Function at 0x10040240
Capabilities:
Encode data using xor

Disassembly:
mov eax, 0x48
call fcn.10162d70
mov eax, dword [0x10211a50]
xor eax, esp
mov dword [esp + 0x44], eax
mov eax, dword [esp + 0x4c]
push esi
mov esi, dword [esp + 0x54]
mov dword [esp + 8], eax
test esi, esi
je 0x1004059f
cmp dword [0x10217854], 0
push ebx
je 0x10040367
lea ecx, [esp + 0x10]
push ecx
call fcn.1001a860
push 0xdf
push str..crypto_randmd_rand.c
push 0x13
push 5
call fcn.1001aca0
lea edx, [esp + 0x24]
push edx
push 0x10217408
call fcn.1001a8a0
mov ebx, eax
push 0xe1
neg ebx
push str..crypto_randmd_rand.c
sbb ebx, ebx
push 0x13
inc ebx
push 6
mov dword [esp + 0x34], ebx
call fcn.1001aca0
add esp, 0x2c
test ebx, ebx
jne 0x100402df
push 0xe6
push str..crypto_randmd_rand.c
push 0x12
push 9
call fcn.1001aca0
add esp, 0x10
mov eax, dword [0x10217840]
mov edx, dword [0x10217844]
mov ecx, dword [0x1021783c]
mov dword [esp + 0x18], eax
mov eax, dword [0x10217824]
mov dword [esp + 0x1c], edx
mov edx, dword [0x10217828]
mov dword [esp + 0x38], eax
mov eax, dword [0x1021782c]
push edi
mov edi, ecx
add ecx, esi
mov dword [esp + 0x40], edx
mov edx, dword [0x10217830]
mov dword [esp + 0x44], eax
mov eax, dword [0x10217834]
mov dword [esp + 0x48], edx
mov dword [esp + 0x4c], eax
mov dword [0x1021783c], ecx
cmp ecx, 0x3ff
jl 0x10040378
mov eax, 0x7fdff7fd
imul ecx
sub edx, ecx
sar edx, 9
mov eax, edx
shr eax, 0x1f
add eax, edx
imul eax, eax, 0x3ff
add ecx, eax
mov dword [0x1021783c], ecx
mov dword [0x10217838], 0x3ff
jmp 0x1004038e
mov dword [esp + 8], 0
mov ebx, dword [esp + 8]
jmp 0x100402c9
mov eax, dword [0x10217838]
cmp eax, 0x3ff
jge 0x1004038e
cmp ecx, eax
jle 0x1004038e
mov dword [0x10217838], ecx
mov eax, 0x66666667
imul esi
sar edx, 3
mov eax, edx
shr eax, 0x1f
add eax, edx
lea ecx, [eax + eax*4]
add ecx, ecx
add ecx, ecx
mov edx, esi
sub edx, ecx
xor ecx, ecx
test edx, edx
setg cl
add ecx, eax
add dword [0x10217844], ecx
test ebx, ebx
jne 0x100403d3
push 0x106
push str..crypto_randmd_rand.c
push 0x12
push 0xa
call fcn.1001aca0
add esp, 0x10
lea edx, [esp + 0x24]
push edx
call fcn.1005eb90
add esp, 4
test esi, esi
jle 0x100404ee
push ebp
mov ebp, esi
dec esi
mov eax, 0xcccccccd
mul esi
shr edx, 4
inc edx
mov dword [esp + 0x18], edx
jmp 0x10040400
mov esi, ebp
cmp ebp, 0x14
jle 0x1004040c
mov esi, 0x14
push 0
call fcn.1005f180
push eax
lea eax, [esp + 0x30]
push eax
call fcn.1005ebe0
push 0x14
lea ecx, [esp + 0x50]
push ecx
lea edx, [esp + 0x3c]
push edx
call fcn.1005ed90
lea ebx, [esi + edi - 0x3ff]
add esp, 0x18
lea ecx, [edi + 0x10217410]
lea edx, [esp + 0x28]
test ebx, ebx
jle 0x10040468
mov eax, esi
sub eax, ebx
push eax
push ecx
push edx
call fcn.1005ed90
push ebx
lea eax, [esp + 0x38]
push 0x10217410
push eax
call fcn.1005ed90
add esp, 0x18
jmp 0x10040473
push esi
push ecx
push edx
call fcn.1005ed90
add esp, 0xc
mov ebx, dword [esp + 0x14]
push esi
lea eax, [esp + 0x2c]
push ebx
push eax
call fcn.1005ed90
push 8
lea ecx, [esp + 0x30]
push ecx
lea edx, [esp + 0x3c]
push edx
call fcn.1005ed90
push 0
lea eax, [esp + 0x5c]
push eax
lea ecx, [esp + 0x48]
push ecx
call fcn.1005eda0
mov ecx, 1
add dword [esp + 0x48], ecx
add ebx, esi
add esp, 0x24
xor eax, eax
mov dword [esp + 0x14], ebx
test esi, esi
jle 0x100404dc
lea ecx, [ecx]
mov dl, byte [esp + eax + 0x40]
xor byte [edi + 0x10217410], dl
add edi, ecx
cmp edi, 0x3ff
jl 0x100404d6
xor edi, edi
add eax, ecx
cmp eax, esi
jl 0x100404c0
sub ebp, 0x14
sub dword [esp + 0x18], ecx
jne 0x10040400
mov ebx, dword [esp + 0x10]
pop ebp
lea eax, [esp + 0x24]
push eax
call fcn.1005ee20
add esp, 4
pop edi
test ebx, ebx
jne 0x10040516
push 0x137
push str..crypto_randmd_rand.c
push 0x12
push 9
call fcn.1001aca0
add esp, 0x10
xor eax, eax
jmp 0x10040520
movzx ecx, byte [esp + eax + 0x38]
xor byte [eax + 0x10217824], cl
movzx edx, byte [esp + eax + 0x39]
movzx ecx, byte [esp + eax + 0x3a]
xor byte [eax + 0x10217825], dl
xor byte [eax + 0x10217826], cl
movzx edx, byte [esp + eax + 0x3b]
movzx ecx, byte [esp + eax + 0x3c]
xor byte [eax + 0x10217827], dl
xor byte [eax + 0x10217828], cl
add eax, 5
cmp eax, 0x14
jl 0x10040520
fld qword [0x101af7a0]
fld qword [0x10217848]
fcom st(1)
fnstsw ax
fstp st(1)
test ah, 5
jp 0x10040582
fadd qword [esp + 0x5c]
fstp qword [0x10217848]
jmp 0x10040584
fstp st(0)
test ebx, ebx
pop ebx
jne 0x1004059f
push 0x144
push str..crypto_randmd_rand.c
push 0x12
push 0xa
call fcn.1001aca0
add esp, 0x10
mov ecx, dword [esp + 0x48]
pop esi
xor ecx, esp
call fcn.1016177d
add esp, 0x48
ret