// File: /workspace/github_cpp_makefile_star2_O2/ahupowerdns[P]mcounter/mcounter-multi.cc
// Function: main
int main(int argc, char **argv)
{
  cout<<sizeof(mca)<<endl;
  int num= argc > 1 ? atoi(argv[1]) : 1;
  bool unshared = argc > 2 ? argv[2]==std::string("unshared") : 1;
  std::thread progress(printWorker);
  progress.detach();

  vector<std::thread> threads;

  auto start = high_resolution_clock::now();
  for(int n=0; n < num; ++n)
    threads.emplace_back(unshared ? unsharedStructWorker: sharedStructWorker,
                         100000000);

  for(auto& t : threads)
    t.join();
                           
  auto finish = high_resolution_clock::now();
  auto msecs = duration_cast<milliseconds>(finish-start);
  cout<<msecs.count()<<" milliseconds"<<endl;
  cout << "Final: "<<myc.get().a << " / "<<mca.a<<", "<<mca.b<<endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movl %edi, %r15d
movq 0x4ada(%rip), %rdi      # 0x6fd8
pushq $0x10
popq %rsi
callq 0x20f0
movq %rax, %rdi
callq 0x20b0
leaq -0x129(%rip), %rbx      # 0x23ec
cmpl $0x2, %r15d
jl 0x2570
movq 0x8(%r14), %rdi
callq 0x21f0
movl %eax, %ebp
cmpl $0x2, %r15d
je 0x2573
movq 0x10(%r14), %rbx
leaq 0x1ad4(%rip), %rsi      # 0x400b
leaq 0x10(%rsp), %r14
movq %rsp, %rdx
movq %r14, %rdi
callq 0x2796
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2780
leaq -0x16d(%rip), %rcx      # 0x23ec
leaq -0x13b(%rip), %rbx      # 0x2425
testb %al, %al
cmovneq %rcx, %rbx
movq %r14, %rdi
callq 0x2090
jmp 0x2573
pushq $0x1
popq %rbp
leaq -0x116(%rip), %rsi      # 0x2464
movq %rsp, %r14
movq %r14, %rdi
callq 0x27d2
movq %r14, %rdi
callq 0x2220
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r15
movaps %xmm0, (%r15)
andq $0x0, 0x10(%r15)
callq 0x2030
movq %rax, %r14
xorl %r13d, %r13d
testl %ebp, %ebp
cmovgl %ebp, %r13d
leaq 0xc(%rsp), %r12
subl $0x1, %r13d
jb 0x25d2
movl $0x5f5e100, 0xc(%rsp)   # imm = 0x5F5E100
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2838
jmp 0x25b4
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r15
cmpq %r15, %rbx
je 0x25ef
movq %rbx, %rdi
callq 0x2210
addq $0x8, %rbx
jmp 0x25dc
callq 0x2030
subq %r14, %rax
movl $0xf4240, %ecx          # imm = 0xF4240
cqto
idivq %rcx
movq 0x49d0(%rip), %rdi      # 0x6fd8
movq %rax, %rsi
callq 0x2160
leaq 0x19fd(%rip), %rsi      # 0x4014
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20b0
movq 0x49aa(%rip), %rdi      # 0x6fd8
leaq 0x19ed(%rip), %rsi      # 0x4022
callq 0x2170
movq %rax, %rbx
leaq 0x4b0c(%rip), %rdi      # 0x7150
callq 0x271e
movq %rbx, %rdi
movq %rax, %rsi
callq 0x20f0
leaq 0x19a9(%rip), %rsi      # 0x4004
movq %rax, %rdi
callq 0x2170
movq 0x4b56(%rip), %rsi      # 0x71c0
movq %rax, %rdi
callq 0x20f0
leaq 0x198f(%rip), %rsi      # 0x4008
movq %rax, %rdi
callq 0x2170
movq 0x4b40(%rip), %rsi      # 0x71c8
movq %rax, %rdi
callq 0x20f0
movq %rax, %rdi
callq 0x20b0
leaq 0x10(%rsp), %rdi
callq 0x287a
movq %rsp, %rdi
callq 0x289c
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x26d3
jmp 0x26c6
jmp 0x26c6
jmp 0x26c6
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x287a
movq %rsp, %rdi
callq 0x289c
movq %rbx, %rdi
callq 0x2230
nop