Function at 0x406578
Capabilities:
Encode data using xor

Disassembly:
sub esp, 0x4f8
and dword [esp + 0xc], 0
push ebx
push ebp
mov ebp, dword [esp + 0x50c]
mov ebx, ecx
mov dword [esp + 0xc], ebx
push esi
push edi
mov edi, edx
mov dword [esp + 0x18], edi
test ebp, ebp
jle 0x4065e5
mov eax, dword [esp + 0x510]
mov edi, dword [esp + 0x50c]
sub eax, edi
mov ebx, dword [esp + 0x1c]
mov dword [esp + 0x510], eax
mov esi, dword [eax + edi]
mov eax, dword [esp + 0x18]
push esi
push dword [edi]
add eax, ebx
push eax
call fcn.0040d230
mov eax, dword [esp + 0x51c]
lea edi, [edi + 4]
add esp, 0xc
add ebx, esi
dec ebp
jne 0x4065b9
mov ebx, dword [esp + 0x14]
mov edi, dword [esp + 0x18]
xor ebp, ebp
mov ecx, ebp
mov edx, ebp
test ebx, ebx
jle 0x40660e
mov esi, dword [esp + 0x518]
mov al, byte [ecx + esi]
xor byte [edx + edi], al
inc ecx
xor eax, eax
cmp ecx, dword [esp + 0x51c]
cmove ecx, eax
inc edx
cmp edx, ebx
jl 0x4065f6
push 0x44c
call fcn.0040e5e7
mov esi, eax
pop ecx
test esi, esi
je 0x40663a
or dword [esi + 4], 0xffffffff
or dword [esi + 0x238], 0xffffffff
mov dword [esi], ebp
mov dword [esi + 0x23c], ebp
mov dword [esi + 0x240], ebp
jmp 0x40663c
mov esi, ebp
push ecx
push ebx
push edi
mov ecx, esi
call fcn.0040c99c
mov dword [0x491254], eax
test eax, eax
je 0x40665f
test esi, esi
je 0x40665b
push ecx
mov ecx, esi
call fcn.0040d042
mov edi, ebp
jmp 0x406672
push 8
call fcn.0040e5e7
mov edi, eax
pop ecx
mov dword [edi], 1
mov dword [edi + 4], esi
push 5
mov edx, 0x428b34
lea ecx, [esp + 0x24]
call fcn.00404f88
cmp dword [eax + 0x14], 8
jb 0x40668a
mov eax, dword [eax]
mov edx, 0x80000
mov ecx, 0x10000
test edi, edi
jne 0x4066a2
mov dword [0x491254], ecx
mov esi, ecx
jmp 0x4066cd
cmp dword [edi], 1
je 0x4066b1
mov dword [0x491254], edx
mov esi, edx
jmp 0x4066cd
lea ecx, [esp + 0x38]
push ecx
lea ecx, [esp + 0x18]
push ecx
push ecx
mov ecx, dword [edi + 4]
push eax
call fcn.0040ceb9
mov esi, eax
mov dword [0x491254], esi
push ebp
push 1
lea ecx, [esp + 0x28]
call fcn.0040199b
test esi, esi
je 0x406766
cmp byte [0x48ad81], 0
je 0x40673e
push esi
push str.z__x
lea eax, [esp + 0x270]
push 0x3ff
push eax
call fcn.00404f56
add esp, 0x10
lea ecx, [esp + 0x20]
mov edx, 0x427db4
push 3
call fcn.00404f88
cmp dword [eax + 0x14], 8
jb 0x40671d
mov eax, dword [eax]
push 0x40040
push eax
lea eax, [esp + 0x270]
push eax
push ebp
call dword [0x48a9d0]
push ebp
push 1
lea ecx, [esp + 0x28]
call fcn.0040199b
push 0x2f
mov edx, 0x430bd0
lea ecx, [esp + 0x24]
call fcn.00404f88
mov ecx, eax
call fcn.004079de
push ebp
push 1
lea ecx, [esp + 0x28]
call fcn.0040199b
jmp 0x406803
mov ebx, dword [esp + 0x264]
push ebx
call fcn.0040d223
mov ebp, eax
pop ecx
test edi, edi
jne 0x406786
mov dword [0x491254], 0x10000
jmp 0x4067ab
cmp dword [edi], 1
je 0x406797
mov dword [0x491254], 0x80000
jmp 0x4067ab
push ecx
mov ecx, dword [edi + 4]
push ebx
push ebp
push dword [esp + 0x20]
call fcn.0040cf61
mov dword [0x491254], eax
push ebx
push ebp
push dword [esp + 0x20]
call fcn.0040d230
add esp, 0xc
test edi, edi
jne 0x4067c9
mov dword [0x491254], 0x10000
jmp 0x4067fc
cmp dword [edi], 1
je 0x4067da
mov dword [0x491254], 0x80000
jmp 0x4067fc
mov esi, dword [edi + 4]
mov ecx, esi
call fcn.0040d004
mov dword [0x491254], eax
test esi, esi
je 0x4067f5
push ecx
mov ecx, esi
call fcn.0040d042
push edi
call fcn.0040e472
pop ecx
push ebp
call fcn.0040e76b
pop ecx
pop edi
pop esi
pop ebp
mov eax, ebx
pop ebx
add esp, 0x4f8
ret 0x14