Function at 0x40d510
Capabilities:
Encode data using xor

Disassembly:
sub esp, 0x588
mov eax, dword [0x551a60]
push ebx
push ebp
push esi
push edi
push eax
call dword [0x5002a4]
xor ebp, ebp
mov dword [esp + 0x4c], eax
cmp eax, ebp
jne 0x40d540
pop edi
pop esi
pop ebp
mov eax, 1
pop ebx
add esp, 0x588
ret
mov esi, dword [esp + 0x5a0]
mov ecx, 0x120
xor eax, eax
lea edi, [esp + 0x118]
rep stosd dword es:[edi], eax
mov ecx, 0x11
lea edi, [esp + 0x50]
rep stosd dword es:[edi], eax
mov ecx, dword [esp + 0x59c]
mov edx, esi
mov eax, dword [ecx]
add ecx, 4
mov ebx, dword [esp + eax*4 + 0x50]
lea eax, [esp + eax*4 + 0x50]
inc ebx
dec edx
mov dword [eax], ebx
jne 0x40d56b
cmp dword [esp + 0x50], esi
jne 0x40d5a3
mov ecx, dword [esp + 0x5b0]
mov edx, dword [esp + 0x5b4]
mov dword [ecx], ebp
mov dword [edx], ebp
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
add esp, 0x588
ret
mov edi, dword [esp + 0x5b4]
mov ecx, 1
lea eax, [esp + 0x54]
mov ebx, dword [edi]
mov dword [esp + 0x14], ebx
cmp dword [eax], ebp
jne 0x40d5c6
inc ecx
add eax, 4
cmp ecx, 0x10
jbe 0x40d5b9
cmp ebx, ecx
mov dword [esp + 0x10], ecx
jae 0x40d5d4
mov dword [esp + 0x14], ecx
mov ebx, ecx
mov eax, 0x10
lea esi, [esp + 0x90]
cmp dword [esi], ebp
jne 0x40d5ec
dec eax
sub esi, 4
cmp eax, ebp
jne 0x40d5e0
mov edx, eax
cmp ebx, eax
mov dword [esp + 0x40], edx
jbe 0x40d5fc
mov dword [esp + 0x14], eax
mov ebx, eax
mov dword [edi], ebx
mov edi, 1
shl edi, cl
cmp ecx, eax
jae 0x40d61b
lea esi, [esp + ecx*4 + 0x50]
sub edi, dword [esi]
js 0x40d627
inc ecx
add esi, 4
shl edi, 1
cmp ecx, eax
jb 0x40d60d
mov ecx, dword [esp + eax*4 + 0x50]
sub edi, ecx
mov dword [esp + 0x48], edi
jns 0x40d637
pop edi
pop esi
pop ebp
mov eax, 2
pop ebx
add esp, 0x588
ret
add ecx, edi
mov dword [esp + 0x98], ebp
mov dword [esp + eax*4 + 0x50], ecx
xor ecx, ecx
dec eax
je 0x40d65e
xor edi, edi
mov esi, dword [esp + edi + 0x54]
add edi, 4
add ecx, esi
dec eax
mov dword [esp + edi + 0x98], ecx
jne 0x40d64b
mov esi, dword [esp + 0x59c]
xor edi, edi
mov eax, dword [esi]
add esi, 4
cmp eax, ebp
je 0x40d688
mov ecx, dword [esp + eax*4 + 0x94]
lea eax, [esp + eax*4 + 0x94]
mov dword [esp + ecx*4 + 0x118], edi
inc ecx
mov dword [eax], ecx
mov eax, dword [esp + 0x5a0]
inc edi
cmp edi, eax
jb 0x40d667
mov ecx, dword [esp + 0x10]
lea eax, [esp + 0x118]
mov dword [esp + 0x2c], eax
mov eax, ebx
or edi, 0xffffffff
xor esi, esi
neg eax
cmp ecx, edx
mov dword [esp + 0x28], ebp
mov dword [esp + 0x94], ebp
mov dword [esp + 0x24], edi
mov dword [esp + 0xd8], ebp
mov dword [esp + 0x44], ebp
jg 0x40d9b2
lea edx, [ecx - 1]
lea ecx, [esp + ecx*4 + 0x50]
mov dword [esp + 0x38], edx
mov dword [esp + 0x34], ecx
mov edx, dword [esp + 0x34]
mov ecx, dword [edx]
mov edx, ecx
dec ecx
test edx, edx
mov dword [esp + 0x30], ecx
je 0x40d989
mov edx, dword [esp + 0x10]
lea ecx, [eax + ebx]
cmp edx, ecx
jle 0x40d827
mov esi, dword [esp + 0x30]
mov dword [esp + 0x3c], ecx
jmp 0x40d70f
mov esi, dword [esp + 0x30]
mov edx, dword [esp + 0x40]
mov ecx, dword [esp + 0x3c]
add eax, ebx
inc edi
sub edx, eax
add ecx, ebx
cmp edx, ebx
mov dword [esp + 0x24], edi
mov dword [esp + 0x20], eax
mov dword [esp + 0x3c], ecx
jbe 0x40d730
mov edx, ebx
mov ebx, dword [esp + 0x10]
sub ebx, eax
mov eax, 1
mov ecx, ebx
shl eax, cl
lea ecx, [esi + 1]
cmp eax, ecx
jbe 0x40d769
or ecx, 0xffffffff
sub ecx, esi
mov esi, dword [esp + 0x34]
add eax, ecx
inc ebx
cmp ebx, edx
jae 0x40d769
mov ecx, dword [esi + 4]
add esi, 4
shl eax, 1
cmp eax, ecx
jbe 0x40d769
sub eax, ecx
inc ebx
cmp ebx, edx
jb 0x40d756
mov esi, 1
mov ecx, ebx
shl esi, cl
lea edx, [esi + esi*2 + 3]
shl edx, 1
push edx
call fcn.004f3cf8
add esp, 4
test eax, eax
je 0x40d9d7
mov ecx, dword [esp + 0x4c]
lea edx, [esi + 1]
mov ebp, dword [ecx + 0x167c0]
add ebp, edx
mov edx, dword [esp + 0x5b0]
mov dword [ecx + 0x167c0], ebp
lea ecx, [eax + 6]
add eax, 2
mov ebp, ecx
mov dword [edx], ecx
mov dword [esp + 0x5b0], eax
test edi, edi
mov dword [eax], 0
mov dword [esp + 0x44], ebp
mov dword [esp + edi*4 + 0xd8], ebp
je 0x40d80f
mov eax, dword [esp + 0x14]
mov ecx, dword [esp + 0x20]
mov edx, dword [esp + 0x28]
mov byte [esp + 0x19], al
sub ecx, eax
mov eax, edx
add bl, 0x10
mov dword [esp + edi*4 + 0x94], edx
shr eax, cl
mov ecx, dword [esp + edi*4 + 0xd4]
mov byte [esp + 0x18], bl
mov dword [esp + 0x1a], ebp
lea eax, [eax + eax*2]
lea edx, [ecx + eax*2]
mov eax, dword [esp + 0x18]
mov cx, word [esp + 0x1c]
mov dword [edx], eax
mov word [edx + 4], cx
mov edx, dword [esp + 0x3c]
mov eax, dword [esp + 0x10]
mov ebx, dword [esp + 0x14]
cmp eax, edx
mov eax, dword [esp + 0x20]
jg 0x40d70b
mov cl, byte [esp + 0x10]
mov edx, dword [esp + 0x5a0]
mov edi, dword [esp + 0x2c]
sub cl, al
mov byte [esp + 0x19], cl
lea ecx, [esp + edx*4 + 0x118]
cmp edi, ecx
jb 0x40d84e
mov byte [esp + 0x18], 0x63
jmp 0x40d8b5
mov ecx, dword [edi]
mov edx, dword [esp + 0x5a4]
cmp ecx, edx
jae 0x40d879
cmp ecx, 0x100
mov word [esp + 0x1a], cx
setb dl
add edx, 0xf
add edi, 4
mov byte [esp + 0x18], dl
mov dword [esp + 0x2c], edi
jmp 0x40d8b5
mov edx, dword [esp + 0x5ac]
test edx, edx
je 0x40d9c7
sub ecx, dword [esp + 0x5a4]
shl ecx, 1
mov edi, ecx
mov ecx, dword [esp + 0x5a8]
mov dl, byte [edi + edx]
mov byte [esp + 0x18], dl
mov dx, word [edi + ecx]
mov ecx, dword [esp + 0x2c]
mov word [esp + 0x1a], dx
add ecx, 4
mov dword [esp + 0x2c], ecx
mov ecx, dword [esp + 0x10]
mov edx, dword [esp + 0x28]
sub ecx, eax
mov edi, 1
shl edi, cl
mov ecx, eax
shr edx, cl
cmp edx, esi
jae 0x40d903
lea ecx, [edi + edi*2]
shl ecx, 1
mov dword [esp + 0x20], ecx
lea ecx, [edx + edx*2]
lea ecx, [ebp + ecx*2]
mov ebp, dword [esp + 0x18]
mov ebx, ecx
add edx, edi
mov dword [ebx], ebp
mov bp, word [esp + 0x1c]
mov word [ebx + 4], bp
mov ebp, dword [esp + 0x20]
add ecx, ebp
cmp edx, esi
jb 0x40d8de
mov ebx, dword [esp + 0x14]
mov ebp, dword [esp + 0x44]
mov ecx, dword [esp + 0x38]
mov edi, dword [esp + 0x28]
mov edx, 1
shl edx, cl
test edi, edx
je 0x40d91e
xor edi, edx
shr edx, 1
test edi, edx
jne 0x40d916
xor edi, edx
mov edx, 1
mov ecx, eax
mov dword [esp + 0x28], edi
shl edx, cl
mov ecx, dword [esp + 0x24]
dec edx
and edx, edi
mov edi, dword [esp + ecx*4 + 0x94]
mov dword [esp + 0x20], edx
lea edx, [esp + ecx*4 + 0x94]
mov ecx, dword [esp + 0x20]
cmp ecx, edi
je 0x40d972
mov edi, dword [esp + 0x24]
sub eax, ebx
dec edi
mov ecx, eax
mov dword [esp + 0x24], edi
mov edi, 1
shl edi, cl
mov ecx, dword [esp + 0x28]
sub edx, 4
dec edi
and edi, ecx
mov ecx, dword [edx]
cmp edi, ecx
jne 0x40d94e
mov ecx, dword [esp + 0x30]
mov edi, dword [esp + 0x24]
mov edx, ecx
dec ecx
test edx, edx
mov dword [esp + 0x30], ecx
jne 0x40d6f2
mov edx, dword [esp + 0x34]
mov ecx, dword [esp + 0x10]
add edx, 4
inc ecx
mov dword [esp + 0x34], edx
mov edx, dword [esp + 0x38]
inc edx
mov dword [esp + 0x10], ecx
mov dword [esp + 0x38], edx
mov edx, dword [esp + 0x40]
cmp ecx, edx
jle 0x40d6dd
mov eax, dword [esp + 0x48]
test eax, eax
je 0x40d596
cmp edx, 1
je 0x40d596
pop edi
pop esi
pop ebp
mov eax, 1
pop ebx
add esp, 0x588
ret
test edi, edi
je 0x40d9eb
mov eax, dword [esp + 0xd8]
push eax
call fcn.0040a5d0
add esp, 4
pop edi
pop esi
pop ebp
mov eax, 3
pop ebx
add esp, 0x588
ret