Function at 0x40d720
Capabilities:
Encode data using xor

Disassembly:
sub esp, 0x48
push ebx
push ebp
push esi
push edi
xor edi, edi
mov dword [esp + 0x10], edi
lea ecx, [ecx]
mov edx, dword [esp + 0x5c]
mov ecx, edi
imul ecx, ecx, 0xbc
mov eax, dword [ecx + 0x4a5518]
mov ecx, dword [ecx + 0x4a551c]
add eax, edx
add ecx, edx
cmp edi, 2
jge 0x40d7cc
cmp dword [esp + 0x60], 0
movzx ebx, word [eax + 0x12]
mov edx, dword [ecx + 4]
mov ebp, dword [eax + 4]
mov esi, dword [eax + 8]
mov dword [esp + 0x30], ebx
movzx ebx, word [ecx + 0x12]
mov dword [esp + 0x34], edx
mov edx, dword [ecx + 8]
mov dword [esp + 0x28], ebp
mov dword [esp + 0x2c], esi
mov dword [esp + 0x38], edx
mov dword [esp + 0x3c], ebx
jne 0x40d7c2
mov ebx, dword [eax + 0x40004]
mov dword [esp + 0x40], ebx
mov ebx, dword [eax + 0x40008]
movzx eax, word [eax + 0x40012]
mov dword [esp + 0x48], eax
mov eax, dword [ecx + 0x40004]
mov dword [esp + 0x4c], eax
mov eax, dword [ecx + 0x40008]
movzx ecx, word [ecx + 0x40012]
mov dword [esp + 0x44], ebx
mov dword [esp + 0x50], eax
mov dword [esp + 0x54], ecx
mov dword [esp + 0x14], 0x14
jmp 0x40d847
cmp dword [esp + 0x60], 0
movzx ebx, word [eax + 0xe]
mov esi, dword [eax]
mov edx, dword [ecx]
mov dword [esp + 0x30], ebx
movzx ebx, word [ecx + 0xe]
mov dword [esp + 0x28], esi
mov esi, dword [eax + 4]
mov dword [esp + 0x34], edx
mov edx, dword [ecx + 4]
mov dword [esp + 0x2c], esi
mov dword [esp + 0x38], edx
mov dword [esp + 0x3c], ebx
jne 0x40d83b
mov ebx, dword [eax + 0x40000]
mov dword [esp + 0x40], ebx
mov ebx, dword [eax + 0x40004]
movzx eax, word [eax + 0x4000e]
mov dword [esp + 0x48], eax
mov eax, dword [ecx + 0x40000]
mov dword [esp + 0x4c], eax
mov eax, dword [ecx + 0x40004]
movzx ecx, word [ecx + 0x4000e]
mov dword [esp + 0x44], ebx
mov dword [esp + 0x50], eax
mov dword [esp + 0x54], ecx
mov ebp, dword [esp + 0x28]
mov dword [esp + 0x14], 0x10
xor ebx, ebx
cmp esi, ebx
je 0x40d852
cmp esi, 0xffffffff
jne 0x40d85b
cmp ebp, ebx
je 0x40d868
cmp ebp, 0xffffffff
je 0x40d868
mov eax, 1
mov dword [esp + 0x20], eax
xor ebp, ebp
jmp 0x40d873
mov dword [esp + 0x20], ebx
mov ebp, 2
mov eax, ebx
cmp edx, ebx
je 0x40d87c
cmp edx, 0xffffffff
jne 0x40d889
mov ecx, dword [esp + 0x34]
cmp ecx, ebx
je 0x40d894
cmp ecx, 0xffffffff
je 0x40d894
mov ebx, 1
mov dword [esp + 0x24], ebx
jmp 0x40d89d
mov dword [esp + 0x24], ebx
mov ebx, 3
test eax, eax
je 0x40d8ae
cmp esi, dword [edi*8 + 0x4a5798]
jne 0x40da6a
cmp dword [esp + 0x24], 0
je 0x40d8c2
cmp edx, dword [edi*8 + 0x4a579c]
jne 0x40da6a
cmp dword [esp + 0x60], 0
jne 0x40d8fe
mov edx, dword [esp + 0x44]
cmp edx, dword [edi*8 + 0x4a5798]
jne 0x40da6a
mov ecx, dword [esp + 0x50]
cmp ecx, dword [edi*8 + 0x4a579c]
jne 0x40da6a
test eax, eax
je 0x40d8fe
mov edx, dword [esp + 0x28]
cmp dword [esp + 0x40], edx
jbe 0x40d8fe
mov ebp, 2
mov esi, dword [edi*8 + 0x4a5798]
xor ecx, ecx
sub esi, dword [esp + 0x14]
mov eax, 0xffff
je 0x40d960
mov edx, ebp
neg edx
sbb edx, edx
and edx, 0x40000
add edx, dword [esp + 0x5c]
mov dword [esp + 0x18], edx
jmp 0x40d930
mov edx, dword [esp + 0x18]
movzx edx, byte [edx + ecx]
mov dword [esp + 0x1c], ebx
mov ebx, eax
shr ebx, 8
movzx edi, bl
mov ebx, dword [esp + 0x1c]
xor edx, edi
movzx edx, word [edx*2 + 0x4a4ad8]
shl eax, 8
inc ecx
xor eax, edx
cmp ecx, esi
jb 0x40d930
mov edi, dword [esp + 0x10]
movzx edx, ax
lea ecx, [ebp + ebp*2]
cmp edx, dword [esp + ecx*4 + 0x30]
je 0x40d9b0
cmp dword [esp + 0x60], 0
jne 0x40da6a
cmp dword [esp + 0x20], 0
je 0x40da6a
xor ebp, 2
mov edi, ebp
neg edi
sbb edi, edi
and edi, 0x40000
add edi, dword [esp + 0x5c]
call fcn.0040d280
movzx eax, ax
lea ecx, [ebp + ebp*2]
cmp eax, dword [esp + ecx*4 + 0x30]
jne 0x40da66
mov edi, dword [esp + 0x10]
neg ebp
sbb ebp, ebp
and ebp, 0x40000
cmp dword [esp + 0x60], 0
mov dword [0x4dea50], ebp
jne 0x40da87
cmp dword [esp + 0x24], 0
je 0x40d9e1
mov edx, dword [esp + 0x4c]
cmp edx, dword [esp + 0x34]
jbe 0x40d9e1
mov ebx, 3
mov eax, 0xf700
cmp edi, 2
je 0x40d9f2
mov eax, dword [edi*8 + 0x4a5798]
mov esi, dword [edi*8 + 0x4a579c]
sub esi, dword [esp + 0x14]
lea edi, [ebx - 1]
neg edi
sbb edi, edi
and edi, 0x40000
add edi, eax
add edi, dword [esp + 0x5c]
call fcn.0040d280
movzx eax, ax
lea ecx, [ebx + ebx*2]
cmp eax, dword [esp + ecx*4 + 0x30]
je 0x40da83
cmp dword [esp + 0x24], 0
je 0x40da66
mov eax, dword [esp + 0x10]
xor ebx, 2
cmp eax, 2
jne 0x40da3b
mov eax, 0xf700
jmp 0x40da42
mov eax, dword [eax*8 + 0x4a5798]
lea edi, [ebx - 1]
neg edi
sbb edi, edi
and edi, 0x40000
add edi, eax
add edi, dword [esp + 0x5c]
call fcn.0040d280
movzx edx, ax
lea eax, [ebx + ebx*2]
cmp edx, dword [esp + eax*4 + 0x30]
je 0x40da83
mov edi, dword [esp + 0x10]
inc edi
mov dword [esp + 0x10], edi
cmp edi, 3
jl 0x40d730
pop edi
pop esi
pop ebp
or eax, 0xffffffff
pop ebx
add esp, 0x48
ret
mov edi, dword [esp + 0x10]
dec ebx
neg ebx
mov eax, edi
pop edi
sbb ebx, ebx
pop esi
and ebx, 0x40000
pop ebp
mov dword [0x4dea54], ebx
pop ebx
add esp, 0x48
ret