Function at 0x513881
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 0x5138b6
mov cl, byte [esi + 0x11e]
movzx eax, cl
dec eax
je 0x5138c1
dec eax
dec eax
je 0x5138c1
sub eax, 6
je 0x5138c1
mov dword [esi], 0x1c
jmp 0x513c3a
xor ebx, ebx
cmp cl, 3
jne 0x5138d0
mov dword [esi + 0x108], ebx
jmp 0x5138da
mov dword [esi + 0x108], 1
mov al, byte [esi + 0x11c]
cmp al, bl
je 0x513903
mov ecx, dword [ebp + 8]
movzx eax, al
push eax
lea eax, [esi + 4]
push eax
call fcn.0050fcbd
test al, al
jne 0x513903
mov dword [esi], 3
jmp 0x513c3a
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.005d2a00
add esp, 0xc
cmp byte [esi + 0x11d], bl
je 0x51398c
movzx eax, word [esi + 0x121]
movzx ecx, word [esi + 0x11f]
add eax, ecx
mov dword [ebp - 0x10], ebx
test eax, eax
jle 0x5139b5
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.00513c43
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 0x513950
jmp 0x5139b5
cmp dword [esi + 0x108], ebx
jne 0x513c34
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 0x51399d
mov al, byte [esi + 0x11e]
cmp al, 9
je 0x5139c7
cmp al, 0xa
je 0x5139c7
cmp al, 0xb
jne 0x5139ce
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 0x5139fa
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.0051aff2
push edi
lea ecx, [ebp - 0x24]
call fcn.0051affe
mov eax, dword [ebp - 0x1c]
cmp eax, ebx
jne 0x513a2a
mov dword [esi], 1
jmp 0x513c3a
cmp byte [ebp - 1], bl
mov ecx, eax
mov dword [ebp - 0x18], ecx
je 0x513a9f
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 [0x6a2224]
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 0x513ac0
sub ecx, dword [ebp - 8]
add ecx, edi
mov dword [ebp - 0xc], ecx
cmp word [esi + 0x12a], bx
mov dword [ebp - 0x10], ebx
jbe 0x513bae
mov edi, 0x6a2280
cmp dword [esi], ebx
jne 0x513bae
mov eax, dword [ebp - 0xc]
cmp word [esi + 0x128], bx
mov dword [ebp - 0x14], eax
mov dword [ebp - 0x18], ebx
jbe 0x513b3a
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.00513d6e
test eax, eax
je 0x513b34
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 0x513aef
jmp 0x513b3a
mov dword [esi], 3
cmp byte [ebp + 0x1b], bl
mov eax, dword [ebp - 8]
jne 0x513b47
sub dword [ebp - 0xc], eax
jmp 0x513b4a
add dword [ebp - 0xc], eax
mov ecx, edi
call fcn.00506f83
cmp dword [eax + 4], 1
jne 0x513b8d
mov ecx, edi
call fcn.00506f83
cmp dword [eax], ebx
je 0x513b8d
mov ecx, edi
call fcn.00506f83
mov ecx, edi
mov dword [ebp - 0x18], eax
call fcn.00506f83
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 0x513b8f
xor eax, eax
cmp eax, ebx
jne 0x513ba8
movzx eax, word [esi + 0x12a]
inc dword [ebp - 0x10]
cmp dword [ebp - 0x10], eax
jb 0x513ad5
jmp 0x513bae
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.00514136
test al, al
je 0x513c2a
push str.Found_TGA_footer_n
push ebx
call fcn.00538eb0
mov eax, dword [esi + 0x31d]
pop ecx
cmp eax, ebx
pop ecx
je 0x513c15
lea ecx, [esi + 0x12e]
push ecx
push eax
push dword [ebp + 8]
mov ecx, esi
call fcn.00514191
test al, al
je 0x513c15
push str.Found_TGA_extension_n
push ebx
call fcn.00538eb0
pop ecx
pop ecx
cmp dword [esi + 0x321], ebx
je 0x513c2a
push str.TGA_has_developer_ext_n
push ebx
call fcn.00538eb0
pop ecx
pop ecx
lea ecx, [ebp - 0x24]
call fcn.0051b15f
jmp 0x513c3c
mov dword [esi], 0x20
xor eax, eax
pop edi
pop esi
pop ebx
leave
ret 0x14