Function at 0x40c470
Capabilities:
Get thread local storage value
Set thread local storage value

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x18
push ebx
push esi
push edi
mov edi, dword [ebp + 8]
xor ebx, ebx
mov dword [ebp - 4], ebx
lea eax, [edi + 0xec]
push eax
mov dword [ebp - 0x10], eax
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
push dword [edi + 0xc0]
call dword [sym.imp.KERNEL32.dll_TlsGetValue]
test eax, eax
je 0x40c4b5
mov esi, dword [ebp - 0x10]
push esi
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
pop edi
pop esi
lea eax, [ebx - 6]
pop ebx
mov esp, ebp
pop ebp
ret
push edi
push dword [edi + 0xc0]
call dword [sym.imp.KERNEL32.dll_TlsSetValue]
lea esi, [edi + 0xec]
push esi
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
push esi
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
push edi
call fcn.0040c390
add esp, 4
test byte [edi + 0x104], 1
je 0x40c5b2
push str.poll_fds_modified__reallocating
push str.handle_events
push 4
push 0
call fcn.0040b040
push dword [edi + 0x11c]
call fcn.004211d6
push 8
push dword [edi + 0x120]
mov dword [edi + 0x11c], ebx
call fcn.0042409b
add esp, 0x1c
mov dword [edi + 0x11c], eax
test eax, eax
jne 0x40c53c
mov eax, dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
push esi
call eax
mov esi, 0xfffffff5
jmp 0x40c9a1
mov eax, dword [edi + 0x110]
lea ebx, [edi + 0x10c]
lea esi, [eax - 8]
cmp eax, ebx
je 0x40c57b
mov edx, 0xfffffff8
mov ecx, dword [edi + 0x11c]
lea edx, [edx + 8]
mov eax, dword [esi]
mov dword [edx + ecx], eax
mov ecx, dword [edi + 0x11c]
mov ax, word [esi + 4]
mov word [edx + ecx + 4], ax
mov eax, dword [esi + 0xc]
lea esi, [eax - 8]
cmp eax, ebx
jne 0x40c554
and dword [edi + 0x104], 0xfffffffe
jne 0x40c5b2
cmp dword [edi + 0x108], 0
jne 0x40c5b2
lea eax, [edi + 0x124]
cmp dword [edi + 0x128], eax
jne 0x40c5b2
lea eax, [edi + 0x12c]
cmp dword [edi + 0x130], eax
jne 0x40c5b2
push edi
call fcn.0040aef0
add esp, 4
mov ebx, dword [edi + 0x120]
mov eax, dword [edi + 0x11c]
push ebx
push eax
mov dword [ebp - 4], eax
call fcn.0040e240
add esp, 8
lea eax, [edi + 0xec]
push eax
mov eax, dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
call eax
mov ecx, dword [ebp + 0xc]
mov esi, 0x3e8
mov eax, dword [ecx + 4]
cdq
idiv esi
imul ecx, dword [ecx], 0x3e8
add eax, ecx
test edx, edx
lea esi, [eax + 1]
cmove esi, eax
push esi
push ebx
push str.poll____d_fds_with_timeout_in__dms
push str.handle_events
push 4
push 0
call fcn.0040b040
push esi
push ebx
push dword [ebp - 4]
call fcn.0040e400
mov esi, eax
push esi
push str.poll___returned__d
push str.handle_events
push 4
push 0
mov dword [ebp - 8], esi
call fcn.0040b040
add esp, 0x38
test esi, esi
jne 0x40c65e
lea esi, [edi + 0x80]
push esi
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
push edi
call fcn.0040c9d0
add esp, 4
mov dword [ebp - 8], eax
push esi
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
mov esi, dword [ebp - 8]
jmp 0x40c9a1
cmp esi, 0xffffffff
jne 0x40c677
call fcn.0042412a
cmp dword [eax], 4
jne 0x40c67b
mov esi, 0xfffffff6
jmp 0x40c9a1
test esi, esi
jns 0x40c6a0
call fcn.0042412a
push dword [eax]
push esi
push str.poll_failed__d_err_d
push str.handle_events
push 1
push edi
call fcn.0040b040
add esp, 0x18
or esi, 0xffffffff
jmp 0x40c9a1
mov edx, dword [ebp - 4]
cmp word [edx + 6], 0
je 0x40c905
push str.caught_a_fish_on_the_event_pipe
push str.handle_events
xor esi, esi
mov dword [ebp - 0xc], 0
lea eax, [ebp - 0x18]
mov dword [ebp - 0x10], esi
push 4
push esi
mov dword [ebp - 0x14], eax
mov dword [ebp - 0x18], eax
call fcn.0040b040
add esp, 0x10
lea eax, [edi + 0xec]
push eax
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
mov eax, dword [edi + 0x104]
test al, 1
je 0x40c70a
push str.someone_updated_the_poll_fds
push str.handle_events
push 4
push esi
call fcn.0040b040
mov eax, dword [edi + 0x104]
add esp, 0x10
test al, 2
je 0x40c731
push str.someone_purposely_interrupted
push str.handle_events
push 4
push 0
call fcn.0040b040
add esp, 0x10
and dword [edi + 0x104], 0xfffffffd
mov eax, dword [edi + 0x104]
test al, 4
je 0x40c759
push str.someone_unregistered_a_hotplug_cb
push str.handle_events
push 4
push 0
call fcn.0040b040
add esp, 0x10
mov dword [ebp - 0xc], 1
and dword [edi + 0x104], 0xfffffffb
cmp dword [edi + 0x108], esi
je 0x40c777
push str.someone_is_closing_a_device
push str.handle_events
push 4
push 0
call fcn.0040b040
add esp, 0x10
lea esi, [edi + 0x124]
cmp dword [edi + 0x128], esi
je 0x40c7b7
push str.hotplug_message_received
push str.handle_events
push 4
push 0
call fcn.0040b040
mov eax, dword [esi + 4]
add esp, 0x10
cmp eax, esi
je 0x40c7b7
mov dword [ebp - 0x14], eax
lea ecx, [ebp - 0x18]
mov dword [eax], ecx
mov eax, dword [esi]
mov dword [ebp - 0x18], eax
mov dword [eax + 4], ecx
mov dword [esi + 4], esi
mov dword [esi], esi
mov esi, dword [edi + 0x130]
lea ecx, [edi + 0x12c]
cmp esi, ecx
je 0x40c83e
mov ecx, dword [esi + 4]
mov eax, dword [esi]
mov dword [ecx], eax
mov ecx, dword [esi]
mov eax, dword [esi + 4]
mov dword [ecx + 4], eax
lea eax, [edi + 0xec]
push eax
mov dword [esi], 0
mov dword [esi + 4], 0
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
lea eax, [esi - 0xc]
push eax
call dword [0x438d0c]
add esp, 4
mov dword [ebp - 0x10], eax
test eax, eax
jne 0x40c813
lea eax, [edi + 0xec]
push eax
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
jmp 0x40c7b7
push eax
push str.backend_handle_transfer_completion_failed_with_error__d
push str.handle_events
push 1
push edi
call fcn.0040b040
add esp, 0x14
lea esi, [edi + 0xec]
push esi
call dword [sym.imp.KERNEL32.dll_EnterCriticalSection]
lea ecx, [edi + 0x12c]
jmp 0x40c844
lea esi, [edi + 0xec]
cmp dword [edi + 0x104], 0
jne 0x40c875
cmp dword [edi + 0x108], 0
jne 0x40c875
lea eax, [edi + 0x124]
cmp dword [edi + 0x128], eax
jne 0x40c875
cmp dword [edi + 0x130], ecx
jne 0x40c875
push edi
call fcn.0040aef0
add esp, 4
push esi
call dword [sym.imp.KERNEL32.dll_LeaveCriticalSection]
cmp dword [ebp - 0xc], 0
je 0x40c88d
push 0
push edi
call fcn.0040e650
add esp, 8
mov eax, dword [ebp - 0x14]
lea ecx, [ebp - 0x18]
cmp eax, ecx
je 0x40c8e8
push dword [eax - 8]
lea esi, [eax - 8]
push dword [esi + 4]
push edi
call fcn.0040e700
add esp, 0xc
cmp dword [esi], 2
jne 0x40c8b6
push dword [esi + 4]
call fcn.0040ad10
mov ecx, dword [esi + 0xc]
mov eax, dword [esi + 8]
push esi
mov dword [ecx], eax
mov ecx, dword [esi + 8]
mov eax, dword [esi + 0xc]
mov dword [ecx + 4], eax
mov dword [esi + 8], 0
mov dword [esi + 0xc], 0
call fcn.004211d6
mov eax, dword [ebp - 0x14]
lea ecx, [ebp - 0x18]
add esp, 4
cmp eax, ecx
jne 0x40c897
mov esi, dword [ebp - 0x10]
test esi, esi
jne 0x40c9a1
mov esi, dword [ebp - 8]
sub esi, 1
mov dword [ebp - 8], esi
je 0x40c9a1
mov edx, dword [ebp - 4]
mov eax, dword [edi + 0x118]
lea esi, [edi + 0x114]
mov dword [ebp - 0xc], esi
lea ecx, [eax - 8]
cmp eax, esi
je 0x40c96f
mov edi, ecx
mov ecx, esi
nop
mov esi, 1
cmp ebx, esi
jbe 0x40c962
mov ecx, dword [edi]
nop dword [eax + eax]
mov eax, dword [edx + esi*8]
cmp ecx, eax
je 0x40c93e
inc esi
cmp esi, ebx
jb 0x40c930
jmp 0x40c95f
push eax
push str.pollfd__d_was_removed._ignoring_raised_events
push str.handle_events
push 4
push 0
call fcn.0040b040
mov edx, dword [ebp - 4]
add esp, 0x14
xor eax, eax
mov word [edx + esi*8 + 6], ax
mov ecx, dword [ebp - 0xc]
mov eax, dword [edi + 0xc]
lea edi, [eax - 8]
cmp eax, ecx
jne 0x40c920
mov edi, dword [ebp + 8]
mov eax, dword [ebp - 8]
push eax
lea eax, [ebx - 1]
push eax
lea eax, [edx + 8]
push eax
push edi
call dword [0x438d08]
mov esi, eax
add esp, 0x10
test esi, esi
je 0x40c9a1
push esi
push str.backend_handle_events_failed_with_error__d
push str.handle_events
push 1
push edi
call fcn.0040b040
add esp, 0x14
push 0
push dword [edi + 0xc0]
call dword [sym.imp.KERNEL32.dll_TlsSetValue]
push ebx
push dword [ebp - 4]
call fcn.0040e180
add esp, 8
mov eax, esi
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret