// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movq %rsi, %r14
movl %edi, %ebp
movl $0x1, %ebx
cmpl $0x2, %edi
jl 0x260b
movq 0x8(%r14), %rdi
callq 0x21f0
movl %eax, %ebx
leaq 0x38(%rsp), %r12
cmpl $0x3, %ebp
jl 0x2658
movq 0x10(%r14), %r14
leaq 0x28(%rsp), %r15
movq %r12, (%r15)
leaq 0x19e0(%rip), %rsi      # 0x4008
leaq 0x19e1(%rip), %rdx      # 0x4010
movq %r15, %rdi
callq 0x2da2
movq %r15, %rdi
movq %r14, %rsi
callq 0x2060
testl %eax, %eax
leaq -0x13c(%rip), %rax      # 0x250f
leaq -0x108(%rip), %r14      # 0x254a
cmoveq %rax, %r14
jmp 0x265f
leaq -0x150(%rip), %r14      # 0x250f
cmpl $0x3, %ebp
jl 0x267b
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x267b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2180
leaq -0x127(%rip), %rsi      # 0x255b
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x286e
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 0x26d8
leaq 0x10(%rsp), %r12
leaq 0x4(%rsp), %r13
movl $0x5f5e100, 0x4(%rsp)   # imm = 0x5F5E100
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x28e8
decl %ebx
jne 0x26be
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
cmpq %r14, %rbx
je 0x26f5
movq %rbx, %rdi
callq 0x2210
addq $0x8, %rbx
jmp 0x26e2
callq 0x2040
movq %rax, %rbx
movq 0x38d4(%rip), %rdi      # 0x5fd8
leaq 0x1906(%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 0x389b(%rip), %rdi      # 0x5fd8
callq 0x2150
movq %rax, %rbx
leaq 0x18cb(%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 0x39c9(%rip), %rdi      # 0x6150
callq 0x240c
movq 0x3845(%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 0x39ec(%rip), %rsi      # 0x61b8
movq 0x3805(%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 0x2924
cmpq $0x0, 0x8(%rsp)
jne 0x284b
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x283b
jmp 0x282e
jmp 0x282e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2924
cmpq $0x0, 0x8(%rsp)
jne 0x284b
movq %rbx, %rdi
callq 0x2230
callq 0x2050