Function at 0x509a30
Capabilities:
Create thread
Resume thread

Disassembly:
mov eax, dword [esp + 8]
sub esp, 8
cmp eax, 0x24
push ebx
push ebp
push esi
push edi
jl 0x509b4d
mov edi, str.RIFF
or ecx, 0xffffffff
xor eax, eax
mov esi, dword [esp + 0x1c]
repne scasb al, byte es:[edi]
not ecx
dec ecx
push ecx
push str.RIFF
push esi
call fcn.00561040
add esp, 0xc
test eax, eax
jne 0x509b4d
mov eax, dword [esi + 4]
mov edi, 0xbdb1f4
mov dword [esp + 0x14], eax
or ecx, 0xffffffff
xor eax, eax
add esi, 8
repne scasb al, byte es:[edi]
not ecx
dec ecx
push ecx
push 0xbdb1f4
push esi
call fcn.00561040
add esp, 0xc
test eax, eax
jne 0x509b4d
mov ecx, dword [esp + 0x1c]
xor ebx, ebx
xor esi, esi
xor ebp, ebp
lea edi, [ecx + 0xc]
mov dword [esp + 0x10], edi
mov edx, dword [edi + 4]
push 4
push str.fmt
push edi
mov dword [esp + 0x28], edx
call fcn.00561040
add esp, 0xc
test eax, eax
jne 0x509ad3
test esi, esi
lea ebx, [edi + 8]
jne 0x509b0a
jmp 0x509af2
push 4
push 0xbdb1e4
push edi
call fcn.00561040
add esp, 0xc
test eax, eax
jne 0x509af2
mov ebp, dword [esp + 0x1c]
lea esi, [edi + 8]
test ebx, ebx
jne 0x509b0e
mov eax, dword [esp + 0x1c]
mov edx, dword [esp + 0x10]
lea edi, [edi + eax + 8]
mov eax, dword [esp + 0x14]
mov ecx, edi
sub ecx, edx
cmp ecx, eax
jb 0x509aaf
test ebx, ebx
je 0x509b4d
test esi, esi
je 0x509b4d
test ebp, ebp
jbe 0x509b4d
push 0x4c
call fcn.005724a5
mov dword [esp + 0x24], eax
mov dword [eax + 8], ebp
mov edx, dword [esp + 0x24]
mov eax, dword [edx + 8]
push eax
call fcn.00562407
mov ecx, dword [esp + 0x28]
add esp, 8
mov dword [ecx], eax
mov eax, dword [esp + 0x20]
mov edi, dword [eax]
test edi, edi
jne 0x509b57
push eax
call fcn.005724ce
add esp, 4
pop edi
pop esi
pop ebp
xor eax, eax
pop ebx
add esp, 8
ret
mov ecx, ebp
push 0x14
mov edx, ecx
push 0x3c00
shr ecx, 2
rep movsd dword es:[edi], dword [esi]
mov ecx, edx
and ecx, 3
rep movsb byte es:[edi], byte [esi]
mov eax, dword [esp + 0x28]
mov ecx, dword [esp + 0x2c]
mov dword [eax + 0x48], ecx
mov edx, dword [esp + 0x28]
mov dword [edx + 0x1c], 0
call fcn.00509820
mov ecx, dword [esp + 0x28]
add esp, 8
push 0
push 0
push 1
push 0
mov dword [ecx + 0xc], eax
call dword [sym.imp.KERNEL32.dll_CreateEventA]
mov edx, dword [esp + 0x20]
push 0
push 0x14
push 0x14
push 0
mov dword [edx + 0x2c], eax
call dword [sym.imp.KERNEL32.dll_CreateSemaphoreA]
mov ecx, dword [esp + 0x20]
mov dword [ecx + 0x28], eax
mov edx, dword [esp + 0x20]
mov dword [edx + 0x14], 0
mov eax, dword [esp + 0x20]
mov dword [eax + 0x10], 0x14
mov ecx, dword [esp + 0x20]
add ecx, 0x30
push ecx
call dword [sym.imp.KERNEL32.dll_InitializeCriticalSection]
mov eax, dword [esp + 0x20]
push 0x50a060
push eax
add eax, 4
push ebx
push eax
call fcn.00509890
mov eax, dword [esp + 0x30]
add esp, 0x10
mov edi, 4
lea edx, [eax + 0x24]
push edx
push edi
push eax
push 0x509e10
push 0
push 0
call dword [sym.imp.KERNEL32.dll_CreateThread]
mov ecx, dword [esp + 0x20]
push 0xbf9710
mov dword [ecx + 0x20], eax
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [0xbf9730]
mov edx, dword [0xbf9734]
sub edx, eax
mov esi, eax
sar edx, 2
cmp edx, 1
jae 0x509d33
mov edx, dword [0xbf972c]
test edx, edx
je 0x509c62
mov ecx, eax
sub ecx, edx
sar ecx, 2
cmp ecx, 1
jbe 0x509c62
mov ecx, eax
sub ecx, edx
sar ecx, 2
jmp 0x509c67
mov ecx, 1
test edx, edx
jne 0x509c6f
xor eax, eax
jmp 0x509c74
sub eax, edx
sar eax, 2
add eax, ecx
test eax, eax
mov dword [esp + 0x1c], eax
jge 0x509c80
xor eax, eax
lea edx, [eax*4]
push edx
call fcn.005724a5
mov edi, dword [0xbf972c]
add esp, 4
mov ebp, eax
cmp edi, esi
mov ebx, ebp
je 0x509cb2
push edi
push ebx
call fcn.0050a120
add edi, 4
add esp, 8
add ebx, 4
cmp edi, esi
jne 0x509c9e
lea eax, [esp + 0x20]
push eax
push ebx
call fcn.0050a120
mov edi, dword [0xbf9730]
add esp, 8
add ebx, 4
cmp esi, edi
je 0x509ce1
push esi
push ebx
call fcn.0050a120
add esi, 4
add esp, 8
add ebx, 4
cmp esi, edi
jne 0x509ccd
mov ecx, dword [0xbf9730]
mov edx, dword [0xbf972c]
push ecx
push edx
mov ecx, 0xbf9728
call fcn.00549090
mov eax, dword [0xbf972c]
push eax
call fcn.005724ce
mov ecx, dword [esp + 0x20]
add esp, 4
lea edx, [ebp + ecx*4]
mov ecx, 0xbf9728
mov dword [0xbf9734], edx
call fcn.0050a0a0
lea eax, [ebp + eax*4 + 4]
mov dword [0xbf972c], ebp
mov dword [0xbf9730], eax
jmp 0x509dd0
mov ecx, eax
sub ecx, esi
sar ecx, 2
cmp ecx, 1
jae 0x509d8d
lea edx, [esi + 4]
mov ecx, 0xbf9728
push edx
push eax
push esi
call fcn.0050a0c0
lea eax, [esp + 0x20]
mov edx, 1
push eax
mov eax, dword [0xbf9730]
mov ecx, eax
sub ecx, esi
sar ecx, 2
sub edx, ecx
mov ecx, 0xbf9728
push edx
push eax
call fcn.0050a0f0
mov ecx, dword [0xbf9730]
mov eax, esi
cmp esi, ecx
je 0x509dca
mov edx, dword [esp + 0x20]
mov dword [eax], edx
add eax, edi
cmp eax, ecx
jne 0x509d7f
jmp 0x509dca
push eax
push eax
add eax, 0xfffffffc
mov ecx, 0xbf9728
push eax
call fcn.0050a0c0
mov eax, dword [0xbf9730]
mov ecx, eax
add eax, 0xfffffffc
cmp esi, eax
je 0x509db7
sub eax, edi
sub ecx, edi
cmp eax, esi
mov edx, dword [eax]
mov dword [ecx], edx
jne 0x509dab
lea eax, [esi + 4]
cmp esi, eax
je 0x509dca
mov ecx, dword [esp + 0x20]
mov dword [esi], ecx
add esi, edi
cmp esi, eax
jne 0x509dbe
add dword [0xbf9730], edi
push 0xbf9710
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov edx, dword [esp + 0x20]
mov eax, dword [edx + 0x20]
push eax
call dword [sym.imp.KERNEL32.dll_ResumeThread]
mov ecx, dword [esp + 0x20]
push 0
push 0x14
mov edx, dword [ecx + 0x28]
push edx
call dword [sym.imp.KERNEL32.dll_ReleaseSemaphore]
pop edi
pop esi
pop ebp
mov eax, 1
pop ebx
add esp, 8
ret