// File: /workspace/github_cpp_makefile_star2_O3/ahupowerdns[P]mcounter/mcounter-single.cc
// Function: main
int main(int argc, char **argv)
{
  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 ? unsharedWorker: sharedWorker, 100000000);

  for(auto& t : threads)
    t.join();
                           
  auto finish = high_resolution_clock::now();
  auto msecs = duration_cast<milliseconds>(finish-start);

  cout<<"Took "<<msecs.count()<<" milliseconds of wall time"<<endl;
  cout << ucp.get() <<endl;
  cout << g_counter<<endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl $0x1, %ebx
leaq -0xee(%rip), %r14       # 0x2519
cmpl $0x2, %edi
jl 0x267e
movq %rsi, %r15
movl %edi, %ebp
movq 0x8(%rsi), %rdi
callq 0x21f0
movl %eax, %ebx
cmpl $0x2, %ebp
je 0x267e
movq 0x10(%r15), %r14
leaq 0x20(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x19d2(%rip), %rsi      # 0x4008
leaq 0x19d3(%rip), %rdx      # 0x4010
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x2d6e
movq %r15, %rdi
movq %r14, %rsi
callq 0x2060
testl %eax, %eax
leaq -0x145(%rip), %rax      # 0x2519
leaq -0x111(%rip), %r14      # 0x2554
cmoveq %rax, %r14
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x267e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2180
leaq -0x120(%rip), %rsi      # 0x2565
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x2872
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 0x26db
leaq 0x10(%rsp), %r12
leaq 0x4(%rsp), %r13
movl $0x5f5e100, 0x4(%rsp)   # imm = 0x5F5E100
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x28dc
decl %ebx
jne 0x26c1
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
cmpq %r14, %rbx
je 0x26f8
movq %rbx, %rdi
callq 0x2210
addq $0x8, %rbx
jmp 0x26e5
callq 0x2040
movq %rax, %rbx
movq 0x38d1(%rip), %rdi      # 0x5fd8
leaq 0x1903(%rip), %rsi      # 0x4011
movl $0x5, %edx
callq 0x2190
subq %r15, %rbx
movabsq $0x431bde82d7b634db, %rcx # imm = 0x431BDE82D7B634DB
movq %rbx, %rax
imulq %rcx
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x12, %rdx
addq %rdx, %rsi
movq 0x3898(%rip), %rdi      # 0x5fd8
callq 0x2150
movq %rax, %rbx
leaq 0x18c8(%rip), %rsi      # 0x4017
movl $0x1a, %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
leaq 0x39c6(%rip), %rdi      # 0x6150
callq 0x240c
movq 0x3842(%rip), %rdi      # 0x5fd8
movq %rax, %rsi
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
movq 0x39e9(%rip), %rsi      # 0x61b8
movq 0x3802(%rip), %rdi      # 0x5fd8
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 0x291e
cmpq $0x0, 0x8(%rsp)
jne 0x284e
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x283e
jmp 0x2831
jmp 0x2831
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x291e
cmpq $0x0, 0x8(%rsp)
jne 0x284e
movq %rbx, %rdi
callq 0x2230
callq 0x2050
nop