// File: /workspace/github_c_makefile_star2_O2/KhuramAli[P]JAM-Benchmark/lock_and_lockfree/code13.cpp
// Function: main
int main(int argc, char** argv)
    {
    
      if (argc < 5)
        return -1;
      int numthreads = atoi(argv[1]);
      count = atol(argv[2]);
      int factor = atoi(argv[3]);
      int type = atoi(argv[4]);
      int readerCount = 0;
      int writerCount = 0;
      double ticStart;
    
      jobs Jobs [] = {
        JOB(unlocked,               unlocked_read),
        JOB(mutex,                  mutex_read),
        JOB(rwlock,                 rwlock_read_wr),
        JOB(rwlock,                 rwlock_read_rd),
        JOB(atomic,                 atomic_read),
        JOB(atomic_set_release,     atomic_read_consume),
        JOB(atomic_set_release,     atomic_read_acquire),
        JOB(atomic_set_cst,         atomic_read_consume),
        JOB(atomic_set_cst,         atomic_read_acquire),
        JOB(atomic_set_relaxed,     atomic_read_consume),
        JOB(atomic_set_relaxed,     atomic_read_acquire),
        JOB(atomic_weak,            atomic_read_consume),
        JOB(atomic_weak,            atomic_read_acquire)
      };
    
    #ifdef WIN32
    InitializeSRWLock(&srwlock);
    #endif
    
      atomic_uint = 1;
      if (type >= sizeof(Jobs)/sizeof(jobs)) {
        std::cout << "type not supported.\n";
        exit(1);
      }
    
      for (int i = 0; i < numthreads; i++) {
        if (i % factor == 0) {
          writerCount ++;
          threads.push_back(std::thread(Jobs[type].Write));
        }
        else {
          readerCount ++;
          threads.push_back(std::thread(Jobs[type].Read));
        }
      }
    
      ready = true;
      ticStart = TRI_microtime();
      halt.notify_all();
    
      for (int i = 0; i < numthreads; i++) {
        threads[i].join();
      }
      std::cout
        << "Threads: "
        << numthreads
        <<" count:   "
        << count
        << " Readers: "
        << readerCount
        << " Writers: "
        << writerCount
        << " atomic_uint is now: " 
        << atomic_uint
        << " flat_uint is now: "
        << flat_uint
        << " Test: "
        << Jobs[type].ReadStr
        << " + "
        << Jobs[type].WriteStr
        << " test Duration: "
        << (float) (TRI_microtime() - ticStart)
        << "\n";
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
cmpl $0x5, %edi
jge 0x2b5d
pushq $-0x1
popq %rax
jmp 0x2db0
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x21e0
movl %eax, %ebp
movq 0x10(%rbx), %rdi
callq 0x2170
movq %rax, 0x363d(%rip)      # 0x61b8
movq 0x18(%rbx), %rdi
callq 0x21e0
movl %eax, %r12d
movq 0x20(%rbx), %rdi
callq 0x21e0
movl %eax, %ebx
leaq 0x3037(%rip), %rsi      # 0x5bd0
leaq 0x20(%rsp), %rdi
movl $0x1a0, %edx            # imm = 0x1A0
callq 0x20f0
pushq $0x1
popq %rax
xchgq %rax, 0x35fe(%rip)      # 0x61b0
cmpl $0xc, %ebx
ja 0x2dc2
movl %ebx, %eax
shlq $0x5, %rax
leaq (%rsp,%rax), %r13
addq $0x30, %r13
addq %rsp, %rax
addq $0x20, %rax
movq %rax, 0x8(%rsp)
xorl %r15d, %r15d
testl %ebp, %ebp
movl %ebp, 0x4(%rsp)
movl %ebp, %ebx
cmovlel %r15d, %ebx
leaq 0x10(%rsp), %rbp
movl $0x0, (%rsp)
xorl %r14d, %r14d
cmpl %r14d, %ebx
je 0x2c4b
movl %r14d, %eax
cltd
idivl %r12d
movq %rbp, %rdi
testl %edx, %edx
je 0x2c22
movq %r13, %rsi
callq 0x2e56
leaq 0x360b(%rip), %rdi      # 0x6220
movq %rbp, %rsi
callq 0x2f70
incl %r15d
jmp 0x2c3e
movq 0x8(%rsp), %rsi
callq 0x2e56
leaq 0x35ed(%rip), %rdi      # 0x6220
movq %rbp, %rsi
callq 0x2f70
incl (%rsp)
movq %rbp, %rdi
callq 0x2ebe
incl %r14d
jmp 0x2bf3
movb $0x1, 0x35c6(%rip)      # 0x6218
callq 0x23bc
movsd %xmm0, 0x18(%rsp)
leaq 0x3584(%rip), %rdi      # 0x61e8
callq 0x2200
movl %ebx, %ebx
shlq $0x3, %rbx
xorl %r14d, %r14d
movl 0x4(%rsp), %ebp
cmpq %r14, %rbx
je 0x2c90
movq 0x359e(%rip), %rdi      # 0x6220
addq %r14, %rdi
callq 0x2210
addq $0x8, %r14
jmp 0x2c76
movq 0x3339(%rip), %rdi      # 0x5fd0
leaq 0x1481(%rip), %rsi      # 0x411f
callq 0x2150
movq %rax, %rdi
movl %ebp, %esi
callq 0x2220
leaq 0x1475(%rip), %rsi      # 0x4129
movq %rax, %rdi
callq 0x2150
movq 0x34f5(%rip), %rsi      # 0x61b8
movq %rax, %rdi
callq 0x2140
leaq 0x1462(%rip), %rsi      # 0x4134
movq %rax, %rdi
callq 0x2150
movq %rax, %rdi
movl %r15d, %esi
callq 0x2220
leaq 0x1453(%rip), %rsi      # 0x413f
movq %rax, %rdi
callq 0x2150
movq %rax, %rdi
movl (%rsp), %esi
callq 0x2220
leaq 0x1444(%rip), %rsi      # 0x414a
movq %rax, %rdi
callq 0x2150
movq 0x349b(%rip), %rsi      # 0x61b0
movq %rax, %rdi
callq 0x20b0
leaq 0x143c(%rip), %rsi      # 0x4160
movq %rax, %rdi
callq 0x2150
movq 0x33fd(%rip), %rsi      # 0x6130
movq %rax, %rdi
callq 0x20b0
leaq 0x1432(%rip), %rsi      # 0x4174
movq %rax, %rdi
callq 0x2150
movq 0x8(%rsp), %rbx
movq 0x18(%rbx), %rsi
movq %rax, %rdi
callq 0x2150
leaq 0x141a(%rip), %rsi      # 0x417c
movq %rax, %rdi
callq 0x2150
movq 0x8(%rbx), %rsi
movq %rax, %rdi
callq 0x2150
leaq 0x1403(%rip), %rsi      # 0x4180
movq %rax, %rdi
callq 0x2150
movq %rax, %rbx
callq 0x23bc
subsd 0x18(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq %rbx, %rdi
callq 0x20c0
leaq 0x1377(%rip), %rsi      # 0x411d
movq %rax, %rdi
callq 0x2150
xorl %eax, %eax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3207(%rip), %rdi      # 0x5fd0
leaq 0x133a(%rip), %rsi      # 0x410a
callq 0x2150
pushq $0x1
popq %rdi
callq 0x2180
jmp 0x2ddf
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2ebe
movq %rbx, %rdi
callq 0x2230