Function at 0x405040
Capabilities:
Encode data using xor

Disassembly:
push ebp
push edi
mov ebp, eax
push esi
push ebx
sub esp, 0x5c
fld xword [esp + 0x70]
fld st(0)
fstp xword [esp + 0x28]
fxam
wait
fnstsw ax
and ax, 0x4500
cmp ax, 0x100
je 0x405561
movzx edx, word [esp + 0x30]
test dx, dx
js 0x4054a0
fxam
wait
fnstsw ax
fstp st(0)
and ax, 0x4500
cmp ax, 0x500
je 0x405576
and dx, 0x7fff
mov word [esp + 8], dx
jne 0x405220
mov eax, dword [esp + 0x28]
mov edx, dword [esp + 0x2c]
mov edi, edx
mov dword [esp + 4], edx
or edx, eax
mov esi, eax
mov dword [esp], eax
je 0x4054c3
test edi, edi
js 0x4055ba
mov eax, 0xffffc001
shld edi, esi, 1
mov edx, eax
add esi, esi
sub eax, 1
test edi, edi
jns 0x4050c1
mov ebx, dword [ebp + 0xc]
mov word [esp + 8], dx
mov dword [esp], esi
mov dword [esp + 4], edi
cmp ebx, 0xe
jbe 0x40524a
mov eax, dword [ebp + 4]
lea ebx, [esp + 0x3e]
mov dword [esp + 0xc], ebp
mov esi, dword [esp]
mov dword [esp + 0x10], ebx
mov ebp, ebx
movzx ebx, word [esp + 8]
mov edi, eax
mov dword [esp + 0x14], eax
and eax, 0x20
and edi, 0x800
mov byte [esp + 0x1b], al
mov dword [esp + 0x1c], edi
mov edi, dword [esp + 4]
jmp 0x40516f
mov eax, dword [esp + 0xc]
mov eax, dword [eax + 0xc]
test eax, eax
jle 0x405135
mov edx, dword [esp + 0xc]
sub eax, 1
mov dword [edx + 0xc], eax
shrd esi, edi, 4
shr edi, 4
test ecx, ecx
mov dword [esp + 8], ebp
je 0x4051f2
mov eax, dword [esp + 8]
cmp ecx, 9
lea ebp, [eax + 1]
jle 0x405212
add ecx, 0x37
or cl, byte [esp + 0x1b]
mov eax, dword [esp + 8]
mov byte [eax], cl
mov edx, edi
or edx, esi
je 0x4052d0
mov ecx, esi
and ecx, 0xf
mov eax, ecx
mov dword [esp], ecx
cdq
mov eax, ecx
mov dword [esp + 4], edx
mov edx, dword [esp + 4]
xor eax, esi
xor edx, edi
or edx, eax
jne 0x405120
cmp ebp, dword [esp + 0x10]
ja 0x4051b0
mov eax, dword [esp + 0x1c]
test eax, eax
jne 0x4051b0
mov eax, dword [esp + 0xc]
mov dword [esp + 8], ebp
mov eax, dword [eax + 0xc]
test eax, eax
jle 0x4051bb
lea esi, [esi]
lea eax, [ebp + 1]
mov byte [ebp], 0x2e
mov dword [esp + 8], eax
mov ebp, esi
mov esi, edi
xor ebp, 1
or esi, ebp
je 0x4051e6
mov eax, dword [esp]
mov edx, dword [esp + 4]
lea esi, [ebx - 1]
shrd eax, edx, 1
shr edx, 1
mov ebx, esi
mov edi, eax
mov ebp, edx
lea esi, [ebx - 1]
xor edi, 1
or ebp, edi
jne 0x4051d0
xor esi, esi
xor edi, edi
test ecx, ecx
jne 0x405148
mov edx, dword [esp + 0x10]
cmp dword [esp + 8], edx
ja 0x40520b
mov eax, dword [esp + 0xc]
mov ebp, dword [eax + 0xc]
test ebp, ebp
js 0x405540
mov eax, dword [esp + 8]
lea ebp, [eax + 1]
add ecx, 0x30
jmp 0x40515f
mov eax, dword [esp + 0x28]
mov edx, dword [esp + 0x2c]
sub word [esp + 8], 0x3fff
mov dword [esp + 4], edx
or edx, eax
mov dword [esp], eax
je 0x4054c3
mov ebx, dword [ebp + 0xc]
cmp ebx, 0xe
ja 0x4050e8
mov edi, dword [esp + 4]
mov esi, dword [esp]
test edi, edi
js 0x405266
shld edi, esi, 1
add esi, esi
test edi, edi
jns 0x405255
mov dword [esp], esi
mov dword [esp + 4], edi
mov ecx, 0xe
mov eax, 4
xor edx, edx
sub ecx, ebx
shl ecx, 2
shld edx, eax, cl
shl eax, cl
test cl, 0x20
je 0x405285
mov edx, eax
xor eax, eax
mov edi, dword [esp + 4]
mov esi, dword [esp]
shrd esi, edi, 1
shr edi, 1
add eax, esi
adc edx, edi
test edx, edx
js 0x40558e
shld edx, eax, 1
add eax, eax
mov ecx, 0xf
sub ecx, ebx
shl ecx, 2
shrd eax, edx, cl
shr edx, cl
test cl, 0x20
je 0x4052bc
mov eax, edx
xor edx, edx
mov dword [esp], eax
mov dword [esp + 4], edx
jmp 0x4050e8
mov word [esp + 8], bx
mov ebx, ebp
cmp ebx, dword [esp + 0x10]
mov ebp, dword [esp + 0xc]
je 0x4054d2
mov eax, dword [ebp + 8]
test eax, eax
mov dword [esp], eax
jle 0x4054b0
movsx edi, word [esp + 8]
mov edx, dword [ebp + 0xc]
mov eax, ebx
sub eax, dword [esp + 0x10]
test edx, edx
mov dword [esp + 8], edi
jle 0x40530b
add eax, edx
xor edx, edx
test dword [esp + 0x14], 0x1c0
mov ecx, 0x66666667
setne dl
lea edi, [eax + edx + 5]
mov eax, dword [esp + 8]
imul ecx
mov eax, dword [esp + 8]
mov ecx, edx
sar eax, 0x1f
sar ecx, 2
sub ecx, eax
je 0x405599
mov esi, 2
mov eax, 0x66666667
add edi, 1
add esi, 1
imul ecx
sar ecx, 0x1f
sar edx, 2
sub edx, ecx
mov ecx, edx
jne 0x405340
movsx esi, si
mov eax, dword [esp]
cmp eax, edi
jle 0x4053c0
sub eax, edi
test dword [esp + 0x14], 0x600
jne 0x4054f1
sub eax, 1
mov dword [ebp + 8], eax
lea esi, [esi]
mov edx, ebp
mov eax, 0x20
call fcn.00404060
mov eax, dword [ebp + 8]
lea edx, [eax - 1]
test eax, eax
mov dword [ebp + 8], edx
jg 0x405380
mov eax, dword [ebp + 4]
mov dword [esp + 0x14], eax
test byte [esp + 0x14], 0x80
je 0x4053ce
mov esi, esi
lea edi, [edi]
mov edx, ebp
mov eax, 0x2d
call fcn.00404060
jmp 0x4053e7
mov dword [ebp + 8], 0xffffffff
test byte [esp + 0x14], 0x80
jne 0x4053b0
test dword [esp + 0x14], 0x100
jne 0x405500
test byte [esp + 0x14], 0x40
jne 0x405550
mov edx, ebp
mov eax, 0x30
call fcn.00404060
mov eax, dword [ebp + 4]
mov edx, ebp
and eax, 0x20
or eax, 0x58
call fcn.00404060
mov edx, dword [ebp + 8]
test edx, edx
jle 0x40541d
mov eax, dword [ebp + 4]
and eax, 0x600
cmp eax, 0x200
je 0x405511
cmp ebx, dword [esp + 0x10]
mov edi, dword [esp + 0x10]
jbe 0x40545c
mov esi, esi
lea edi, [edi]
sub ebx, 1
movsx eax, byte [ebx]
mov edx, ebp
call fcn.004045b0
cmp ebx, edi
jne 0x405430
mov eax, dword [ebp + 0xc]
lea edx, [eax - 1]
test eax, eax
mov dword [ebp + 0xc], edx
jle 0x405469
nop
mov edx, ebp
mov eax, 0x30
call fcn.00404060
mov eax, dword [ebp + 0xc]
lea edx, [eax - 1]
test eax, eax
mov dword [ebp + 0xc], edx
jg 0x405450
mov eax, dword [ebp + 4]
mov edx, ebp
and eax, 0x20
or eax, 0x50
call fcn.00404060
mov eax, dword [esp + 8]
add dword [ebp + 8], esi
mov ecx, ebp
or dword [ebp + 4], 0x1c0
cdq
call fcn.004045f0
add esp, 0x5c
pop ebx
pop esi
pop edi
pop ebp
ret
or dword [ebp + 4], 0x80
jmp 0x405074
movsx eax, word [esp + 8]
mov esi, 2
mov dword [esp + 8], eax
jmp 0x4053c7
mov eax, dword [ebp + 4]
mov dword [esp + 0x14], eax
lea eax, [esp + 0x3e]
mov dword [esp + 0x10], eax
mov edx, dword [ebp + 0xc]
test edx, edx
jle 0x4055a3
lea eax, [esp + 0x3f]
mov byte [esp + 0x3e], 0x2e
lea ebx, [eax + 1]
mov byte [eax], 0x30
jmp 0x4052e5
mov dword [ebp + 8], eax
jmp 0x4053c7
mov edx, ebp
mov eax, 0x2b
call fcn.00404060
jmp 0x4053e7
sub edx, 1
mov dword [ebp + 8], edx
mov esi, esi
lea edi, [edi]
mov edx, ebp
mov eax, 0x30
call fcn.00404060
mov eax, dword [ebp + 8]
lea edx, [eax - 1]
test eax, eax
mov dword [ebp + 8], edx
jg 0x405520
jmp 0x40541d
mov ebp, dword [esp + 8]
jmp 0x405165
mov edx, ebp
mov eax, 0x20
call fcn.00404060
jmp 0x4053e7
fstp st(0)
mov ecx, ebp
mov edx, 0x40c605
xor eax, eax
call fcn.004042c0
jmp 0x40548f
mov eax, edx
mov ecx, ebp
mov edx, 0x40c609
and eax, 0x8000
call fcn.004042c0
jmp 0x40548f
add word [esp + 8], 1
jmp 0x4052a4
mov esi, 2
jmp 0x40535c
test dword [esp + 0x14], 0x800
mov eax, dword [esp + 0x10]
je 0x4054e6
jmp 0x4054dd
mov ebx, dword [ebp + 0xc]
mov eax, 0xffffc002
mov word [esp + 8], ax
cmp ebx, 0xe
jbe 0x405266
jmp 0x4050e8