Function at 0x40d470
Capabilities:
Encode data using xor

Disassembly:
sub esp, 0xf1c
mov eax, dword [esp + 0xf20]
push ebx
mov ebx, dword [esp + 0xf30]
push ebp
imul eax, ebx
add eax, 0x1f
push esi
cdq
mov esi, dword [esp + 0xf34]
and edx, 0x1f
add eax, edx
push edi
mov edi, eax
mov ebp, esi
sar edi, 5
shl edi, 2
push edi
mov dword [esp + 0x24], edi
mov dword [esp + 0x2c], ebp
call fcn.0040ff21
add esp, 4
mov dword [esp + 0x24], eax
test eax, eax
jne 0x40d4cc
pop edi
pop esi
pop ebp
or eax, 0xffffffff
pop ebx
add esp, 0xf1c
ret
dec ebx
cmp ebx, 0x17
ja case.0x40d4de.5
xor eax, eax
mov al, byte [ebx + 0x40d7b0]
jmp dword [eax*4 + 0x40d79c]
mov ebp, dword [esp + 0xf40]
mov eax, dword [ebp]
lea ecx, [eax + eax*2]
mov eax, dword [ebp + 8]
lea edx, [eax + eax*2]
mov dword [esp + 0x28], edx
mov edx, dword [ebp + 4]
mov ebx, edx
mov dword [esp + 0x14], edx
imul ebx, edi
add ebx, ecx
add ebx, esi
mov eax, dword [ebp + 4]
mov ecx, dword [ebp + 0xc]
add eax, ecx
mov ecx, dword [esp + 0xf34]
cmp eax, ecx
jl 0x40d521
mov eax, ecx
cmp edx, eax
jae case.0x40d4de.5
mov edx, dword [ebp + 8]
mov esi, dword [esp + 0x24]
push edx
push ebx
push esi
call fcn.0040d2b0
mov ecx, dword [esp + 0x34]
mov edi, ebx
mov eax, ecx
add esp, 0xc
shr ecx, 2
rep movsd dword es:[edi], dword [esi]
mov ecx, eax
mov eax, dword [esp + 0x20]
and ecx, 3
rep movsb byte es:[edi], byte [esi]
mov ecx, dword [esp + 0x14]
inc ecx
add ebx, eax
mov dword [esp + 0x14], ecx
mov edx, ecx
jmp 0x40d50c
mov ebp, dword [esp + 0xf40]
mov ecx, dword [ebp + 8]
mov eax, dword [ebp]
mov dword [esp + 0x28], ecx
mov ecx, dword [ebp + 4]
mov ebx, ecx
mov dword [esp + 0x14], ecx
imul ebx, edi
add ebx, eax
add ebx, esi
mov edx, dword [ebp + 4]
mov eax, dword [ebp + 0xc]
add eax, edx
mov edx, dword [esp + 0xf34]
cmp eax, edx
jl 0x40d598
mov eax, edx
cmp ecx, eax
jae case.0x40d4de.5
mov ecx, dword [ebp + 8]
mov esi, dword [esp + 0x24]
push ecx
push ebx
push esi
call fcn.0040d2f0
mov ecx, dword [esp + 0x34]
mov edi, ebx
mov edx, ecx
mov eax, dword [esp + 0x2c]
shr ecx, 2
rep movsd dword es:[edi], dword [esi]
mov ecx, edx
add esp, 0xc
and ecx, 3
rep movsb byte es:[edi], byte [esi]
mov ecx, dword [esp + 0x14]
inc ecx
add ebx, eax
mov dword [esp + 0x14], ecx
jmp 0x40d583
xor eax, eax
mov cl, al
mov edx, eax
shl cl, 4
shr edx, 4
xor dl, cl
and dl, 0xf
xor dl, cl
mov byte [esp + eax + 0x2c], dl
inc eax
cmp eax, 0x100
jb 0x40d5d9
mov ebx, dword [esp + 0xf34]
test ebx, ebx
jbe case.0x40d4de.5
jmp 0x40d60b
mov edi, dword [esp + 0x20]
mov ecx, dword [esp + 0xf30]
mov edx, dword [esp + 0x24]
lea eax, [esp + 0x2c]
push eax
push ecx
push ebp
push edx
call fcn.0040d310
mov esi, dword [esp + 0x34]
mov ecx, edi
mov eax, ecx
mov edi, ebp
shr ecx, 2
rep movsd dword es:[edi], dword [esi]
mov ecx, eax
add esp, 0x10
and ecx, 3
rep movsb byte es:[edi], byte [esi]
mov ecx, dword [esp + 0x20]
add ebp, ecx
dec ebx
jne 0x40d607
jmp case.0x40d4de.5
mov byte [esp + 0x14], 0
mov byte [esp + 0x15], 0x80
mov byte [esp + 0x16], 0xc0
mov byte [esp + 0x17], 0xe0
mov byte [esp + 0x18], 0xf0
mov byte [esp + 0x19], 0xf8
mov byte [esp + 0x1a], 0xfc
mov byte [esp + 0x1b], 0xfe
xor ebp, ebp
xor edx, edx
mov eax, 1
mov ecx, 0x80
test ebp, eax
je 0x40d686
or edx, ecx
add eax, eax
shr ecx, 1
cmp eax, 0x100
jb 0x40d680
mov byte [esp + ebp + 0x2c], dl
mov esi, 1
mov edi, ebp
lea ecx, [esi - 1]
mov al, 1
shl al, cl
mov edx, 0x80
mov byte [esp + 0x13], 0
sar edx, cl
mov byte [esp + 0x12], 0
mov byte [esp + 0x1f], al
xor eax, eax
test esi, esi
jbe 0x40d6f3
mov ebx, 0x80
mov cl, al
shr ebx, cl
test ebp, ebx
je 0x40d6d5
mov bl, dl
mov ecx, eax
shl bl, cl
or byte [esp + 0x13], bl
mov ebx, 1
mov ecx, eax
shl ebx, cl
test ebp, ebx
je 0x40d6ee
mov bl, byte [esp + 0x1f]
mov cl, al
shr bl, cl
or byte [esp + 0x12], bl
inc eax
cmp eax, esi
jb 0x40d6be
mov cl, byte [esp + 0x13]
mov dl, byte [esp + 0x12]
mov byte [esp + edi + 0x82c], cl
mov byte [esp + edi + 0x12c], dl
inc esi
add edi, 0x100
cmp esi, 8
jb 0x40d69c
inc ebp
cmp ebp, 0x100
jl 0x40d674
mov ebx, dword [esp + 0xf34]
test ebx, ebx
jbe case.0x40d4de.5
mov ebp, dword [esp + 0x28]
mov esi, dword [esp + 0x24]
lea eax, [esp + 0x14]
lea ecx, [esp + 0x12c]
push eax
lea edx, [esp + 0x830]
push ecx
mov ecx, dword [esp + 0xf38]
lea eax, [esp + 0x34]
push edx
push eax
push ecx
push ebp
push esi
call fcn.0040d390
mov ecx, dword [esp + 0x3c]
mov edi, ebp
mov edx, ecx
add esp, 0x1c
shr ecx, 2
rep movsd dword es:[edi], dword [esi]
mov ecx, edx
and ecx, 3
rep movsb byte es:[edi], byte [esi]
mov ecx, edx
add ebp, ecx
dec ebx
mov dword [esp + 0x28], ebp
jne 0x40d72d
mov eax, dword [esp + 0x24]
push eax
call fcn.0040fb3a
add esp, 4
xor eax, eax
pop edi
pop esi
pop ebp
pop ebx
add esp, 0xf1c
ret