Function at 0x140012060
Capabilities:
Hijack thread execution

Disassembly:
push r13
push r12
push rsi
push rbx
sub rsp, 0x4f8
mov rbx, rcx
test rcx, rcx
je 0x140012112
lea r12, [0x1400e8158]
mov rcx, r12
call sym.pthread_mutex_lock
mov rax, qword [0x140119d18]
test rax, rax
je 0x1400120b1
mov r9, qword [0x140119d20]
lea r8, [rax - 1]
xor ecx, ecx
cmp rax, 1
jne 0x1400120de
cmp rbx, qword [r9 + 8]
je 0x1400122d1
mov rcx, r12
call sym.pthread_mutex_unlock
mov eax, 3
add rsp, 0x4f8
pop rbx
pop rsi
pop r12
pop r13
ret
cmp rax, rcx
je 0x1400120b1
lea r8, [rax - 1]
cmp r8, rcx
jb 0x1400120b1
lea rax, [rcx + r8]
shr rax, 1
mov rdx, rax
shl rdx, 4
add rdx, r9
cmp rbx, qword [rdx + 8]
je 0x140012128
jb 0x1400120d0
lea rcx, [rax + 1]
jmp 0x1400120d9
mov rcx, r13
call sym.pthread_mutex_unlock
test byte [rsi + 0x40], 0xc
je 0x1400121ba
mov eax, 3
add rsp, 0x4f8
pop rbx
pop rsi
pop r12
pop r13
ret
mov rsi, qword [rdx]
mov rcx, r12
call sym.pthread_mutex_unlock
test rsi, rsi
je 0x140012112
mov rcx, qword [rsi + 0x28]
lea rax, [rcx - 1]
cmp rax, 0xfffffffffffffffd
ja 0x140012112
lea r12, [rsp + 0x20]
mov rdx, r12
call qword [sym.imp.KERNEL32.dll_GetHandleInformation]
test eax, eax
je 0x140012112
lea r13, [rsi + 0x38]
mov rcx, r13
call sym.pthread_mutex_lock
call sym.__pthread_self_lite
test rax, rax
je 0x140012177
cmp rbx, qword [rax + 0x1d8]
je 0x1400121d0
mov edx, dword [rsi + 0x44]
movzx eax, byte [rsi + 0x40]
and edx, 3
cmp edx, 3
je 0x140012230
test al, 3
jne 0x140012100
and eax, 0xfffffffc
or eax, 1
mov byte [rsi + 0x40], al
lock add dword [0x140119d48], 1
mov rcx, qword [rsi + 0x30]
test rcx, rcx
je 0x1400121b2
call qword [sym.imp.KERNEL32.dll_SetEvent]
mov rcx, r13
call sym.pthread_mutex_unlock
xor eax, eax
add rsp, 0x4f8
pop rbx
pop rsi
pop r12
pop r13
ret
movzx eax, byte [rsi + 0x40]
test al, 3
jne 0x140012100
and eax, 0xfffffffc
or eax, 1
mov byte [rsi + 0x40], al
lock add dword [0x140119d48], 1
mov rcx, qword [rsi + 0x30]
test rcx, rcx
je 0x1400121fc
call qword [sym.imp.KERNEL32.dll_SetEvent]
mov eax, dword [rsi + 0x44]
mov edx, eax
and edx, 3
cmp edx, 3
jne 0x1400121b2
and eax, 0xfffffffe
mov rcx, r13
mov dword [rsi + 0x44], eax
movzx eax, byte [rsi + 0x40]
and eax, 0xfffffff3
or eax, 4
mov byte [rsi + 0x40], al
call sym.pthread_mutex_unlock
call sym._pthread_invoke_cancel
nop dword [rax]
test al, 0xc
jne 0x140012100
test al, 0xf
jne 0x140012112
mov rcx, qword [rsi + 0x28]
mov dword [rsp + 0x50], 0x100001
call qword [sym.imp.KERNEL32.dll_SuspendThread]
xor edx, edx
mov rcx, qword [rsi + 0x28]
call qword [sym.imp.KERNEL32.dll_WaitForSingleObject]
cmp eax, 0x102
jne 0x1400121b2
mov rcx, qword [rsi + 0x28]
mov rdx, r12
call qword [sym.imp.KERNEL32.dll_GetThreadContext]
lea rax, [sym._pthread_invoke_cancel]
mov rcx, qword [rsi + 0x28]
mov rdx, r12
mov qword [rsp + 0x118], rax
call qword [sym.imp.KERNEL32.dll_SetThreadContext]
movzx eax, byte [rsi + 0x40]
and dword [rsi + 0x44], 0xfffffffe
and eax, 0xfffffff0
or eax, 5
mov byte [rsi + 0x40], al
lock add dword [0x140119d48], 1
mov rcx, qword [rsi + 0x30]
test rcx, rcx
je 0x1400122ba
call qword [sym.imp.KERNEL32.dll_SetEvent]
mov rcx, r13
call sym.pthread_mutex_unlock
mov rcx, qword [rsi + 0x28]
call qword [sym.imp.KERNEL32.dll_ResumeThread]
jmp 0x1400121b2
mov rsi, qword [r9]
jmp 0x14001212b