// File: UBOdin[P]jitd-cpp/src/rwlock.cpp
// Function: RWLock::reader_lock()
void RWLock::reader_lock()
{
  unique_lock<std::mutex> l(lock);
  if(writers.load() || write_waiters.load())
  {
    read_waiters.fetch_add(1);
    do { read.wait(l); }
    while(writers.load() || write_waiters.load());
    read_waiters.fetch_sub(1);
  }
  readers.fetch_add(1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0xb0(%rbp)
movq -0xb0(%rbp), %rsi
movq %rsi, -0xd8(%rbp)
addq $0x10, %rsi
leaq -0xc0(%rbp), %rdi
callq 0x5560
movq -0xd8(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
movl $0x5, -0x54(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0xd0(%rbp)
movl -0x54(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x56f0
movl %eax, -0xc4(%rbp)
jmp 0x4796
movl -0xc4(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0xdc(%rbp)
decl %eax
subl $0x2, %eax
jb 0x47cc
jmp 0x47b1
movl -0xdc(%rbp), %eax
subl $0x5, %eax
je 0x47da
jmp 0x47be
movq -0xd0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
jmp 0x47f0
movq -0xd0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
jmp 0x47f0
movq -0xd0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
jmp 0x47f0
movq %rax, %rdi
callq 0x56c0
cmpl $0x0, -0x5c(%rbp)
jne 0x4894
movq -0xd8(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x68(%rbp)
movl $0x5, -0x6c(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0xe8(%rbp)
movl -0x6c(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x56f0
movl %eax, -0xe0(%rbp)
jmp 0x4830
movl -0xe0(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0xec(%rbp)
decl %eax
subl $0x2, %eax
jb 0x4866
jmp 0x484b
movl -0xec(%rbp), %eax
subl $0x5, %eax
je 0x4874
jmp 0x4858
movq -0xe8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x74(%rbp)
jmp 0x488a
movq -0xe8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x74(%rbp)
jmp 0x488a
movq -0xe8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x74(%rbp)
jmp 0x488a
movq %rax, %rdi
callq 0x56c0
cmpl $0x0, -0x74(%rbp)
je 0x4ba2
movq -0xd8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movl $0x1, -0x24(%rbp)
movl $0x5, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x100(%rbp)
movl -0x28(%rbp), %eax
movl -0x24(%rbp), %ecx
movl %ecx, -0x2c(%rbp)
decl %eax
movl %eax, %ecx
movq %rcx, -0xf8(%rbp)
subl $0x4, %eax
ja 0x48ec
movq -0xf8(%rbp), %rax
leaq 0x1b721(%rip), %rcx     # 0x20004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x100(%rbp), %rcx
movl -0x2c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x30(%rbp)
jmp 0x4949
movq -0x100(%rbp), %rcx
movl -0x2c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x30(%rbp)
jmp 0x4949
movq -0x100(%rbp), %rcx
movl -0x2c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x30(%rbp)
jmp 0x4949
movq -0x100(%rbp), %rcx
movl -0x2c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x30(%rbp)
jmp 0x4949
movq -0x100(%rbp), %rcx
movl -0x2c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x30(%rbp)
movq -0xd8(%rbp), %rdi
addq $0x38, %rdi
leaq -0xc0(%rbp), %rsi
callq 0x4090
movq -0xd8(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x80(%rbp)
movl $0x5, -0x84(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x110(%rbp)
movl -0x84(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x56f0
movl %eax, -0x104(%rbp)
jmp 0x499c
movl -0x104(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x84(%rbp), %eax
movl %eax, -0x114(%rbp)
decl %eax
subl $0x2, %eax
jb 0x49db
jmp 0x49bd
movl -0x114(%rbp), %eax
subl $0x5, %eax
je 0x49ec
jmp 0x49ca
movq -0x110(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x8c(%rbp)
jmp 0x4a05
movq -0x110(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x8c(%rbp)
jmp 0x4a05
movq -0x110(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x8c(%rbp)
jmp 0x4a05
movq %rax, %rdi
callq 0x56c0
movb $0x1, %al
cmpl $0x0, -0x8c(%rbp)
movb %al, -0x115(%rbp)
jne 0x4ad5
movq -0xd8(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x98(%rbp)
movl $0x5, -0x9c(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x128(%rbp)
movl -0x9c(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x56f0
movl %eax, -0x11c(%rbp)
jmp 0x4a5c
movl -0x11c(%rbp), %eax
movl %eax, -0xa0(%rbp)
movl -0x9c(%rbp), %eax
movl %eax, -0x12c(%rbp)
decl %eax
subl $0x2, %eax
jb 0x4a9b
jmp 0x4a7d
movl -0x12c(%rbp), %eax
subl $0x5, %eax
je 0x4aac
jmp 0x4a8a
movq -0x128(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xa4(%rbp)
jmp 0x4ac5
movq -0x128(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xa4(%rbp)
jmp 0x4ac5
movq -0x128(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xa4(%rbp)
jmp 0x4ac5
movq %rax, %rdi
callq 0x56c0
cmpl $0x0, -0xa4(%rbp)
setne %al
movb %al, -0x115(%rbp)
movb -0x115(%rbp), %al
testb $0x1, %al
jne 0x4949
movq -0xd8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x8(%rbp)
movl $0x1, -0xc(%rbp)
movl $0x5, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x140(%rbp)
movl -0x10(%rbp), %eax
movl -0xc(%rbp), %ecx
movl %ecx, -0x14(%rbp)
decl %eax
movl %eax, %ecx
movq %rcx, -0x138(%rbp)
subl $0x4, %eax
ja 0x4b3b
movq -0x138(%rbp), %rax
leaq 0x1b4e6(%rip), %rcx     # 0x20018
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x140(%rbp), %rcx
movl -0x14(%rbp), %eax
negl %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x18(%rbp)
jmp 0x4ba2
movq -0x140(%rbp), %rcx
movl -0x14(%rbp), %eax
negl %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x18(%rbp)
jmp 0x4ba2
movq -0x140(%rbp), %rcx
movl -0x14(%rbp), %eax
negl %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x18(%rbp)
jmp 0x4ba2
movq -0x140(%rbp), %rcx
movl -0x14(%rbp), %eax
negl %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x18(%rbp)
jmp 0x4ba2
movq -0x140(%rbp), %rcx
movl -0x14(%rbp), %eax
negl %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x18(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x1, -0x3c(%rbp)
movl $0x5, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x150(%rbp)
movl -0x40(%rbp), %eax
movl -0x3c(%rbp), %ecx
movl %ecx, -0x44(%rbp)
decl %eax
movl %eax, %ecx
movq %rcx, -0x148(%rbp)
subl $0x4, %eax
ja 0x4bf6
movq -0x148(%rbp), %rax
leaq 0x1b43f(%rip), %rcx     # 0x2002c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x150(%rbp), %rcx
movl -0x44(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x48(%rbp)
jmp 0x4c53
movq -0x150(%rbp), %rcx
movl -0x44(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x48(%rbp)
jmp 0x4c53
movq -0x150(%rbp), %rcx
movl -0x44(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x48(%rbp)
jmp 0x4c53
movq -0x150(%rbp), %rcx
movl -0x44(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x48(%rbp)
jmp 0x4c53
movq -0x150(%rbp), %rcx
movl -0x44(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x48(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x55a0
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopl (%rax,%rax)