Function at 0x512040
Capabilities:
Resolve function by parsing pe exports

Disassembly:
sub esp, 0x20
mov eax, dword [edi]
push ebx
push ebp
mov dword [esp + 8], eax
push esi
mov esi, dword [eax + 4]
movsx eax, byte [edi + 0x44]
movzx ecx, word [edi + eax*2 + 0x50]
mov ebp, dword [edi + eax*4 + 0x78]
mov dword [esp + 0x1c], eax
mov eax, dword [ebp + 0x40]
mov dword [esp + 0x14], ecx
mov cx, word [eax + ecx*2]
mov ah, cl
xor edx, edx
mov dword [esp + 0x18], esi
mov dword [esp + 0x20], edx
mov al, ch
movzx ecx, word [ebp + 0x14]
movzx ebx, ax
and ebx, ecx
add ebx, dword [ebp + 0x38]
cmp byte [ebp + 5], dl
jne 0x5120a4
mov dword [esp + 0x10], edx
lea edx, [esp + 0x10]
push edx
push edi
call fcn.00511dd0
add esp, 8
test eax, eax
jne 0x5122e2
test byte [edi + 0x40], 0x20
je 0x5120c0
mov ecx, dword [edi + 0x34]
push esi
mov edx, edi
call fcn.005114b0
add esp, 4
test eax, eax
jne 0x5122e2
cmp dword [edi + 0x48], 0
jne 0x5120e0
mov eax, dword [edi + 0x14]
mov ecx, dword [edi + 0x10]
push eax
push ecx
mov ecx, dword [esp + 0x14]
xor esi, esi
call fcn.004c3b10
mov esi, dword [esp + 0x20]
add esp, 8
cmp dword [esp + 0x30], 0
je 0x51212d
cmp byte [ebp + 5], 0
je 0x51211e
push ebx
push ebp
call fcn.004c3de0
movzx edx, ax
movzx eax, word [ebp + 0x10]
lea ecx, [edx + eax + 2]
mov edx, dword [esi + 0x24]
add edx, edx
mov eax, 0xaaaaaaab
mul edx
shr edx, 1
add esp, 8
cmp ecx, edx
jg 0x51211e
mov dword [esp + 0x20], 1
jmp 0x51212d
mov esi, edi
call fcn.0050a7d0
test eax, eax
jne 0x5122e2
mov esi, dword [ebp + 0x48]
call fcn.005004f0
test eax, eax
jne 0x5122e2
lea eax, [esp + 0xc]
push eax
mov eax, ebx
mov ecx, ebp
call fcn.00507770
movzx edx, word [esp + 0x10]
lea ecx, [esp + 0x14]
push ecx
mov dword [esp + 0x18], eax
mov eax, dword [esp + 0x1c]
push edx
push eax
mov esi, ebp
call fcn.004ee0e0
mov eax, dword [esp + 0x20]
add esp, 0x10
test eax, eax
jne 0x5122e2
cmp byte [ebp + 5], al
jne 0x51223e
movsx ecx, byte [edi + 0x44]
mov ebx, dword [edi + ecx*4 + 0x78]
mov edx, dword [esp + 0x1c]
mov eax, dword [edi + edx*4 + 0x7c]
mov ecx, dword [eax + 0x54]
movzx edx, word [ebx + 0x12]
mov eax, dword [ebx + 0x40]
mov esi, dword [ebx + 0x38]
mov dword [esp + 0xc], ecx
mov cx, word [eax + edx*2 - 2]
mov dh, cl
mov dl, ch
movzx ecx, word [ebx + 0x14]
movzx eax, dx
and eax, ecx
add eax, esi
add esi, 4
mov dword [esp + 0x28], eax
cmp eax, esi
jae 0x5121ce
pop esi
pop ebp
mov eax, 0xf74e
pop ebx
add esp, 0x20
jmp fcn.004eb240
mov edx, dword [ebx + 0x4c]
push eax
push ebx
call edx
mov ecx, dword [esp + 0x20]
mov edx, dword [ecx + 0x50]
mov esi, dword [ebx + 0x48]
movzx eax, ax
mov dword [esp + 0x2c], eax
mov dword [esp + 0x20], edx
call fcn.005004f0
mov ecx, dword [esp + 0x14]
mov esi, dword [esp + 0x2c]
mov dword [esp + 0x18], eax
lea eax, [esp + 0x18]
push eax
mov eax, dword [esp + 0x34]
push ecx
mov ecx, dword [esp + 0x24]
lea edx, [esi + 4]
push edx
add eax, 0xfffffffc
push eax
mov eax, dword [esp + 0x30]
push ecx
push ebp
call fcn.00501320
movzx eax, word [ebx + 0x12]
lea edx, [esp + 0x30]
push edx
push esi
dec eax
push eax
mov esi, ebx
call fcn.004ee0e0
mov eax, dword [esp + 0x3c]
add esp, 0x2c
test eax, eax
jne 0x5122e2
push edi
call fcn.0050c920
add esp, 4
test eax, eax
jne 0x5122e2
movsx ecx, byte [edi + 0x44]
mov esi, dword [esp + 0x1c]
cmp ecx, esi
jle 0x512294
jmp 0x512260
mov al, byte [edi + 0x44]
movsx edx, al
mov ecx, dword [edi + edx*4 + 0x78]
dec al
mov byte [edi + 0x44], al
test ecx, ecx
je 0x51227f
mov eax, dword [ecx + 0x48]
push eax
call fcn.00505710
add esp, 4
movsx ecx, byte [edi + 0x44]
cmp ecx, esi
jg 0x512260
push edi
call fcn.0050c920
add esp, 4
test eax, eax
jne 0x5122e2
cmp dword [esp + 0x20], 0
je 0x5122d0
mov byte [edi + 0x42], 2
movzx edx, word [ebp + 0x12]
cmp dword [esp + 0x14], edx
jl 0x5122c2
mov dword [edi + 0x3c], 0xffffffff
mov cx, word [ebp + 0x12]
dec cx
mov word [edi + esi*2 + 0x50], cx
pop esi
pop ebp
pop ebx
add esp, 0x20
ret
pop esi
pop ebp
mov dword [edi + 0x3c], 1
pop ebx
add esp, 0x20
ret
mov esi, edi
call fcn.0050ad40
cmp dword [esp + 0x30], 0
je 0x5122e2
mov byte [edi + 0x42], 3
pop esi
pop ebp
pop ebx
add esp, 0x20
ret