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

Disassembly:
push r15
push r14
push r13
push r12
push rsi
push rdi
push rbp
push rbx
sub rsp, 0x48
mov qword [rsp + 0x38], rcx
mov r15, qword [0x140057110]
xor esi, esi
lea r14, [0x142a55e50]
jmp 0x140019977
mov r15, qword [0x140057110]
mov rbx, r15
and rbx, 3
je 0x140019990
cmp ebx, 1
je 0x1400199c0
jmp 0x140019e16
cmp qword [rsp + 0x38], 0
je 0x1400199c0
lea rcx, [r15 + 1]
mov rax, r15
lock cmpxchg qword [0x140057110], rcx
mov r15, rax
jne 0x140019977
jmp 0x140019e32
lea rdi, [rsp + rbx]
add rdi, 0x20
nop dword [rax + rax]
mov ecx, dword [0x1400570e0]
test ecx, ecx
je 0x1400199f3
dec ecx
call sub.KERNEL32.dll_TlsGetValue
cmp rax, 1
jbe 0x140019a10
mov r12, rax
add r12, 8
jmp 0x140019ab1
lea rcx, [0x1400570c8]
call fcn.140027e30
mov ecx, eax
call sub.KERNEL32.dll_TlsGetValue
cmp rax, 1
ja 0x1400199e7
nop dword [rax]
je 0x140019ec9
movzx eax, byte [0x142a5c108]
mov edx, 0x10
xor ecx, ecx
call fcn.140025a60
test rax, rax
je 0x140019ec9
mov r12, rax
mov rbp, rax
lea rax, [0x1400570c8]
mov qword [r12], rax
mov qword [r12 + 8], 0
mov ecx, dword [0x1400570e0]
test ecx, ecx
je 0x140019b92
dec ecx
call sub.KERNEL32.dll_TlsGetValue
mov r13, rax
mov ecx, dword [0x1400570e0]
test ecx, ecx
je 0x140019ba5
dec ecx
add r12, 8
mov rdx, rbp
call sub.KERNEL32.dll_TlsSetValue
test r13, r13
je 0x140019ab1
mov rax, qword [r13 + 8]
test rax, rax
je 0x140019aa0
lock dec qword [rax]
jne 0x140019aa0
mov rcx, r13
add rcx, 8
call fcn.1400350a0
mov rcx, qword [0x142a5c058]
xor edx, edx
mov r8, r13
call sub.KERNEL32.dll_HeapFree
mov rcx, qword [r12]
test rcx, rcx
jne 0x140019b2e
movzx eax, byte [0x142a5c108]
mov edx, 0x38
xor ecx, ecx
call fcn.140025a60
test rax, rax
je 0x140019ec9
mov rcx, rax
mov qword [rax], 1
mov qword [rax + 8], 1
mov qword [rax + 0x10], 2
mov rax, qword [0x142a5c078]
nop word [rax + rax]
mov rdx, rax
inc rdx
je 0x140019ec9
lock cmpxchg qword [0x142a5c078], rdx
jne 0x140019b00
mov qword [rcx + 0x28], rdx
mov byte [rcx + 0x30], 0
cmp qword [r12], 0
jne 0x140019ec9
mov qword [r12], rcx
lock inc qword [rcx]
jle 0x140019ec9
mov rax, r15
and rax, 0xfffffffffffffffc
mov qword [rsp + 0x20], rcx
mov byte [rsp + 0x30], 0
mov qword [rsp + 0x28], rax
mov rax, r15
lock cmpxchg qword [0x140057110], rdi
je 0x140019bc0
mov r15, rax
and eax, 3
cmp rax, rbx
jne 0x140019df0
mov rax, qword [rsp + 0x20]
test rax, rax
je 0x1400199d0
lock dec qword [rax]
jne 0x1400199d0
mov rcx, qword [rsp + 0x20]
call fcn.1400198e0
jmp 0x1400199d0
lea rcx, [0x1400570c8]
call fcn.140027e30
mov ecx, eax
jmp 0x140019a5c
lea rcx, [0x1400570c8]
call fcn.140027e30
mov ecx, eax
jmp 0x140019a74
movzx eax, byte [rsp + 0x30]
test al, al
lea rdi, [rsp + 0x40]
je 0x140019c09
mov rax, qword [rsp + 0x20]
test rax, rax
je 0x140019970
lock dec qword [rax]
jne 0x140019970
mov rcx, qword [rsp + 0x20]
call fcn.1400198e0
jmp 0x140019970
movzx eax, byte [rsp + 0x30]
test al, al
jne 0x140019bce
mov ecx, dword [0x1400570e0]
test ecx, ecx
je 0x140019c2c
dec ecx
call sub.KERNEL32.dll_TlsGetValue
cmp rax, 1
jbe 0x140019c50
mov r15, rax
add r15, 8
jmp 0x140019cf0
lea rcx, [0x1400570c8]
call fcn.140027e30
mov ecx, eax
call sub.KERNEL32.dll_TlsGetValue
cmp rax, 1
ja 0x140019c20
nop word cs:[rax + rax]
je 0x140019ec9
movzx eax, byte [0x142a5c108]
mov edx, 0x10
xor ecx, ecx
call fcn.140025a60
test rax, rax
je 0x140019ec9
mov r15, rax
mov r13, rax
lea rax, [0x1400570c8]
mov qword [r15], rax
mov qword [r15 + 8], 0
mov ecx, dword [0x1400570e0]
test ecx, ecx
je 0x140019dc8
dec ecx
call sub.KERNEL32.dll_TlsGetValue
mov r12, rax
mov ecx, dword [0x1400570e0]
test ecx, ecx
je 0x140019ddb
dec ecx
add r15, 8
mov rdx, r13
call sub.KERNEL32.dll_TlsSetValue
test r12, r12
je 0x140019cf0
mov rax, qword [r12 + 8]
test rax, rax
je 0x140019cdf
lock dec qword [rax]
jne 0x140019cdf
mov rcx, r12
add rcx, 8
call fcn.1400350a0
mov rcx, qword [0x142a5c058]
xor edx, edx
mov r8, r12
call sub.KERNEL32.dll_HeapFree
mov r12, qword [r15]
test r12, r12
jne 0x140019d6f
movzx eax, byte [0x142a5c108]
mov edx, 0x38
xor ecx, ecx
call fcn.140025a60
test rax, rax
je 0x140019ec9
mov r12, rax
mov qword [rax], 1
mov qword [rax + 8], 1
mov qword [rax + 0x10], 2
mov rax, qword [0x142a5c078]
nop word cs:[rax + rax]
mov rcx, rax
inc rcx
je 0x140019ec9
lock cmpxchg qword [0x142a5c078], rcx
jne 0x140019d40
mov qword [r12 + 0x28], rcx
mov byte [r12 + 0x30], 0
cmp qword [r15], 0
jne 0x140019ec9
mov qword [r15], r12
lock inc qword [r12]
jle 0x140019ec9
mov qword [rsp + 0x40], r12
lock dec byte [r12 + 0x30]
je 0x140019db0
lea r15, [r12 + 0x30]
nop dword [rax]
mov r8d, 1
mov rcx, r15
mov rdx, r14
mov r9d, 0xffffffff
call sub.api_ms_win_core_synch_l1_2_0.dll_WaitOnAddress
mov al, 1
lock cmpxchg byte [r15], sil
jne 0x140019d90
lock dec qword [r12]
jne 0x140019c00
mov rcx, rdi
call fcn.1400350a0
jmp 0x140019c00
lea rcx, [0x1400570c8]
call fcn.140027e30
mov ecx, eax
jmp 0x140019c9a
lea rcx, [0x1400570c8]
call fcn.140027e30
mov ecx, eax
jmp 0x140019cb2
mov rax, qword [rsp + 0x20]
test rax, rax
je 0x140019e0a
lock dec qword [rax]
jne 0x140019e0a
mov rcx, qword [rsp + 0x20]
call fcn.1400198e0
mov r15, qword [0x140057110]
jmp 0x140019977
cmp ebx, 2
jne 0x140019e30
add rsp, 0x48
pop rbx
pop rbp
pop rdi
pop rsi
pop r12
pop r13
pop r14
pop r15
ret
jmp 0x140019e30
mov rsi, qword [rsp + 0x38]
mov rax, qword [rsi]
mov rcx, qword [rax]
mov qword [rax], 0
mov rax, qword [rcx + 0x10]
mov qword [rcx + 0x10], 0
test rax, rax
je 0x140019ec9
call rax
mov rcx, qword [rsi + 8]
mov rcx, qword [rcx]
mov byte [rcx], al
mov eax, 2
xchg qword [0x140057110], rax
mov ecx, eax
and ecx, 3
cmp ecx, 1
jne 0x140019ec9
dec rax
jne 0x140019e88
jmp 0x140019e1b
mov rax, rdi
test rdi, rdi
je 0x140019e1b
mov rsi, qword [rax]
mov rdi, qword [rax + 8]
mov qword [rax], 0
test rsi, rsi
je 0x140019ec9
mov byte [rax + 0x10], 1
mov al, 1
xchg byte [rsi + 0x30], al
cmp al, 0xff
je 0x140019eb0
lock dec qword [rsi]
jne 0x140019e80
jmp 0x140019ebf
lea rcx, [rsi + 0x30]
call sub.api_ms_win_core_synch_l1_2_0.dll_WakeByAddressSingle
lock dec qword [rsi]
jne 0x140019e80
mov rcx, rsi
call fcn.1400198e0
jmp 0x140019e80
ud2