// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x228, %rsp            # imm = 0x228
movl $0x0, 0x224(%rsp)
movl %edi, 0x220(%rsp)
movq %rsi, 0x218(%rsp)
cmpl $0x5, 0x220(%rsp)
jge 0x384b
movl $0xffffffff, 0x224(%rsp) # imm = 0xFFFFFFFF
jmp 0x3be8
movq 0x218(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x21d0
movl %eax, 0x214(%rsp)
movq 0x218(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x2160
movq %rax, 0x593d(%rip)      # 0x91b8
movq 0x218(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x21d0
movl %eax, 0x210(%rsp)
movq 0x218(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x21d0
movl %eax, 0x20c(%rsp)
movl $0x0, 0x208(%rsp)
movl $0x0, 0x204(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x52f3(%rip), %rsi      # 0x8bc0
movl $0x1a0, %edx            # imm = 0x1A0
callq 0x20f0
leaq 0x58d2(%rip), %rdi      # 0x91b0
movl $0x1, %esi
callq 0x3f50
movslq 0x20c(%rsp), %rax
cmpq $0xd, %rax
jb 0x3913
movq 0x56cb(%rip), %rdi      # 0x8fc8
leaq 0x282e(%rip), %rsi      # 0x6132
callq 0x2140
movl $0x1, %edi
callq 0x2170
movl $0x0, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x214(%rsp), %eax
jge 0x3a2a
movl 0x4c(%rsp), %eax
cltd
idivl 0x210(%rsp)
cmpl $0x0, %edx
jne 0x39ac
movl 0x204(%rsp), %eax
incl %eax
movl %eax, 0x204(%rsp)
movslq 0x20c(%rsp), %rax
shlq $0x5, %rax
leaq 0x50(%rsp,%rax), %rsi
leaq 0x40(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x4040
movq 0x18(%rsp), %rsi
leaq 0x58a7(%rip), %rdi      # 0x9220
callq 0x4010
jmp 0x3980
leaq 0x40(%rsp), %rdi
callq 0x4100
jmp 0x3a18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
leaq 0x40(%rsp), %rdi
callq 0x4100
jmp 0x3bf7
movl 0x208(%rsp), %eax
incl %eax
movl %eax, 0x208(%rsp)
movslq 0x20c(%rsp), %rax
shlq $0x5, %rax
leaq 0x60(%rsp,%rax), %rsi
leaq 0x28(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x4040
movq 0x10(%rsp), %rsi
leaq 0x5838(%rip), %rdi      # 0x9220
callq 0x4010
jmp 0x39ef
leaq 0x28(%rsp), %rdi
callq 0x4100
jmp 0x3a18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
leaq 0x28(%rsp), %rdi
callq 0x4100
jmp 0x3bf7
jmp 0x3a1a
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x391b
movb $0x1, 0x57e7(%rip)      # 0x9218
callq 0x23f0
movsd %xmm0, 0x1f8(%rsp)
leaq 0x57a2(%rip), %rdi      # 0x91e8
callq 0x21f0
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
cmpl 0x214(%rsp), %eax
jge 0x3a86
movslq 0x24(%rsp), %rsi
leaq 0x57b4(%rip), %rdi      # 0x9220
callq 0x4120
movq %rax, %rdi
callq 0x2200
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x3a53
movq 0x553b(%rip), %rdi      # 0x8fc8
leaq 0x26b3(%rip), %rsi      # 0x6147
callq 0x2140
movq %rax, %rdi
movl 0x214(%rsp), %esi
callq 0x2210
movq %rax, %rdi
leaq 0x269f(%rip), %rsi      # 0x6151
callq 0x2140
movq %rax, %rdi
movq 0x56f7(%rip), %rsi      # 0x91b8
callq 0x2230
movq %rax, %rdi
leaq 0x268c(%rip), %rsi      # 0x615c
callq 0x2140
movq %rax, %rdi
movl 0x208(%rsp), %esi
callq 0x2210
movq %rax, %rdi
leaq 0x2679(%rip), %rsi      # 0x6167
callq 0x2140
movq %rax, %rdi
movl 0x204(%rsp), %esi
callq 0x2210
movq %rax, %rdi
leaq 0x2666(%rip), %rsi      # 0x6172
callq 0x2140
movq %rax, (%rsp)
leaq 0x5694(%rip), %rdi      # 0x91b0
callq 0x3ec0
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x2040
movq %rax, %rdi
leaq 0x2651(%rip), %rsi      # 0x6188
callq 0x2140
movq %rax, %rdi
movq 0x55ea(%rip), %rsi      # 0x9130
callq 0x2040
movq %rax, %rdi
leaq 0x2647(%rip), %rsi      # 0x619c
callq 0x2140
movq %rax, %rdi
movslq 0x20c(%rsp), %rcx
leaq 0x50(%rsp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x2620(%rip), %rsi      # 0x61a4
callq 0x2140
movq %rax, %rdi
movslq 0x20c(%rsp), %rcx
leaq 0x50(%rsp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x25f5(%rip), %rsi      # 0x61a8
callq 0x2140
movq %rax, 0x8(%rsp)
callq 0x23f0
movq 0x8(%rsp), %rdi
subsd 0x1f8(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x20c0
movq %rax, %rdi
leaq 0x2562(%rip), %rsi      # 0x6145
callq 0x2140
movl 0x224(%rsp), %eax
addq $0x228, %rsp            # imm = 0x228
retq
movq 0x38(%rsp), %rdi
callq 0x2220
nopw %cs:(%rax,%rax)