Function at 0x666040
Capabilities:
Get thread local storage value

Disassembly:
push r13
push r12
push rbp
push rdi
push rsi
push rbx
sub rsp, 0x78
mov eax, 0x16
test rcx, rcx
mov dword [rsp + 0x2c], 0
je 0x6661b4
mov rsi, qword [rcx]
test rsi, rsi
je 0x6661b4
cmp rsi, 0xffffffffffffffff
mov rdi, rdx
mov rbx, rcx
je 0x666200
lea rcx, [rsi + 0x18]
call fcn.00664e30
test eax, eax
jne 0x6661c1
mov rbx, qword [rsi + 0x18]
add dword [rsi], 1
test rbx, rbx
je 0x6661f1
lea r12, [rbx + 8]
mov rcx, r12
call fcn.0065cc30
test eax, eax
mov ebp, eax
jne 0x6661e0
cmp qword [rsi + 0x18], 0
je 0x6663bc
mov eax, dword [rbx]
cmp eax, 0x7fffffff
je 0x6661d0
add eax, 1
test eax, eax
mov dword [rbx], eax
jle 0x66635f
mov rcx, r12
call fcn.0065db60
lea rax, [rsp + 0x2c]
mov qword [rsp + 0x30], rdi
mov rbx, qword [0x0071e748]
mov qword [rsp + 0x40], rax
lea rax, [0x00661e70]
mov qword [rsp + 0x50], rax
lea rax, [rsp + 0x30]
mov qword [rsp + 0x38], rsi
test rbx, rbx
mov qword [rsp + 0x58], rax
je 0x6663b5
call qword [sym.imp.KERNEL32.dll_GetLastError]
mov ecx, dword [rbx]
mov r12d, eax
call qword [sym.imp.KERNEL32.dll_TlsGetValue]
mov ecx, r12d
mov rbp, rax
call qword [sym.imp.KERNEL32.dll_SetLastError]
mov rbx, qword [0x0071e748]
lea rdx, [rsp + 0x50]
mov rcx, rbx
mov qword [rsp + 0x60], rbp
call fcn.0065c360
mov rcx, rdi
call fcn.0065db60
test eax, eax
mov dword [rsp + 0x2c], eax
je 0x6662e0
mov rbx, qword [0x0071e748]
test rbx, rbx
je 0x6661b0
call qword [sym.imp.KERNEL32.dll_GetLastError]
mov ecx, dword [rbx]
mov esi, eax
call qword [sym.imp.KERNEL32.dll_TlsGetValue]
mov ecx, esi
mov rbx, rax
call qword [sym.imp.KERNEL32.dll_SetLastError]
test rbx, rbx
je 0x6661b0
mov rax, qword [rbx]
test rax, rax
je 0x6661a0
mov rcx, qword [rbx + 8]
call rax
mov rdx, qword [rbx + 0x10]
mov rcx, qword [0x0071e748]
call fcn.0065c360
mov eax, dword [rsp + 0x2c]
add rsp, 0x78
pop rbx
pop rsi
pop rdi
pop rbp
pop r12
pop r13
ret
call qword [sym.imp.msvcrt.dll__errno]
mov eax, dword [rax]
jmp 0x6661b4
mov ebp, 0x22
mov rcx, r12
call fcn.0065db60
nop dword [rax]
mov rbx, qword [sym.imp.msvcrt.dll__errno]
call rbx
mov dword [rax], ebp
call rbx
mov eax, dword [rax]
jmp 0x6661b4
mov ebp, 0x16
jmp 0x6661e0
mov qword [rsp + 0x68], 0
lea rbp, [rsp + 0x50]
lea rax, [0x0071e708]
mov rdx, rbp
mov qword [rsp + 0x60], 0
mov qword [rsp + 0x50], rax
mov qword [rsp + 0x58], 0
xchg qword [rax], rdx
test rdx, rdx
je 0x666269
mov qword [rdx + 8], rbp
xor eax, eax
add rdx, 0x18
lock cmpxchg qword [rdx], rsi
test rax, rax
mov rcx, rax
je 0x666254
call qword [sym.imp.KERNEL32.dll_SetEvent]
lea r12, [rbp + 0x10]
xor esi, esi
lock xadd qword [r12], rsi
test rsi, rsi
je 0x666304
mov rax, qword [rbx]
cmp rax, 0xffffffffffffffff
je 0x666396
cmp rax, 1
sbb r12d, r12d
and r12d, 6
cmp rax, 1
sbb esi, esi
and esi, 0x16
mov r8, qword [rsp + 0x50]
lea rax, [rbp + 8]
xor edx, edx
lock xadd qword [rax], rdx
test rdx, rdx
mov rcx, rdx
je 0x666333
lea rdx, [rcx + 0x10]
xor eax, eax
mov rcx, 0xffffffffffffffff
lock cmpxchg qword [rdx], rcx
test rax, rax
mov rcx, rax
je 0x6662c6
call qword [sym.imp.KERNEL32.dll_SetEvent]
test r12d, r12d
mov dword [rsp + 0x2c], esi
je 0x6663d0
mov eax, esi
jmp 0x6661b4
lea rcx, [rsi + 0x10]
xor edx, edx
call fcn.00665980
test eax, eax
je 0x666166
call qword [sym.imp.msvcrt.dll__errno]
mov eax, dword [rax]
mov dword [rsp + 0x2c], eax
jmp 0x666166
xor r9d, r9d
xor r8d, r8d
xor edx, edx
xor ecx, ecx
call qword [sym.imp.KERNEL32.dll_CreateEventA]
mov r13, rax
mov rax, rsi
lock cmpxchg qword [r12], r13
test rax, rax
je 0x666386
mov rcx, r13
call qword [sym.imp.KERNEL32.dll_CloseHandle]
jmp 0x666269
mov rax, rbp
lock cmpxchg qword [r8], rdx
cmp rbp, rax
je 0x6662c6
lea rcx, [rbp + 0x18]
lock xadd qword [rcx], rdx
test rdx, rdx
je 0x6663ae
add rbp, 8
xor ecx, ecx
lock xadd qword [rbp], rcx
jmp 0x6662a6
xor r8d, r8d
mov rcx, qword [rbx + 0x10]
mov edx, 1
call qword [sym.imp.KERNEL32.dll_ReleaseSemaphore]
test eax, eax
jne 0x6660da
sub dword [rbx], 1
mov ebp, 0x16
jmp 0x6661d5
mov edx, 0xffffffff
mov rcx, r13
call qword [sym.imp.KERNEL32.dll_WaitForSingleObject]
jmp 0x666325
xor edx, edx
mov rcx, rbx
call fcn.006604e0
mov r12d, eax
mov esi, eax
and r12d, 0xffffffef
jmp 0x66628a
call fcn.006583d0
jmp 0x66634e
xor ebp, ebp
jmp 0x666140
mov rcx, r12
call fcn.0065db60
mov rbx, qword [sym.imp.msvcrt.dll__errno]
jmp 0x6661eb
mov rsi, qword [rbx]
jmp 0x66607e