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

Disassembly:
sub esp, 0x24
push ebx
mov ebx, dword [esp + 0x38]
movsx eax, byte [ebx]
movsx ecx, byte [ebx + 1]
movsx edx, byte [ebx + 5]
push ebp
push esi
push edi
mov edi, dword [esp + 0x48]
mov dword [esp + 0x20], eax
mov dword [esp + 0x24], ecx
mov dword [esp + 0x2c], edx
mov dword [esp + 0x14], 0
mov dword [esp + 0x10], 0xfffffff7
lea eax, [esp + 0x14]
push edi
push eax
call fcn.00540c30
add esp, 8
test eax, eax
mov dword [esp + 0x28], eax
je 0x5408e9
lea ecx, [esp + 0x18]
push ecx
lea edx, [esp + 0x20]
push edx
push eax
call fcn.0053e9a0
mov eax, dword [esp + 0x24]
mov ecx, dword [esp + 0x28]
push eax
movsx eax, byte [edi + 0xc]
push ecx
movsx ecx, byte [edi + 3]
lea edx, [esp + 0x24]
push edx
push eax
push ecx
call fcn.0053dde0
add esp, 0x20
test eax, eax
mov dword [esp + 0x44], eax
jl 0x5405b6
mov edx, dword [0x669fb8]
movsx ebp, byte [edi + 0x11]
mov esi, eax
mov al, byte [edi + 0x12]
imul esi, esi, 0x8c
mov dword [esp + 0x30], esi
add esi, edx
test al, al
je 0x540646
movsx eax, al
push eax
call fcn.00544a80
add esp, 4
add ebp, eax
jns 0x54063c
xor ebp, ebp
jmp 0x540646
cmp ebp, 0x7f
jle 0x540646
mov ebp, 0x7f
push ebp
call fcn.00544a70
mov edx, dword [esp + 0x50]
mov word [esi + 0x4c], ax
xor eax, eax
mov ax, word [edi + 4]
mov word [esi + 0x84], ax
movsx cx, byte [edi + 0xd]
add esp, 4
sub edx, ecx
mov ecx, dword [esp + 0x54]
imul edx, edx, 0x64
add eax, edx
test ecx, ecx
mov word [esi + 0x84], ax
je 0x540688
add eax, ecx
mov word [esi + 0x84], ax
mov ax, word [edi + 6]
test ax, ax
je 0x5406a4
movsx eax, ax
push eax
call fcn.00544a80
add esp, 4
add word [esi + 0x84], ax
mov ecx, dword [edi + 0x20]
mov eax, dword [esp + 0x20]
mov dword [esi + 0x70], ecx
mov edx, dword [edi + 0x24]
shl eax, 0x10
mov dword [esi + 0x74], edx
mov dword [esi + 0x30], 0
mov dword [esi + 0x38], eax
mov al, byte [edi + 0x15]
test al, al
movsx ebp, byte [edi + 0x14]
je 0x5406da
movsx ecx, al
push ecx
call fcn.00544a80
add esp, 4
add ebp, eax
cmp ebp, 0x7f
jle 0x5406e6
mov ebp, 0x7f
jmp 0x5406ec
test ebp, ebp
jge 0x5406ec
xor ebp, ebp
imul ebp, dword [esp + 0x50]
mov eax, 0x81020409
imul ebp
add edx, ebp
sar edx, 6
mov eax, edx
shr eax, 0x1f
add edx, eax
mov byte [esi + 0x2b], dl
movsx cx, byte [edi + 0x10]
mov dl, byte [esp + 0x24]
mov byte [esi + 0x64], dl
imul ecx, ecx, 0x64
mov word [esi + 0x82], cx
mov eax, dword [edi + 0x28]
mov dword [esi + 0x6c], eax
movsx ecx, byte [edi + 0x1a]
shl ecx, 0x10
mov dword [esi + 0x40], ecx
mov ecx, dword [esi + 0x6c]
mov byte [esi + 0x5d], 0
mov dl, byte [edi + 0xf]
mov byte [esi + 0x5c], dl
mov al, byte [edi + 0xe]
mov byte [esi + 0x5e], al
mov eax, dword [ecx]
test eax, eax
mov dword [esi + 0x44], eax
jge 0x540750
mov dword [esi + 0x44], DirectSoundCreate
mov eax, dword [ecx + 4]
mov ecx, dword [esi + 0x40]
shl eax, 0x10
sub eax, ecx
cdq
idiv dword [esi + 0x44]
mov dword [esi + 0x3c], eax
mov ecx, dword [edi + 0x2c]
mov dword [esi + 0x78], ecx
mov edx, dword [edi + 0x30]
mov dword [esi + 0x7c], edx
mov al, byte [edi + 0x1b]
mov byte [esi + 0x65], al
mov cl, byte [edi + 0x1d]
mov byte [esi + 0x66], cl
mov dx, word [edi + 0x54]
mov word [esi + 0x80], dx
mov al, byte [edi + 0x1c]
test al, al
je 0x54079e
call fcn.005449c0
movsx ecx, byte [edi + 0x1c]
xor edx, edx
div ecx
mov byte [esi + 0x67], dl
jmp 0x5407a2
mov byte [esi + 0x67], 0
mov al, byte [edi + 0x1e]
test al, al
je 0x5407bb
call fcn.005449c0
movzx ecx, byte [edi + 0x1d]
xor edx, edx
div ecx
mov byte [esi + 0x68], dl
jmp 0x5407bf
mov byte [esi + 0x68], 0
mov dx, word [ebx + 0xe]
mov ebp, dword [esp + 0x44]
mov word [esi + 0x6a], dx
mov ax, word [ebx + 0xc]
push ebp
mov word [esi + 0x88], ax
mov word [esi + 0x86], 0
call fcn.0053e420
mov cx, word [esp + 0x3c]
mov dx, word [esp + 0x40]
mov word [esi + 0x12], cx
mov word [esi + 0x10], dx
mov ax, word [ebx + 8]
add ax, word [esi + 0x4c]
add esp, 4
mov word [esi + 0x1c], ax
mov cx, word [ebx + 0xa]
mov word [esi + 0x1e], cx
mov edx, dword [edi + 0x60]
mov dword [esi + 0x18], edx
mov eax, dword [edi + 0x58]
mov dword [esi + 0x14], eax
mov cx, word [edi + 0x56]
mov word [esi + 0x20], cx
mov dl, byte [edi + 0x13]
mov cx, word [esp + 0x28]
mov byte [esi + 0x22], dl
mov al, byte [edi + 3]
mov byte [esi + 0x23], al
mov word [esi + 0x24], cx
mov cl, byte [edi + 3]
xor eax, eax
test cl, cl
jle 0x540869
lea edx, [esi + 0x50]
lea ecx, [edi + 0xbc]
lea esp, [esp]
mov bp, word [ecx]
mov word [edx], bp
movsx ebp, byte [edi + 3]
inc eax
add ecx, 2
add edx, 2
cmp eax, ebp
jl 0x540850
mov ebp, dword [esp + 0x44]
mov dl, byte [ebx + 4]
mov cl, byte [esp + 0x2c]
mov byte [esi + 0x5f], dl
mov al, byte [edi + 0x16]
push ebp
push 0
mov byte [esi + 0x60], al
mov byte [esi + 0x61], cl
call fcn.0053fb60
push ebp
call fcn.0053dca0
movzx edx, word [ebx + 0x16]
movzx eax, word [ebx + 0x14]
movzx ecx, word [ebx + 0x12]
push edx
movzx edx, word [ebx + 0xe]
push eax
mov eax, dword [esp + 0x54]
push ecx
push edx
push ebp
push eax
push edi
call fcn.005448a0
add esp, 0x28
test eax, eax
jge 0x5408e9
mov al, byte [edi + 3]
xor esi, esi
test al, al
jle 0x5405ae
mov ebp, dword [esp + 0x30]
add ebp, 4
mov ecx, dword [0x669fb8]
movsx edx, word [ecx + ebp]
push edx
call fcn.0053e160
movsx eax, byte [edi + 3]
add esp, 4
inc esi
add ebp, 2
cmp esi, eax
jl 0x5408c5
jmp 0x5405ae
mov eax, dword [esp + 0x10]
pop edi
pop esi
pop ebp
pop ebx
add esp, 0x24
ret