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

Disassembly:
sub esp, 0x38
push edi
xor edi, edi
cmp dword [esi + 0x9c], edi
mov dword [esp + 8], 0xffffffff
jne 0x51300d
xor eax, eax
pop edi
add esp, 0x38
ret
push 0x8f2240
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
cmp dword [esi + 0x44], edi
je 0x51304c
cmp dword [0x91a300], edi
je 0x513037
movzx ecx, word [esi + 0x78]
imul ecx, dword [esi + 0x54]
mov dword [esp + 4], ecx
mov dword [esp + 0x10], ecx
jmp 0x513050
mov eax, dword [esi + 0x48]
mov ecx, dword [eax]
lea edx, [esp + 0x10]
push edx
lea edx, [esp + 8]
push edx
push eax
mov eax, dword [ecx + 0x10]
call eax
mov ecx, dword [esp + 4]
mov edx, dword [esi + 0x88]
cmp edx, 0xffffffff
je 0x513093
cmp dword [esi + 0x90], edi
jne 0x513093
mov eax, dword [esi + 0x8c]
cmp ecx, eax
jbe 0x513077
cmp eax, edx
ja 0x513075
cmp ecx, edx
jae 0x513081
cmp ecx, eax
jae 0x51308d
cmp eax, edx
jbe 0x513081
cmp ecx, edx
jb 0x51308d
mov dword [esi + 0x90], 1
jmp 0x513093
mov dword [esi + 0x8c], ecx
mov edx, dword [esi + 0x84]
push ebx
mov ebx, dword [esi + 0x98]
mov eax, edx
sub eax, ebx
jns 0x5130ac
add eax, dword [esi + 0x80]
cmp eax, edx
jbe 0x5130ba
cmp eax, ecx
jbe 0x5130b8
cmp edx, ecx
jb 0x5130c4
cmp eax, edx
jae 0x5130db
cmp eax, ecx
ja 0x5130c4
cmp edx, ecx
jae 0x5130db
push 0x8f2240
mov dword [esp + 0x10], edi
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
pop ebx
mov eax, edi
pop edi
add esp, 0x38
ret
cmp eax, edx
jbe 0x5130ef
cmp eax, ecx
jb 0x5130ef
mov edx, dword [esi + 0x80]
sub edx, eax
add edx, ecx
jmp 0x5130f3
sub ecx, eax
mov edx, ecx
movzx ecx, word [esi + 0x14]
lea eax, [ebx + edx]
cdq
idiv ecx
push ebp
mov ebp, eax
cmp ebp, edi
jge 0x51310d
mov dword [esp + 0x10], edi
jmp 0x51336b
mov eax, dword [esi + 0x2c]
cmp ebp, eax
mov dword [esp + 0x14], edi
jle 0x513124
sub ebp, eax
mov dword [esp + 0x14], ebp
mov edi, dword [esp + 0x14]
mov ebp, eax
lea ebx, [edi + ebp]
imul ebx, ecx
lea ecx, [esp + 0x30]
push ecx
lea edx, [esp + 0x2c]
push edx
lea eax, [esp + 0x34]
push eax
mov eax, dword [esi + 0x84]
lea ecx, [esp + 0x30]
push ecx
lea ecx, [esi + 0x44]
mov dword [esp + 0x2c], ebx
call fcn.005129e0
add esp, 0x10
test eax, eax
jne 0x51336b
xor edx, edx
cmp edi, edx
je 0x5131a1
cmp dword [esi + 0x88], 0xffffffff
jne 0x5131a1
movzx eax, word [esi + 0x14]
mov ecx, dword [esi + 0x84]
imul eax, ebp
add eax, ecx
mov ecx, dword [esi + 0x80]
cmp eax, ecx
mov dword [esi + 0x88], eax
jle 0x513191
sub eax, ecx
mov dword [esi + 0x88], eax
mov eax, dword [esp + 0xc]
mov dword [esi + 0x8c], eax
mov dword [esi + 0x90], edx
cmp dword [esi + 0x90], edx
je 0x5131c3
cmp ebp, edx
je 0x5131c3
mov dword [esi + 0x90], edx
mov dword [esi + 0x8c], edx
mov dword [esi + 0x88], 0xffffffff
mov ecx, dword [esi + 0x84]
mov eax, dword [esp + 0x2c]
sub dword [esi + 0x2c], ebp
cmp eax, edx
mov dword [esp + 0x20], ecx
mov ecx, dword [esp + 0x30]
mov dword [esp + 0x34], edx
mov dword [esp + 0x38], edx
mov dword [esp + 0x3c], eax
mov dword [esp + 0x40], ecx
je 0x51322b
cmp ebp, edx
je 0x51322b
movzx edi, word [esi + 0x14]
imul edi, ebp
cmp edi, eax
jbe 0x5131fd
mov edi, eax
mov edx, dword [esp + 0x24]
push 0
push edi
push edx
lea eax, [esi + 0x30]
push eax
call fcn.004dd150
movzx ecx, word [esi + 0x14]
mov eax, edi
xor edx, edx
div ecx
add dword [esp + 0x44], edi
sub dword [esp + 0x4c], edi
mov edi, dword [esp + 0x24]
add esp, 0x10
sub ebp, eax
xor edx, edx
mov eax, dword [esp + 0x40]
cmp eax, edx
je 0x51326d
cmp ebp, edx
je 0x51326d
movzx ebx, word [esi + 0x14]
imul ebx, ebp
cmp ebx, eax
jbe 0x513244
mov ebx, eax
mov eax, dword [esp + 0x38]
push edx
mov edx, dword [esp + 0x2c]
push ebx
add edx, eax
push edx
lea ecx, [esi + 0x30]
push ecx
call fcn.004dd150
mov eax, dword [esp + 0x50]
add dword [esp + 0x48], ebx
sub eax, ebx
add esp, 0x10
mov dword [esp + 0x40], eax
xor edx, edx
mov ecx, dword [esp + 0x3c]
cmp ecx, edx
je 0x5132d3
cmp edi, edx
je 0x5132d3
movzx ebp, word [esi + 0x14]
imul ebp, edi
cmp ebp, ecx
jbe 0x513286
mov ebp, ecx
movzx eax, word [esi + 0x16]
cmp eax, 8
je 0x5132a3
cmp eax, 0x10
jne 0x5132b9
mov eax, dword [esp + 0x34]
push ebp
push edx
mov edx, dword [esp + 0x2c]
add edx, eax
push edx
jmp 0x5132b1
mov ecx, dword [esp + 0x24]
mov edx, dword [esp + 0x34]
push ebp
push 0x7f
add ecx, edx
push ecx
call fcn.004dc0b0
add esp, 0xc
movzx ecx, word [esi + 0x14]
xor edx, edx
mov eax, ebp
div ecx
add dword [esp + 0x34], ebp
sub dword [esp + 0x3c], ebp
sub edi, eax
mov eax, dword [esp + 0x40]
xor edx, edx
cmp eax, edx
je 0x513323
cmp edi, edx
je 0x513323
movzx ebx, word [esi + 0x14]
imul ebx, edi
cmp ebx, eax
jbe 0x5132e8
mov ebx, eax
movzx eax, word [esi + 0x16]
cmp eax, 8
je 0x513305
cmp eax, 0x10
jne 0x51331b
mov eax, dword [esp + 0x38]
push ebx
push edx
mov edx, dword [esp + 0x30]
add edx, eax
push edx
jmp 0x513313
mov ecx, dword [esp + 0x28]
mov edx, dword [esp + 0x38]
push ebx
push 0x7f
add ecx, edx
push ecx
call fcn.004dc0b0
add esp, 0xc
add dword [esp + 0x38], ebx
sub dword [esp + 0x40], ebx
mov eax, dword [esp + 0x28]
mov ecx, dword [esp + 0x2c]
mov edx, dword [esp + 0x24]
push eax
push ecx
push edx
mov edx, dword [esp + 0x3c]
lea eax, [esi + 0x44]
call fcn.00512aa0
mov eax, dword [esp + 0x28]
add dword [esi + 0x84], eax
mov eax, dword [esi + 0x84]
mov ecx, dword [esi + 0x80]
add esp, 0xc
cmp eax, ecx
jl 0x513363
sub eax, ecx
mov dword [esi + 0x84], eax
mov dword [esp + 0x10], 0
pop ebp
push 0x8f2240
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov eax, dword [esp + 0xc]
pop ebx
pop edi
add esp, 0x38
ret