int
__fastcall sub_51EC7A48(
char
*filepath,
char
*lockpath)
{
int
*dwords;
int
bytes_temp;
char
*filepath1;
char
*lockpath1;
_DWORD *temp;
_DWORD *temp1;
int
signature_array1;
int
index;
int
v10;
int
index1;
int
a;
int
v13;
int
v14;
int
v15;
int
temp3;
int
temp_192;
int
signature_array2;
int
index2;
int
index3;
int
b;
int
v22;
char
i;
char
c;
size_t
readSize;
size_t
readSize1;
_BYTE *readEnd;
int
readLast;
int
*v29;
int
*new_temp;
signed
int
index4;
int
signature_array3;
int
result;
FILE
*inputstream;
FILE
*outputstream;
char
bytes_temp0;
char
bytes_temp4;
char
bytes_temp8;
char
bytes_temp12;
char
bytes_temp1;
char
bytes_temp5;
char
bytes_temp9;
char
bytes_temp13;
char
bytes_temp2;
char
bytes_temp6;
char
bytes_temp10;
char
bytes_temp14;
char
bytes_temp3;
char
bytes_temp7;
char
bytes_temp11;
char
bytes_temp15;
int
v52;
filepath1 = filepath;
lockpath1 = lockpath;
if
( !temp2 )
{
temp =
malloc
(0x180u);
temp1 = temp;
temp2 = (
int
)temp;
signature_array1 = signature_array;
index = 0;
do
{
v10 = *(unsigned
__int8
*)(signature_array1 + index * 4 + 3);
temp1[index] = _byteswap_ulong(*(_DWORD *)(signature_array1 + index * 4));
++index;
}
while
( index != 4 );
index1 = 0;
a = temp1[3];
do
{
if
( !((index1 + 4) & 3) )
{
v13 = *(
int
*)((
char
*)&dword_51EC9F20 + ((index1 + 3 + ((unsigned
int
)((index1 + 3) >> 31) >> 30)) & 0xFFFFFFFC));
a = func0(__ROR4__(a, 24)) ^ v13;
}
v14 = temp1[index1];
v15 = (
int
)&temp1[index1++];
a ^= v14;
*(_DWORD *)(v15 + 16) = a;
}
while
( index1 != 40 );
temp3 = temp2;
temp_192 = temp2 + 192;
temp_192_1 = temp2 + 192;
signature_array2 = signature_array;
index2 = 0;
do
{
bytes_temp = (*(unsigned
__int8
*)(signature_array2 + index2 + 17) << 16) | (*(unsigned
__int8
*)(signature_array2 + index2 + 16) << 24) | (*(unsigned
__int8
*)(signature_array2 + index2 + 18) << 8);
*(_DWORD *)(temp_192 + index2) = _byteswap_ulong(*(_DWORD *)(signature_array2 + index2 + 16));
index2 += 4;
}
while
( index2 != 16 );
index3 = 0;
b = *(_DWORD *)(temp3 + 204);
dwords = &dword_51EC9F20;
do
{
if
( !((index3 + 4) & 3) )
{
bytes_temp = *(
int
*)((
char
*)&dword_51EC9F20
+ ((index3 + 3 + ((unsigned
int
)((index3 + 3) >> 31) >> 30)) & 0xFFFFFFFC));
b = func0(__ROR4__(b, 24)) ^ bytes_temp;
}
v22 = temp3 + 4 * index3++;
b ^= *(_DWORD *)(v22 + 192);
*(_DWORD *)(v22 + 208) = b;
}
while
( index3 != 40 );
}
inputstream =
fopen
(filepath1, (
const
char
*)&r);
if
( inputstream )
{
outputstream =
fopen
(lockpath1, (
const
char
*)&w);
if
( outputstream )
{
bytes_temp = (
int
)
malloc
(0x100u);
lockpath1 = (
char
*)inputstream;
dwords = (
int
*)
malloc
(0x100u);
for
( i = 0; ; ++i )
{
c = *(_BYTE *)(signature_array + (i & 0x1F));
readSize =
fread
((
void
*)bytes_temp, 1u, *(unsigned
__int8
*)(signature_array + (i & 0x1F)), (
FILE
*)lockpath1);
readSize1 = readSize;
if
( !readSize )
goto
LABEL_31;
if
( readSize <= 0xF )
{
readEnd = (_BYTE *)(bytes_temp + readSize);
readLast = 16 - (readSize1 & 0xF);
if
( (readSize1 & 0xF) != 16 )
{
_aeabi_memset(readEnd, 16 - (readSize1 & 0xF), (unsigned
__int8
)readLast);
readEnd = (_BYTE *)(readLast + readSize1 + bytes_temp);
}
lockpath1 = (
char
*)inputstream;
readSize1 = 16;
*readEnd = 0;
}
v29 = &temp_192_1;
if
( !(c & 1) )
v29 = &temp2;
new_temp = (
int
*)*v29;
bytes_temp0 = *(_BYTE *)bytes_temp;
bytes_temp1 = *(_BYTE *)(bytes_temp + 1);
bytes_temp2 = *(_BYTE *)(bytes_temp + 2);
bytes_temp3 = *(_BYTE *)(bytes_temp + 3);
bytes_temp4 = *(_BYTE *)(bytes_temp + 4);
bytes_temp5 = *(_BYTE *)(bytes_temp + 5);
bytes_temp6 = *(_BYTE *)(bytes_temp + 6);
bytes_temp7 = *(_BYTE *)(bytes_temp + 7);
bytes_temp8 = *(_BYTE *)(bytes_temp + 8);
bytes_temp9 = *(_BYTE *)(bytes_temp + 9);
bytes_temp10 = *(_BYTE *)(bytes_temp + 10);
bytes_temp11 = *(_BYTE *)(bytes_temp + 11);
bytes_temp12 = *(_BYTE *)(bytes_temp + 12);
bytes_temp13 = *(_BYTE *)(bytes_temp + 13);
bytes_temp14 = *(_BYTE *)(bytes_temp + 14);
bytes_temp15 = *(_BYTE *)(bytes_temp + 15);
func1(&bytes_temp0, new_temp);
func2(&bytes_temp0);
func3(&bytes_temp0);
func4((unsigned
__int8
*)&bytes_temp0);
func1(&bytes_temp0, new_temp + 4);
func2(&bytes_temp0);
func3(&bytes_temp0);
func4((unsigned
__int8
*)&bytes_temp0);
func1(&bytes_temp0, new_temp + 8);
func2(&bytes_temp0);
func3(&bytes_temp0);
func4((unsigned
__int8
*)&bytes_temp0);
func1(&bytes_temp0, new_temp + 12);
func2(&bytes_temp0);
func3(&bytes_temp0);
func4((unsigned
__int8
*)&bytes_temp0);
func1(&bytes_temp0, new_temp + 16);
func2(&bytes_temp0);
func3(&bytes_temp0);
func4((unsigned
__int8
*)&bytes_temp0);
func1(&bytes_temp0, new_temp + 20);
func2(&bytes_temp0);
func3(&bytes_temp0);
func4((unsigned
__int8
*)&bytes_temp0);
func1(&bytes_temp0, new_temp + 24);
func2(&bytes_temp0);
func3(&bytes_temp0);
func4((unsigned
__int8
*)&bytes_temp0);
func1(&bytes_temp0, new_temp + 28);
func2(&bytes_temp0);
func3(&bytes_temp0);
func4((unsigned
__int8
*)&bytes_temp0);
func1(&bytes_temp0, new_temp + 32);
func2(&bytes_temp0);
func3(&bytes_temp0);
func4((unsigned
__int8
*)&bytes_temp0);
func1(&bytes_temp0, new_temp + 36);
func2(&bytes_temp0);
func3(&bytes_temp0);
func1(&bytes_temp0, new_temp + 40);
*(_BYTE *)dwords = bytes_temp0;
*((_BYTE *)dwords + 1) = bytes_temp1;
*((_BYTE *)dwords + 2) = bytes_temp2;
*((_BYTE *)dwords + 3) = bytes_temp3;
*((_BYTE *)dwords + 4) = bytes_temp4;
*((_BYTE *)dwords + 5) = bytes_temp5;
*((_BYTE *)dwords + 6) = bytes_temp6;
*((_BYTE *)dwords + 7) = bytes_temp7;
*((_BYTE *)dwords + 8) = bytes_temp8;
*((_BYTE *)dwords + 9) = bytes_temp9;
*((_BYTE *)dwords + 10) = bytes_temp10;
*((_BYTE *)dwords + 11) = bytes_temp11;
*((_BYTE *)dwords + 12) = bytes_temp12;
*((_BYTE *)dwords + 13) = bytes_temp13;
*((_BYTE *)dwords + 14) = bytes_temp14;
*((_BYTE *)dwords + 15) = bytes_temp15;
if
( readSize1 >= 0x11 )
{
index4 = 16;
signature_array3 = signature_array;
do
{
*((_BYTE *)dwords + index4) = *(_BYTE *)(bytes_temp + index4) ^ *(_BYTE *)(signature_array3 + index4 % 32);
++index4;
}
while
( index4 < readSize1 );
}
if
(
fwrite
(dwords, 1u, readSize1, outputstream) != readSize1 )
break
;
}
}
}
result = -1;
while
( _stack_chk_guard != v52 )
{
LABEL_31:
free
((
void
*)bytes_temp);
free
(dwords);
fclose
((
FILE
*)lockpath1);
fclose
(outputstream);
result = 0;
}
return
result;
}