// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movq %rsi, %r14
movl %edi, %ebp
movq 0x3a78(%rip), %rdi      # 0x5fd8
movl $0x10, %esi
callq 0x20d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movl $0x1, %ebx
cmpl $0x2, %ebp
jl 0x25a9
movq 0x8(%r14), %rdi
callq 0x21f0
movl %eax, %ebx
leaq 0x38(%rsp), %r12
cmpl $0x3, %ebp
jl 0x25f6
movq 0x10(%r14), %r14
leaq 0x28(%rsp), %r15
movq %r12, (%r15)
leaq 0x1a45(%rip), %rsi      # 0x400b
leaq 0x1a46(%rip), %rdx      # 0x4013
movq %r15, %rdi
callq 0x2e80
movq %r15, %rdi
movq %r14, %rsi
callq 0x2060
testl %eax, %eax
leaq -0x1dd(%rip), %rax      # 0x240c
leaq -0x1a5(%rip), %r14      # 0x244b
cmoveq %rax, %r14
jmp 0x25fd
leaq -0x1f1(%rip), %r14      # 0x240c
cmpl $0x3, %ebp
jl 0x2619
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x2619
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2180
leaq -0x18f(%rip), %rsi      # 0x2491
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x2884
movq %r15, %rdi
callq 0x2220
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
callq 0x2040
movq %rax, %r15
testl %ebx, %ebx
jle 0x2676
leaq 0x10(%rsp), %r12
leaq 0x4(%rsp), %r13
movl $0x5f5e100, 0x4(%rsp)   # imm = 0x5F5E100
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x28fe
decl %ebx
jne 0x265c
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
cmpq %r14, %rbx
je 0x2693
movq %rbx, %rdi
callq 0x2210
addq $0x8, %rbx
jmp 0x2680
callq 0x2040
subq %r15, %rax
movabsq $0x431bde82d7b634db, %rcx # imm = 0x431BDE82D7B634DB
imulq %rcx
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x12, %rdx
addq %rdx, %rsi
movq 0x391b(%rip), %rdi      # 0x5fd8
callq 0x2150
movq %rax, %rbx
leaq 0x1948(%rip), %rsi      # 0x4014
movl $0xd, %edx
movq %rax, %rdi
callq 0x2190
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq 0x38d1(%rip), %rdi      # 0x5fd8
leaq 0x1914(%rip), %rsi      # 0x4022
movl $0x7, %edx
callq 0x2190
leaq 0x3a31(%rip), %rdi      # 0x6150
callq 0x281c
movq 0x38ad(%rip), %rdi      # 0x5fd8
movq %rax, %rsi
callq 0x20d0
movq %rax, %rbx
leaq 0x18c7(%rip), %rsi      # 0x4004
movl $0x3, %edx
movq %rax, %rdi
callq 0x2190
movq 0x3a6f(%rip), %rsi      # 0x61c0
movq %rbx, %rdi
callq 0x20d0
movq %rax, %rbx
leaq 0x18a5(%rip), %rsi      # 0x4008
movl $0x2, %edx
movq %rax, %rdi
callq 0x2190
movq 0x3a51(%rip), %rsi      # 0x61c8
movq %rbx, %rdi
callq 0x20d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
leaq 0x10(%rsp), %rdi
callq 0x293a
cmpq $0x0, 0x8(%rsp)
jne 0x27f4
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x27e4
jmp 0x27d7
jmp 0x27d7
jmp 0x27d7
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x293a
cmpq $0x0, 0x8(%rsp)
jne 0x27f4
movq %rbx, %rdi
callq 0x2230
callq 0x2050
nop