Function at 0x581370
Capabilities:
Encode data using xor

Disassembly:
push ebp
push edi
push esi
push ebx
sub esp, 0x5c
mov dword [esp + 0x44], eax
mov dword [esp + 0x48], edx
mov dword [esp + 0x34], ecx
cmp dword [eax + 8], edx
jl 0x5815ac
mov eax, 1
mov esi, eax
mov cl, byte [esp + 0x74]
shl esi, cl
cmp dword [esp + 0x74], 3
jg 0x581460
mov edi, dword [esp + 0x48]
test edi, edi
jle 0x5815d5
mov eax, dword [esp + 0x44]
mov eax, dword [eax]
mov dword [esp + 0x4c], eax
lea ecx, [esi*4]
mov dword [esp + 0x18], ecx
mov dword [esp + 0x10], eax
lea eax, [eax + edi*4]
mov dword [esp + 0x14], eax
test esi, esi
jle 0x5815ce
mov edi, dword [esp + 0x34]
xor ebp, ebp
xor ebx, ebx
mov edx, dword [edi]
mov eax, dword [esp + 0x70]
xor eax, ebx
lea ecx, [eax - 1]
not eax
and eax, ecx
sar eax, 0x1f
and eax, edx
or ebp, eax
inc ebx
add edi, 4
cmp ebx, esi
jne 0x5813e0
mov eax, dword [esp + 0x10]
mov dword [eax], ebp
mov ecx, dword [esp + 0x18]
add dword [esp + 0x34], ecx
add eax, 4
mov dword [esp + 0x10], eax
cmp eax, dword [esp + 0x14]
jne 0x5813d0
mov edi, dword [esp + 0x44]
mov edx, dword [esp + 0x48]
mov dword [edi + 4], edx
mov edi, dword [esp + 0x4c]
lea eax, [edi + edx*4 - 4]
lea esi, [esi]
sub eax, 4
mov ecx, dword [eax + 4]
test ecx, ecx
jne 0x58143d
dec edx
jne 0x581430
mov eax, dword [esp + 0x44]
mov dword [eax + 4], edx
mov eax, 1
add esp, 0x5c
pop ebx
pop esi
pop edi
pop ebp
ret
mov edi, dword [esp + 0x74]
lea ecx, [edi - 2]
shl eax, cl
mov edi, eax
mov dword [esp + 0x18], eax
dec eax
and eax, dword [esp + 0x70]
mov dword [esp + 0x1c], eax
mov eax, dword [esp + 0x70]
sar eax, cl
mov ecx, eax
lea edx, [eax - 1]
not eax
and eax, edx
cdq
mov dword [esp + 0x20], edx
mov eax, ecx
xor eax, 1
lea edx, [eax - 1]
not eax
and eax, edx
cdq
mov dword [esp + 0x24], edx
mov eax, ecx
xor eax, 2
lea edx, [eax - 1]
not eax
and eax, edx
cdq
mov dword [esp + 0x28], edx
xor ecx, 3
mov edx, ecx
lea eax, [ecx - 1]
not edx
and eax, edx
cdq
mov dword [esp + 0x2c], edx
mov ecx, dword [esp + 0x48]
test ecx, ecx
jle 0x5815d5
mov eax, dword [esp + 0x44]
mov eax, dword [eax]
mov dword [esp + 0x4c], eax
lea ebx, [esi*4]
mov dword [esp + 0x40], ebx
mov dword [esp + 0x38], eax
lea eax, [eax + ecx*4]
mov dword [esp + 0x3c], eax
lea ebp, [edi*4]
mov dword [esp + 0x30], ebp
mov ebx, dword [esp + 0x18]
test ebx, ebx
jle 0x5815a2
lea esi, [esi]
lea edi, [edi]
mov ebp, dword [esp + 0x34]
mov dword [esp + 0x14], 0
xor edi, edi
nop
mov ecx, dword [ebp]
mov edx, dword [esp + 0x30]
mov eax, edx
add eax, ebp
mov esi, dword [eax]
add eax, edx
mov ebx, dword [eax]
add eax, edx
mov edx, dword [eax]
mov dword [esp + 0x10], edx
mov eax, dword [esp + 0x1c]
xor eax, edi
lea edx, [eax - 1]
not eax
and eax, edx
sar eax, 0x1f
and esi, dword [esp + 0x24]
and ebx, dword [esp + 0x28]
or esi, ebx
and ecx, dword [esp + 0x20]
or esi, ecx
mov edx, dword [esp + 0x10]
and edx, dword [esp + 0x2c]
or esi, edx
and esi, eax
or dword [esp + 0x14], esi
inc edi
add ebp, 4
cmp edi, dword [esp + 0x18]
jne 0x581520
mov eax, dword [esp + 0x38]
mov edi, dword [esp + 0x14]
mov dword [eax], edi
mov ecx, dword [esp + 0x40]
add dword [esp + 0x34], ecx
add eax, 4
mov dword [esp + 0x38], eax
cmp eax, dword [esp + 0x3c]
je 0x581419
mov ebx, dword [esp + 0x18]
test ebx, ebx
jg 0x581510
mov dword [esp + 0x14], 0
jmp 0x581573
mov dword [esp + 4], edx
mov eax, dword [esp + 0x44]
mov dword [esp], eax
call fcn.004d3100
test eax, eax
jne 0x58138c
xor eax, eax
add esp, 0x5c
pop ebx
pop esi
pop edi
pop ebp
ret
xor ebp, ebp
jmp 0x5813fe
mov eax, dword [esp + 0x44]
mov edi, dword [esp + 0x48]
mov dword [eax + 4], edi
mov eax, 1
jmp 0x581449