#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 /*<<< orphan*/ barrierDriver(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ runBarrier(int, int, int);
int main(int argc, char *argv[]) {
  int totalReps = 1000;
  if (argc != 2) {
    printf("Calling Barrier driver\n");
    barrierDriver(totalReps);
  } else {
    printf("Running barrier benchmark\n");
    runBarrier(totalReps, 1, 0);
    runBarrier(totalReps, 1, 1);
  }
}


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   $0x3e8,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1170 <main+0x40>
lea    0xea2(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1030 <barrierDriver@plt>
jmp    119a <main+0x6a>
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <runBarrier@plt>
mov    -0x14(%rbp),%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <runBarrier@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    1169 <main+0x39>
lea    0xec3(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3e8,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1050 <runBarrier@plt>
mov    $0x3e8,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1050 <runBarrier@plt>
jmp    117f <main+0x4f>
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3e8,%edi
call   1030 <barrierDriver@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Calling Barrier driver\0A\00"
@.str.1 = [27 x i8] c"Running barrier benchmark\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1000, i32* %6
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* %6
%12 = call i32 @barrierDriver(i32 %11)
br label %19
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* %6
%16 = call i32 @runBarrier(i32 %15, i32 1, i32 0)
%17 = load i32, i32* %6
%18 = call i32 @runBarrier(i32 %17, i32 1, i32 1)
br label %19
19: ; preds = %13, %9
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@str = [26 x i8] c"Running barrier benchmark\00"
@str.2 = [23 x i8] c"Calling Barrier driver\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.2, i64 0, i64 0))
%6 = tail call i32 @barrierDriver(i32 1000)
br label %11
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @runBarrier(i32 1000, i32 1, i32 0)
%10 = tail call i32 @runBarrier(i32 1000, i32 1, i32 1)
br label %11
11: ; preds = %7, %4
ret i32 0
}