Function at 0x406640
Capabilities:
Check for time delay via gettickcount

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x20
push ebx
push esi
push edi
call dword [sym.imp.KERNEL32.dll_GetTickCount]
push 0x420768
mov dword [ebp - 0x10], eax
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
cmp dword [0x4207bc], 0
jne 0x40677a
mov edx, dword [0x420780]
mov ecx, dword [edx + 4]
mov eax, dword [ecx + 4]
cmp byte [eax + 0x19], 0
jne 0x406697
lea esp, [esp]
mov esi, dword [eax + 0xc]
cmp esi, dword [ebp + 8]
jae 0x40668d
mov eax, dword [eax + 8]
jmp 0x406691
mov ecx, eax
mov eax, dword [eax]
cmp byte [eax + 0x19], 0
je 0x406680
mov edx, dword [edx + 4]
mov dword [ebp - 4], ecx
cmp ecx, edx
je 0x4066ae
mov eax, dword [ebp + 8]
cmp eax, dword [ecx + 0xc]
jb 0x4066ae
lea eax, [ebp - 4]
jmp 0x4066b4
mov dword [ebp - 0xc], edx
lea eax, [ebp - 0xc]
mov eax, dword [eax]
cmp eax, edx
je 0x406795
mov esi, dword [eax + 0x14]
push esi
xor ebx, ebx
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov edi, dword [esi + 0x18]
cmp dword [edi + 0x10], ebx
je 0x406735
lea eax, [ebp - 0x1c]
mov ecx, edi
call fcn.00402910
mov ecx, dword [eax]
test ecx, ecx
jne 0x4066e6
xor edx, edx
jmp 0x4066e8
mov edx, dword [ecx]
mov ecx, dword [eax + 8]
mov ebx, dword [edx + 8]
mov eax, ecx
shr eax, 1
and ecx, 1
cmp ebx, eax
ja 0x4066fb
sub eax, ebx
mov edx, dword [edx + 4]
mov eax, dword [edx + eax*4]
mov ebx, dword [eax + ecx*8]
lea eax, [eax + ecx*8]
mov ecx, dword [eax + 4]
mov eax, dword [edi + 0x10]
mov dword [ebp - 4], ecx
test eax, eax
je 0x406735
mov edx, dword [edi + 8]
inc dword [edi + 0xc]
add edx, edx
cmp edx, dword [edi + 0xc]
ja 0x406728
mov dword [edi + 0xc], 0
dec eax
mov dword [edi + 0x10], eax
jne 0x406735
mov dword [edi + 0xc], 0
push esi
mov esi, dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
call esi
push 0x420768
call esi
test ebx, ebx
jne 0x4067b0
call dword [sym.imp.KERNEL32.dll_GetTickCount]
sub eax, dword [ebp - 0x10]
cmp eax, dword [ebp + 0x18]
ja 0x40684f
push 0x64
call dword [sym.imp.KERNEL32.dll_Sleep]
push 0x420768
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
cmp dword [0x4207bc], ebx
je 0x40666a
push 0x420768
mov esi, 2
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov eax, esi
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret 0x14
push 0x420768
mov esi, 3
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov eax, esi
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret 0x14
mov eax, dword [ebp + 0x10]
test eax, eax
je 0x4067bc
mov ecx, dword [ebx + 0x10]
mov dword [eax], ecx
mov eax, dword [ebp + 0x14]
test eax, eax
je 0x4067c8
mov edx, dword [ebx + 8]
mov dword [eax], edx
mov esi, dword [ebp + 0xc]
test esi, esi
je 0x40683b
mov edi, dword [ebx + 0x10]
test edi, edi
je 0x40681f
call fcn.00401760
test eax, eax
jne 0x4067f6
push ebx
lea esi, [eax + 3]
call fcn.00409b71
add esp, 4
mov eax, esi
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret 0x14
mov eax, dword [ebx + 0x10]
push eax
lea ecx, [ebx + 0x18]
mov edx, esi
mov eax, dword [edx]
push ecx
push eax
call fcn.0040e8d0
add esp, 0xc
push ebx
call fcn.00409b71
add esp, 4
xor eax, eax
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret 0x14
mov eax, dword [esi]
test eax, eax
je 0x40682e
push eax
call fcn.00409587
add esp, 4
mov dword [esi + 4], 0
mov dword [esi], 0
push ebx
call fcn.00409b71
add esp, 4
xor eax, eax
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret 0x14
pop edi
pop esi
mov eax, 1
pop ebx
mov esp, ebp
pop ebp
ret 0x14