Function at 0x40d140
Capabilities:
Encode data using xor

Disassembly:
mov ecx, dword [0x42ae1c]
sub esp, 0x34
push ebx
push ebp
mov ebp, dword [ecx*4 + 0x42ab90]
test ebp, ebp
je 0x40d5a5
mov edx, dword [ecx*4 + 0x42aad0]
xor eax, eax
test edx, edx
jbe 0x40d184
mov bl, byte [eax + ebp]
mov cl, al
add cl, 0x42
xor bl, cl
mov byte [eax + ebp], bl
mov edx, dword [0x42ae1c]
inc eax
cmp eax, dword [edx*4 + 0x42aad0]
jb 0x40d167
xor eax, eax
mov ax, word [ebp]
add ebp, 2
test eax, eax
jbe 0x40d5a5
push esi
push edi
mov dword [esp + 0x3c], eax
mov eax, dword [ebp]
mov esi, dword [ebp + 4]
add ebp, 4
mov dword [esp + 0x14], eax
add ebp, 8
xor eax, eax
mov dword [esp + 0x2c], esi
mov cl, byte [ebp]
inc ebp
mov byte [esp + 0x13], cl
mov edi, ebp
or ecx, 0xffffffff
mov edx, ebp
repne scasb al, byte es:[edi]
not ecx
dec ecx
push edx
mov edx, dword [0x42a9b4]
lea ebp, [ecx + ebp + 1]
or ecx, 0xffffffff
mov edi, ebp
mov ebx, ebp
repne scasb al, byte es:[edi]
not ecx
dec ecx
push edx
lea ebp, [ecx + ebp + 1]
mov dword [esp + 0x3c], ebp
add ebp, esi
call fcn.0040c990
push 0xffdc
push ebx
push 0
call fcn.0040c850
mov edi, eax
add esp, 0x14
test edi, edi
mov dword [esp + 0x30], edi
je 0x40d594
lea eax, [edi + edi + 1]
push eax
call fcn.0041a470
lea ecx, [edi + 1]
mov dword [esp + 0x3c], eax
push ecx
push ebx
push eax
call fcn.0040c850
mov edx, dword [0x42a9b4]
push 2
push edx
call fcn.00401140
mov ebx, eax
add esp, 0x18
cmp ebx, 0xffffffff
jne 0x40d25f
test byte [esp + 0x13], 0x28
je 0x40d587
mov eax, dword [0x42a9b4]
push eax
call fcn.00401190
mov ebx, eax
add esp, 4
cmp ebx, 0xffffffff
je 0x40d587
test byte [esp + 0x13], 8
je 0x40d2ed
push ebx
call fcn.004012c0
mov dword [esp + 0x18], eax
mov al, byte [esp + 0x17]
add esp, 4
test al, 0x10
je 0x40d412
mov eax, dword [esp + 0x14]
mov esi, 2
cmp eax, esi
jb 0x40d412
mov ecx, eax
add ecx, 0xfffffffe
push ecx
push ebx
call fcn.00401260
lea edx, [esp + 0x30]
push esi
push edx
push ebx
call fcn.004011c0
mov eax, dword [esp + 0x3c]
add esp, 0x14
cmp ax, 0xa0d
je 0x40d412
cmp ax, 0xd0a
je 0x40d412
lea eax, [esp + 0x28]
push esi
push eax
push ebx
mov dword [esp + 0x34], 0xa0d
call fcn.00401200
mov eax, dword [esp + 0x20]
add esp, 0xc
add eax, esi
mov dword [esp + 0x14], eax
jmp 0x40d412
cmp dword [esp + 0x14], 0xffffffff
jne 0x40d41d
test esi, esi
je 0x40d57e
push ebx
call fcn.004012c0
add esp, 4
cmp eax, 0x8000
mov edi, eax
jb 0x40d317
mov edi, 0x8000
lea ecx, [esp + 0x18]
sub eax, edi
push ecx
push edi
mov dword [esp + 0x28], eax
call fcn.00402180
add esp, 8
test eax, eax
je 0x40d57e
mov edx, dword [esp + 0x18]
push edi
push edx
push ebx
call fcn.004011c0
add esp, 0xc
mov dword [esp + 0x24], 0
mov eax, edi
mov edx, dword [esp + 0x20]
mov ecx, 0x4000
test edx, edx
mov dword [esp + 0x1c], ecx
jne 0x40d366
sub eax, esi
inc eax
mov ecx, eax
mov dword [esp + 0x1c], ecx
mov eax, dword [esp + 0x18]
test ecx, ecx
je 0x40d394
jmp 0x40d374
mov esi, dword [esp + 0x2c]
mov edi, dword [esp + 0x34]
mov ecx, esi
mov esi, eax
xor edx, edx
repe cmpsb byte [esi], byte es:[edi]
mov ecx, dword [esp + 0x1c]
je 0x40d390
inc eax
dec ecx
mov dword [esp + 0x1c], ecx
jne 0x40d370
jmp 0x40d394
test ecx, ecx
jne 0x40d3eb
mov eax, dword [esp + 0x20]
test eax, eax
je 0x40d401
mov eax, dword [esp + 0x18]
mov edi, dword [esp + 0x18]
mov edx, dword [esp + 0x24]
add eax, 0x4000
mov ecx, 0x1000
mov esi, eax
rep movsd dword es:[edi], dword [esi]
mov esi, dword [esp + 0x20]
mov edi, 0x4000
add edx, edi
cmp esi, edi
mov dword [esp + 0x24], edx
ja 0x40d3cb
mov edi, esi
push edi
push eax
push ebx
call fcn.004011c0
add esp, 0xc
sub esi, edi
mov dword [esp + 0x20], esi
mov esi, dword [esp + 0x2c]
lea eax, [edi + 0x4000]
jmp 0x40d34c
mov esi, dword [esp + 0x18]
mov edx, dword [esp + 0x24]
mov ecx, dword [esp + 0x2c]
sub eax, esi
add eax, edx
add eax, ecx
mov dword [esp + 0x14], eax
lea ecx, [esp + 0x18]
push ecx
call fcn.00402200
mov edi, dword [esp + 0x34]
add esp, 4
cmp dword [esp + 0x14], 0xffffffff
je 0x40d57e
mov edx, dword [esp + 0x14]
push edx
push ebx
call fcn.00401260
mov al, byte [esp + 0x1b]
add esp, 8
test al, 0x20
je 0x40d567
cmp edi, 0x186a0
jbe 0x40d447
mov esi, edi
mov dword [esp + 0x2c], esi
jmp 0x40d453
mov dword [esp + 0x2c], 0x186a0
mov esi, dword [esp + 0x2c]
lea eax, [esi + esi]
push eax
call fcn.0041a470
add esp, 4
mov dword [esp + 0x40], eax
test eax, eax
je 0x40d55a
mov ecx, dword [esp + 0x14]
mov dword [esp + 0x1c], edi
mov dword [esp + 0x30], ecx
mov dword [esp + 0x20], ecx
lea ecx, [eax + esi]
mov esi, dword [esp + 0x38]
mov dword [esp + 0x34], ecx
mov ecx, edi
mov edx, ecx
mov edi, eax
shr ecx, 2
rep movsd dword es:[edi], dword [esi]
mov ecx, edx
push ebx
and ecx, 3
mov dword [esp + 0x28], eax
rep movsb byte es:[edi], byte [esi]
call fcn.004012c0
mov edi, eax
mov eax, dword [esp + 0x18]
add esp, 4
sub edi, eax
je 0x40d529
mov esi, dword [esp + 0x2c]
cmp esi, edi
jb 0x40d4b9
mov esi, edi
mov eax, dword [esp + 0x30]
push eax
push ebx
call fcn.00401260
mov ecx, dword [esp + 0x3c]
push esi
push ecx
push ebx
call fcn.004011c0
mov ecx, dword [esp + 0x44]
mov eax, dword [esp + 0x30]
add esp, 0x14
add ecx, esi
test eax, eax
mov dword [esp + 0x30], ecx
je 0x40d511
mov edx, dword [esp + 0x20]
push edx
push ebx
call fcn.00401260
mov eax, dword [esp + 0x24]
mov ecx, dword [esp + 0x2c]
push eax
push ecx
push ebx
call fcn.00401200
mov edx, dword [esp + 0x30]
mov eax, dword [esp + 0x34]
add esp, 0x14
add eax, edx
mov dword [esp + 0x20], eax
mov eax, dword [esp + 0x24]
mov ecx, dword [esp + 0x34]
sub edi, esi
mov dword [esp + 0x1c], esi
mov dword [esp + 0x24], ecx
mov dword [esp + 0x34], eax
jne 0x40d4af
mov esi, dword [esp + 0x1c]
test esi, esi
je 0x40d54b
mov edx, dword [esp + 0x20]
push edx
push ebx
call fcn.00401260
mov eax, dword [esp + 0x2c]
push esi
push eax
push ebx
call fcn.00401200
add esp, 0x14
mov ecx, dword [esp + 0x40]
push ecx
call fcn.0041a5d3
add esp, 4
jmp 0x40d57e
push 0
push ebx
call fcn.004012a0
add esp, 8
jmp 0x40d57e
mov edx, dword [esp + 0x38]
push edi
push edx
push ebx
call fcn.00401200
push 0
push ebx
call fcn.004012a0
add esp, 0x14
push ebx
call fcn.004013c0
add esp, 4
mov eax, dword [esp + 0x38]
push eax
call fcn.0041a5d3
add esp, 4
mov eax, dword [esp + 0x3c]
dec eax
mov dword [esp + 0x3c], eax
jne 0x40d19b
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x34
ret