#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 */
typedef scalar_t__ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ bomp_bomp_init(int /*<<< orphan*/);
int /*<<< orphan*/ omp_set_num_threads(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, scalar_t__);
scalar_t__ rdtsc();
int main(int argc, char *argv[]) {
  uint64_t begin, end;
  int i;
  static int a[10000000];
  assert(argc == 2);
  bomp_bomp_init(atoi(argv[1]));
  omp_set_num_threads(atoi(argv[1]));
  for (i = 0; i < 10000000; i++)
    a[i] = 2 * i;
  begin = rdtsc();
#pragma omp parallel for
  for (i = 0; i < 10000000; i++)
    a[i] = 2 * i;
  end = rdtsc();
  printf("Value of sum is %d, time taken %lu\n", 0, end - begin);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1060 <bomp_bomp_init@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1070 <omp_set_num_threads@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x989680,-0x24(%rbp)
jge    11e5 <main+0x85>
mov    -0x24(%rbp),%edx
shl    $0x1,%edx
movslq -0x24(%rbp),%rcx
lea    0x2e8c(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b6 <main+0x56>
mov    $0x0,%al
call   1040 <rdtsc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x989680,-0x24(%rbp)
jge    1226 <main+0xc6>
mov    -0x24(%rbp),%edx
shl    $0x1,%edx
movslq -0x24(%rbp),%rcx
lea    0x2e4b(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f7 <main+0x97>
mov    $0x0,%al
call   1040 <rdtsc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
sub    -0x18(%rbp),%rdx
lea    0xdc0(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
xor    %eax,%eax
cmp    $0x2,%edi
sete   %al
mov    %eax,%edi
call   1050 <assert@plt>
mov    0x8(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1060 <bomp_bomp_init@plt>
mov    0x8(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1070 <omp_set_num_threads@plt>
xor    %eax,%eax
call   1040 <rdtsc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <rdtsc@plt>
sub    %rbx,%rax
lea    0xe52(%rip),%rdi
xor    %esi,%esi
mov    %rax,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@main.a = internal global [10000000 x i32] zeroinitializer
@.str = [36 x i8] c"Value of sum is %d, time taken %lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 2
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
%17 = call i32 @bomp_bomp_init(i32 %16)
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
%22 = call i32 @omp_set_num_threads(i32 %21)
store i32 0, i32* %8
br label %23
23: ; preds = %32, %2
%24 = load i32, i32* %8
%25 = icmp slt i32 %24, 10000000
br i1 %25, label %26, label %35
26: ; preds = %23
%27 = load i32, i32* %8
%28 = mul nsw i32 2, %27
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @main.a, i64 0, i64 %30
store i32 %28, i32* %31
br label %32
32: ; preds = %26
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
store i32 %34, i32* %8
br label %23
35: ; preds = %23
%36 = call i64 (...) @rdtsc()
store i64 %36, i64* %6
store i32 0, i32* %8
br label %37
37: ; preds = %46, %35
%38 = load i32, i32* %8
%39 = icmp slt i32 %38, 10000000
br i1 %39, label %40, label %49
40: ; preds = %37
%41 = load i32, i32* %8
%42 = mul nsw i32 2, %41
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @main.a, i64 0, i64 %44
store i32 %42, i32* %45
br label %46
46: ; preds = %40
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %37
49: ; preds = %37
%50 = call i64 (...) @rdtsc()
store i64 %50, i64* %7
%51 = load i64, i64* %7
%52 = load i64, i64* %6
%53 = sub nsw i64 %51, %52
%54 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 0, i64 %53)
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@.str = [36 x i8] c"Value of sum is %d, time taken %lu\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @atoi(i8* %7)
%9 = tail call i32 @bomp_bomp_init(i32 %8)
%10 = load i8*, i8** %6
%11 = tail call i32 @atoi(i8* %10)
%12 = tail call i32 @omp_set_num_threads(i32 %11)
%13 = tail call i64 (...) @rdtsc()
%14 = tail call i64 (...) @rdtsc()
%15 = sub nsw i64 %14, %13
%16 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 0, i64 %15)
ret i32 0
}