Function at 0x4116d0
Capabilities:
Allocate thread local storage
Get thread local storage value
Set thread local storage value

Disassembly:
push ebp
push edi
push esi
push ebx
sub esp, 0x2c
mov ebp, dword [esp + 0x40]
mov ecx, dword [0x4a6048]
test ecx, ecx
jne 0x4116f8
mov eax, dword [ebp + 8]
test eax, eax
je 0x411788
add esp, 0x2c
pop ebx
pop esi
pop edi
pop ebp
ret
mov esi, dword [ebp + 8]
test esi, esi
je 0x411797
mov ebx, dword [0x4a6090]
call sub.KERNEL32.dll_GetLastError
mov edi, eax
mov dword [esp], ebx
call sub.KERNEL32.dll_TlsGetValue
push ecx
mov ebx, eax
mov dword [esp], edi
call sub.KERNEL32.dll_SetLastError
push edi
test ebx, ebx
je 0x411748
mov edi, dword [ebx]
cmp esi, edi
ja 0x411817
dec esi
mov eax, dword [ebx + esi*4 + 4]
test eax, eax
jne 0x4116f0
mov eax, ebp
call fcn.0046f748
mov dword [ebx + esi*4 + 4], eax
jmp 0x4116f0
mov dword [esp + 4], 4
lea eax, [esi + 0x21]
mov dword [esp], eax
call sub.msvcrt.dll_calloc
mov ebx, eax
test eax, eax
je 0x41185c
lea eax, [esi + 0x20]
mov dword [ebx], eax
mov dword [esp + 4], ebx
mov eax, dword [0x4a6090]
mov dword [esp], eax
call sub.KERNEL32.dll_TlsSetValue
push edx
push edx
test eax, eax
jne 0x411732
call sub.KERNEL32.dll_GetLastError
jmp 0x411732
mov eax, ebp
call fcn.0046f748
mov dword [ebp + 8], eax
jmp 0x4116f0
cmp dword [0x474014], 0
je 0x411892
mov dword [esp], 0x4a6084
call sub.KERNEL32.dll_InterlockedIncrement
push esi
test eax, eax
jne 0x411861
mov esi, dword [ebp + 8]
test esi, esi
jne 0x4117d0
mov esi, dword [0x4a608c]
inc esi
mov dword [0x4a608c], esi
mov dword [ebp + 8], esi
cmp dword [0x4a6048], 0
je 0x411703
mov dword [esp], 0x4a6084
call sub.KERNEL32.dll_InterlockedDecrement
push edx
test eax, eax
js 0x411703
mov dword [esp + 8], 0
mov dword [esp + 4], 1
mov eax, dword [0x4a6088]
mov dword [esp], eax
call sub.KERNEL32.dll_ReleaseSemaphore
sub esp, 0xc
jmp 0x411703
lea edx, [edi + edi]
cmp esi, edx
jbe 0x411821
lea edx, [esi + 0x20]
lea eax, [edx*4 + 4]
mov dword [esp + 4], eax
mov dword [esp], ebx
mov dword [esp + 0x1c], edx
call sub.msvcrt.dll_realloc
mov ebx, eax
test eax, eax
mov edx, dword [esp + 0x1c]
je 0x41185c
mov dword [eax], edx
sub edx, edi
lea ecx, [edx*4]
lea edx, [eax + edi*4 + 4]
xor eax, eax
mov edi, edx
rep stosb byte es:[edi], al
jmp 0x41176a
call sub.msvcrt.dll_abort
mov dword [esp + 4], 0xffffffff
mov eax, dword [0x4a6088]
mov dword [esp], eax
call sub.KERNEL32.dll_WaitForSingleObject
push ebx
push ebx
test eax, eax
je 0x4117b9
mov dword [esp], 0x4a6084
call sub.KERNEL32.dll_InterlockedDecrement
push ecx
jmp 0x4117b9
mov dword [esp], 0x474018
call sub.KERNEL32.dll_InterlockedIncrement
push edx
test eax, eax
jne 0x4118b2
jmp 0x4118cd
mov dword [esp], 0
call sub.KERNEL32.dll_Sleep
push edi
cmp dword [0x474014], 0
je 0x4118a5
cmp dword [0x4a6048], 0
je 0x4117b9
jmp 0x4117a4
mov dword [0x4a6084], 0xffffffff
mov dword [esp + 0xc], 0
mov dword [esp + 8], 0xffff
mov dword [esp + 4], 0
mov dword [esp], 0
call sub.KERNEL32.dll_CreateSemaphoreA
sub esp, 0x10
mov dword [0x4a6088], eax
call sub.KERNEL32.dll_TlsAlloc
cmp eax, 0xffffffff
je 0x411936
mov dword [0x4a6090], eax
mov dword [esp + 4], 0x411694
mov dword [esp], eax
call fcn.0041bf38
test eax, eax
jne 0x41185c
mov dword [0x474014], 1
jmp 0x4118bb
call sub.KERNEL32.dll_GetLastError
jmp 0x411922