#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ enqueue(int);
int /*<<< orphan*/ initialize_queue();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ testMultiThreaded(int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  int N = 2;
  srand(time(NULL));
  if (argv[1]) {
    N = atoi(argv[1]);
  }
  initialize_queue();
  for (int i = 0; i < 100; ++i) {
    enqueue(42);
  }
  testMultiThreaded(N);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11ac <main+0x4c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <initialize_queue@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x64,-0x18(%rbp)
jge    11dc <main+0x7c>
mov    $0x2a,%edi
call   1080 <enqueue@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ba <main+0x5a>
mov    -0x14(%rbp),%edi
call   1070 <testMultiThreaded@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    0x8(%rbx),%rdi
test   %rdi,%rdi
je     1186 <main+0x26>
call   1060 <atoi@plt>
mov    %eax,%ebx
jmp    118b <main+0x2b>
mov    $0x2,%ebx
xor    %eax,%eax
call   1030 <initialize_queue@plt>
mov    $0x64,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1080 <enqueue@plt>
add    $0xffffffff,%ebp
jne    11a0 <main+0x40>
mov    %ebx,%edi
call   1070 <testMultiThreaded@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 2, i32* %6
%8 = call i32 @time(i32* null)
%9 = call i32 @srand(i32 %8)
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %6
br label %19
19: ; preds = %14, %2
%20 = call i32 (...) @initialize_queue()
store i32 0, i32* %7
br label %21
21: ; preds = %26, %19
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 100
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = call i32 @enqueue(i32 42)
br label %26
26: ; preds = %24
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %21
29: ; preds = %21
%30 = load i32, i32* %6
%31 = call i32 @testMultiThreaded(i32 %30)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @atoi(i8* %6)
br label %10
10: ; preds = %8, %2
%11 = phi i32 [ %9, %8 ], [ 2, %2 ]
%12 = tail call i32 (...) @initialize_queue()
br label %15
13: ; preds = %15
%14 = tail call i32 @testMultiThreaded(i32 %11)
ret i32 0
15: ; preds = %10, %15
%16 = phi i32 [ 0, %10 ], [ %18, %15 ]
%17 = tail call i32 @enqueue(i32 42)
%18 = add nuw nsw i32 %16, 1
%19 = icmp eq i32 %18, 100
br i1 %19, label %13, label %15
}