Function at 0x40d980
Capabilities:
Encode data using xor

Disassembly:
mov eax, 0x2014
call fcn.00402c90
mov eax, dword [esp + 0x2018]
push ebx
push ebp
push esi
mov ecx, dword [eax]
push edi
cmp ecx, 1
jne 0x40d9b3
mov ecx, dword [eax + 4]
test ecx, ecx
jne 0x40d9c7
pop edi
pop esi
pop ebp
mov eax, 0x80000002
pop ebx
add esp, 0x2014
ret
cmp ecx, 2
jne 0x40dc82
mov ecx, dword [eax + 8]
test ecx, ecx
je 0x40dc82
push eax
call fcn.0040cf40
mov ecx, 0x400
xor eax, eax
lea edi, [esp + 0x1028]
push 1
rep stosd dword es:[edi], eax
mov ecx, 0x400
lea edi, [esp + 0x2c]
rep stosd dword es:[edi], eax
lea eax, [esp + 0x1c]
push eax
call fcn.0040f4b0
mov ebp, dword [esp + 0x2038]
mov cl, byte [esp + 0x20]
xor edx, edx
push 0x10
mov dx, word [ebp + 0x810]
mov byte [esp + 0x1034], cl
push edx
mov byte [esp + 0x1039], 0xff
call fcn.0040d010
mov cx, word [ebp + 0x810]
mov ebx, eax
xor eax, eax
mov dl, cl
mov al, ch
and ecx, 0xffff
mov byte [esp + 0x103a], al
mov eax, ecx
mov esi, ebp
lea edi, [esp + 0x103c]
shr ecx, 2
mov byte [esp + 0x103b], dl
add esp, 0x14
rep movsd dword es:[edi], dword [esi]
mov ecx, eax
xor al, al
and ecx, 3
xor edx, edx
rep movsb byte es:[edi], byte [esi]
lea ecx, [ebx + 4]
test ecx, ecx
jle 0x40da73
xor al, byte [esp + edx + 0x1024]
inc edx
cmp edx, ecx
jl 0x40da67
xor esi, esi
mov byte [esp + ebx + 0x1028], al
test ecx, ecx
jle 0x40da9c
mov dl, byte [esp + 0x1024]
mov al, byte [esp + esi + 0x1025]
xor al, dl
mov byte [esp + esi + 0x1025], al
inc esi
cmp esi, ecx
jl 0x40da80
mov edi, dword [esp + 0x2028]
lea ecx, [ebx + 5]
mov dword [esp + 0x10], 0x1000
mov eax, dword [edi]
cmp eax, 1
jne 0x40dad0
lea eax, [esp + 0x10]
lea edx, [esp + 0x24]
push eax
push edx
lea eax, [esp + 0x102c]
push ecx
push eax
push edi
call fcn.0040dca0
jmp 0x40daf2
cmp eax, 2
jne 0x40dc79
lea edx, [esp + 0x10]
lea eax, [esp + 0x24]
push edx
push eax
push ecx
lea ecx, [esp + 0x1030]
push ecx
push edi
call fcn.0040df60
add esp, 0x14
test eax, eax
jne 0x40db12
push edi
call fcn.0040cf60
add esp, 4
mov eax, 0x80000012
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x2014
ret
mov esi, dword [esp + 0x10]
xor eax, eax
lea ecx, [esi - 1]
test ecx, ecx
jle 0x40db32
mov dl, byte [esp + 0x24]
mov bl, byte [esp + eax + 0x25]
xor bl, dl
mov byte [esp + eax + 0x25], bl
inc eax
cmp eax, ecx
jl 0x40db1f
cmp byte [esp + 0x25], 0xff
je 0x40db52
push edi
call fcn.0040cf60
add esp, 4
mov eax, 0x80000012
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x2014
ret
lea edx, [esi - 5]
mov eax, edx
and eax, 0x8000000f
jns 0x40db63
dec eax
or eax, 0xfffffff0
inc eax
je 0x40db7e
push edi
call fcn.0040cf60
add esp, 4
mov eax, 0x80000012
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x2014
ret
add edx, 4
xor cl, cl
xor eax, eax
test edx, edx
jle 0x40db94
mov bl, byte [esp + eax + 0x24]
xor cl, bl
inc eax
cmp eax, edx
jl 0x40db89
cmp cl, byte [esp + esi + 0x23]
je 0x40dbb3
push edi
call fcn.0040cf60
add esp, 4
mov eax, 0x80000012
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x2014
ret
mov edx, dword [esp + 0x27]
xor ecx, ecx
mov ch, byte [esp + 0x26]
and edx, 0xff
and ecx, 0xffff
add ecx, edx
mov esi, ecx
cmp esi, 2
jge 0x40dbeb
push edi
call fcn.0040cf60
add esp, 4
mov eax, 0x80000012
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x2014
ret
movzx ax, byte [esp + esi + 0x26]
movzx cx, byte [esp + esi + 0x27]
shl eax, 8
add eax, ecx
mov edx, eax
and edx, 0xff00
cmp edx, 0x6800
jne 0x40dc1a
mov byte [ebp + 0x10], al
mov word [ebp + 0x812], 1
mov eax, edx
push eax
call fcn.0040d030
mov ebx, eax
add esp, 4
test ebx, ebx
jne 0x40dc63
lea edx, [ebp + 0x10]
add esi, 0xfffffffe
mov ecx, 0x200
mov edi, edx
mov word [ebp + 0x812], si
lea esi, [esp + 0x28]
rep stosd dword es:[edi], eax
xor ecx, ecx
mov edi, edx
mov cx, word [ebp + 0x812]
mov eax, ecx
shr ecx, 2
rep movsd dword es:[edi], dword [esi]
mov ecx, eax
and ecx, 3
rep movsb byte es:[edi], byte [esi]
mov edi, dword [esp + 0x2028]
push edi
call fcn.0040cf60
add esp, 4
mov eax, ebx
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x2014
ret
push edi
call fcn.0040cf60
add esp, 4
pop edi
pop esi
pop ebp
mov eax, 0x80000002
pop ebx
add esp, 0x2014
ret