Function at 0x512da0
Capabilities:
Encrypt data using rc4 ksa

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x24
mov eax, dword [ebp + 0x18]
push ebx
and eax, 2
push esi
mov esi, ecx
cmp al, 2
sete byte [ebp - 1]
cmp byte [esi + 0x12c], 8
push edi
ja 0x512dd5
mov cl, byte [esi + 0x11e]
movzx eax, cl
dec eax
je 0x512de0
dec eax
dec eax
je 0x512de0
sub eax, 6
je 0x512de0
mov dword [esi], 0x1c
jmp 0x513159
xor ebx, ebx
cmp cl, 3
jne 0x512def
mov dword [esi + 0x108], ebx
jmp 0x512df9
mov dword [esi + 0x108], 1
mov al, byte [esi + 0x11c]
cmp al, bl
je 0x512e22
mov ecx, dword [ebp + 8]
movzx eax, al
push eax
lea eax, [esi + 4]
push eax
call fcn.0050f3f0
test al, al
jne 0x512e22
mov dword [esi], 3
jmp 0x513159
mov al, byte [esi + 0x12d]
mov edi, dword [ebp + 0x14]
mov cl, al
push 0x400
shr al, 5
and cl, 0xf
and al, 1
push ebx
push edi
mov byte [esi + 0x104], cl
mov byte [ebp + 0x1b], al
call fcn.005d2100
add esp, 0xc
cmp byte [esi + 0x11d], bl
je 0x512eab
movzx eax, word [esi + 0x121]
movzx ecx, word [esi + 0x11f]
add eax, ecx
mov dword [ebp - 0x10], ebx
test eax, eax
jle 0x512ed4
add edi, 2
movzx eax, byte [esi + 0x123]
push eax
lea eax, [edi + 1]
push dword [ebp + 8]
mov ecx, esi
push eax
lea eax, [edi - 1]
push edi
push eax
lea eax, [edi - 2]
push eax
call fcn.00513162
movzx eax, word [esi + 0x121]
movzx ecx, word [esi + 0x11f]
inc dword [ebp - 0x10]
add eax, ecx
add edi, 4
cmp dword [ebp - 0x10], eax
jl 0x512e6f
jmp 0x512ed4
cmp dword [esi + 0x108], ebx
jne 0x513153
xor ecx, ecx
lea eax, [edi + 2]
or byte [eax + 1], 0xff
mov byte [eax - 2], cl
mov byte [eax - 1], cl
mov byte [eax], cl
inc ecx
add eax, 4
cmp ecx, 0x100
jl 0x512ebc
mov al, byte [esi + 0x11e]
cmp al, 9
je 0x512ee6
cmp al, 0xa
je 0x512ee6
cmp al, 0xb
jne 0x512eed
or dword [esi + 0x108], 4
movzx eax, word [esi + 0x128]
cmp byte [ebp - 1], bl
mov dword [ebp - 8], eax
mov dword [ebp - 0x10], ebx
je 0x512f19
lea eax, [eax*8 + 0x1f]
push 0x20
cdq
pop ecx
mov dword [ebp - 0x10], 0x428
idiv ecx
shl eax, 2
mov dword [ebp - 8], eax
movzx edi, word [esi + 0x12a]
imul edi, eax
add edi, dword [ebp - 0x10]
lea ecx, [ebp - 0x24]
call fcn.0051a511
push edi
lea ecx, [ebp - 0x24]
call fcn.0051a51d
mov eax, dword [ebp - 0x1c]
cmp eax, ebx
jne 0x512f49
mov dword [esi], 1
jmp 0x513159
cmp byte [ebp - 1], bl
mov ecx, eax
mov dword [ebp - 0x18], ecx
je 0x512fbe
mov dword [eax], 0x28
push 0x400
movzx ecx, word [esi + 0x128]
mov dword [eax + 4], ecx
push dword [ebp + 0x14]
movzx ecx, word [esi + 0x12a]
mov dword [eax + 8], ecx
mov word [eax + 0xc], 1
mov word [eax + 0xe], 8
mov dword [eax + 0x10], ebx
movzx ecx, word [esi + 0x12a]
imul ecx, dword [ebp - 8]
mov dword [eax + 0x14], ecx
mov dword [eax + 0x18], ebx
mov dword [eax + 0x1c], ebx
mov dword [eax + 0x20], 0x100
mov dword [eax + 0x24], ebx
mov eax, dword [ebp - 0x1c]
add eax, 0x28
push eax
call dword [0x6a1344]
mov ecx, dword [ebp - 0x18]
add esp, 0xc
cmp byte [ebp + 0x1b], bl
sete al
mov byte [ebp + 0x1b], al
mov eax, dword [ebp - 0x10]
mov dword [esi + 0x114], ebx
add eax, ecx
cmp byte [ebp + 0x1b], bl
mov dword [esi + 0x118], ebx
mov dword [ebp - 0xc], eax
jne 0x512fdf
sub ecx, dword [ebp - 8]
add ecx, edi
mov dword [ebp - 0xc], ecx
cmp word [esi + 0x12a], bx
mov dword [ebp - 0x10], ebx
jbe 0x5130cd
mov edi, 0x6a13a0
cmp dword [esi], ebx
jne 0x5130cd
mov eax, dword [ebp - 0xc]
cmp word [esi + 0x128], bx
mov dword [ebp - 0x14], eax
mov dword [ebp - 0x18], ebx
jbe 0x513059
movzx eax, byte [esi + 0x12c]
push dword [ebp + 0x14]
mov ecx, esi
push eax
lea eax, [ebp - 2]
push dword [ebp + 8]
push eax
lea eax, [ebp - 3]
push eax
lea eax, [ebp - 4]
push eax
lea eax, [ebp - 1]
push eax
call fcn.0051328d
test eax, eax
je 0x513053
mov ecx, dword [ebp - 0x14]
mov al, byte [ebp - 1]
inc dword [ebp - 0x14]
inc dword [ebp - 0x18]
mov byte [ecx], al
movzx eax, word [esi + 0x128]
cmp dword [ebp - 0x18], eax
jb 0x51300e
jmp 0x513059
mov dword [esi], 3
cmp byte [ebp + 0x1b], bl
mov eax, dword [ebp - 8]
jne 0x513066
sub dword [ebp - 0xc], eax
jmp 0x513069
add dword [ebp - 0xc], eax
mov ecx, edi
call fcn.00506673
cmp dword [eax + 4], 1
jne 0x5130ac
mov ecx, edi
call fcn.00506673
cmp dword [eax], ebx
je 0x5130ac
mov ecx, edi
call fcn.00506673
mov ecx, edi
mov dword [ebp - 0x18], eax
call fcn.00506673
push dword [eax + 8]
movzx eax, word [esi + 0x12a]
push eax
mov eax, dword [ebp - 0x18]
push dword [ebp - 0x10]
call dword [eax]
neg eax
sbb eax, eax
inc eax
jmp 0x5130ae
xor eax, eax
cmp eax, ebx
jne 0x5130c7
movzx eax, word [esi + 0x12a]
inc dword [ebp - 0x10]
cmp dword [ebp - 0x10], eax
jb 0x512ff4
jmp 0x5130cd
mov dword [esi], 0xe
movzx eax, word [esi + 0x128]
mov ecx, dword [ebp + 0xc]
mov dword [ecx], eax
mov ecx, dword [ebp + 0x10]
movzx eax, word [esi + 0x12a]
mov dword [ecx], eax
lea eax, [esi + 0x31d]
push eax
mov ecx, esi
push dword [ebp + 8]
call fcn.00513655
test al, al
je 0x513149
push str.Found_TGA_footer_n
push ebx
call fcn.005cee82
mov eax, dword [esi + 0x31d]
pop ecx
cmp eax, ebx
pop ecx
je 0x513134
lea ecx, [esi + 0x12e]
push ecx
push eax
push dword [ebp + 8]
mov ecx, esi
call fcn.005136b0
test al, al
je 0x513134
push str.Found_TGA_extension_n
push ebx
call fcn.005cee82
pop ecx
pop ecx
cmp dword [esi + 0x321], ebx
je 0x513149
push str.TGA_has_developer_ext_n
push ebx
call fcn.005cee82
pop ecx
pop ecx
lea ecx, [ebp - 0x24]
call fcn.0051a67e
jmp 0x51315b
mov dword [esi], 0x20
xor eax, eax
pop edi
pop esi
pop ebx
leave
ret 0x14