Function at 0x58c733
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
cmp dword [0x798b94], 0
mov ebp, dword [esp + 0x40]
jne 0x58c75f
cmp dword [ebp + 8], 0
jne 0x58c757
mov eax, ebp
call fcn.00592a20
mov dword [ebp + 8], eax
mov eax, dword [ebp + 8]
jmp 0x58c95e
mov esi, dword [ebp + 8]
test esi, esi
jne 0x58c8a1
cmp dword [0x6ac9d0], 0
jne 0x58c80e
mov dword [esp], 0x6ac9d4
call sub.kernel32.dll_InterlockedIncrement
test eax, eax
push edx
jne 0x58c805
mov dword [0x798b48], 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 [0x798b4c], eax
call sub.kernel32.dll_TlsAlloc
cmp eax, 0xffffffff
je 0x58c7df
mov dword [esp + 4], 0x58c6fc
mov dword [esp], eax
mov dword [0x798b54], eax
call fcn.0058e6bc
jmp 0x58c7e4
call sub.kernel32.dll_GetLastError
test eax, eax
jne 0x58c918
mov dword [0x6ac9d0], 1
jmp 0x58c80e
mov dword [esp], 0
call sub.kernel32.dll_Sleep
push edi
cmp dword [0x6ac9d0], 0
je 0x58c7f8
cmp dword [0x798b94], 0
je 0x58c850
mov dword [esp], 0x798b48
call sub.kernel32.dll_InterlockedIncrement
test eax, eax
push esi
je 0x58c850
mov eax, dword [0x798b4c]
mov dword [esp + 4], 0xffffffff
mov dword [esp], eax
call sub.kernel32.dll_WaitForSingleObject
test eax, eax
push ebx
push ebx
je 0x58c850
mov dword [esp], 0x798b48
call sub.kernel32.dll_InterlockedDecrement
push ecx
mov esi, dword [ebp + 8]
test esi, esi
jne 0x58c867
mov esi, dword [0x798b50]
inc esi
mov dword [0x798b50], esi
mov dword [ebp + 8], esi
cmp dword [0x798b94], 0
je 0x58c8a1
mov dword [esp], 0x798b48
call sub.kernel32.dll_InterlockedDecrement
test eax, eax
push edx
js 0x58c8a1
mov eax, dword [0x798b4c]
mov dword [esp + 8], 0
mov dword [esp + 4], 1
mov dword [esp], eax
call sub.kernel32.dll_ReleaseSemaphore
sub esp, 0xc
mov ebx, dword [0x798b54]
call sub.kernel32.dll_GetLastError
mov dword [esp], ebx
mov edi, eax
call sub.kernel32.dll_TlsGetValue
push ecx
mov ebx, eax
mov dword [esp], edi
call sub.kernel32.dll_SetLastError
test ebx, ebx
push edi
jne 0x58c8e6
lea eax, [esi + 0x21]
mov dword [esp + 4], 4
mov dword [esp], eax
call sub.msvcrt.dll_calloc
test eax, eax
mov ebx, eax
je 0x58c918
lea eax, [esi + 0x20]
mov dword [ebx], eax
jmp 0x58c92e
mov edi, dword [ebx]
cmp esi, edi
jbe 0x58c94a
lea ecx, [edi + edi]
cmp esi, ecx
lea eax, [esi + 0x20]
cmova ecx, eax
lea eax, [ecx*4 + 4]
mov dword [esp], ebx
mov dword [esp + 0x1c], ecx
mov dword [esp + 4], eax
call sub.msvcrt.dll_realloc
mov ecx, dword [esp + 0x1c]
test eax, eax
mov ebx, eax
jne 0x58c91d
call sub.msvcrt.dll_abort
mov dword [eax], ecx
lea edx, [eax + edi*4 + 4]
sub ecx, edi
shl ecx, 2
xor eax, eax
mov edi, edx
rep stosb byte es:[edi], al
mov eax, dword [0x798b54]
mov dword [esp + 4], ebx
mov dword [esp], eax
call sub.kernel32.dll_TlsSetValue
test eax, eax
push edx
push edx
jne 0x58c94a
call sub.kernel32.dll_GetLastError
dec esi
mov eax, dword [ebx + esi*4 + 4]
test eax, eax
jne 0x58c95e
mov eax, ebp
call fcn.00592a20
mov dword [ebx + esi*4 + 4], eax
add esp, 0x2c
pop ebx
pop esi
pop edi
pop ebp
ret