#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_custom_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];
  bomp_custom_init(NULL);
  assert(argc == 2);
  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)
xor    %eax,%eax
mov    %eax,%edi
call   1030 <bomp_custom_init@plt>
cmpl   $0x2,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@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    11da <main+0x7a>
mov    -0x24(%rbp),%edx
shl    $0x1,%edx
movslq -0x24(%rbp),%rcx
lea    0x2e97(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ab <main+0x4b>
mov    $0x0,%al
call   1050 <rdtsc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x989680,-0x24(%rbp)
jge    121b <main+0xbb>
mov    -0x24(%rbp),%edx
shl    $0x1,%edx
movslq -0x24(%rbp),%rcx
lea    0x2e56(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ec <main+0x8c>
mov    $0x0,%al
call   1050 <rdtsc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
sub    -0x18(%rbp),%rdx
lea    0xdcb(%rip),%rdi
xor    %esi,%esi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
call   1030 <bomp_custom_init@plt>
xor    %edi,%edi
cmp    $0x2,%ebp
sete   %dil
call   1060 <assert@plt>
mov    0x8(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1070 <omp_set_num_threads@plt>
xor    %eax,%eax
call   1050 <rdtsc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <rdtsc@plt>
sub    %rbx,%rax
lea    0xe58(%rip),%rdi
xor    %esi,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
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 = call i32 @bomp_custom_init(i32* null)
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 2
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
%18 = call i32 @omp_set_num_threads(i32 %17)
store i32 0, i32* %8
br label %19
19: ; preds = %28, %2
%20 = load i32, i32* %8
%21 = icmp slt i32 %20, 10000000
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = load i32, i32* %8
%24 = mul nsw i32 2, %23
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @main.a, i64 0, i64 %26
store i32 %24, i32* %27
br label %28
28: ; preds = %22
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %19
31: ; preds = %19
%32 = call i64 (...) @rdtsc()
store i64 %32, i64* %6
store i32 0, i32* %8
br label %33
33: ; preds = %42, %31
%34 = load i32, i32* %8
%35 = icmp slt i32 %34, 10000000
br i1 %35, label %36, label %45
36: ; preds = %33
%37 = load i32, i32* %8
%38 = mul nsw i32 2, %37
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @main.a, i64 0, i64 %40
store i32 %38, i32* %41
br label %42
42: ; preds = %36
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %33
45: ; preds = %33
%46 = call i64 (...) @rdtsc()
store i64 %46, i64* %7
%47 = load i64, i64* %7
%48 = load i64, i64* %6
%49 = sub nsw i64 %47, %48
%50 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 0, i64 %49)
%51 = load i32, i32* %3
ret i32 %51
}

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 = tail call i32 @bomp_custom_init(i32* null)
%4 = icmp eq i32 %0, 2
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = tail call i32 @omp_set_num_threads(i32 %9)
%11 = tail call i64 (...) @rdtsc()
%12 = tail call i64 (...) @rdtsc()
%13 = sub nsw i64 %12, %11
%14 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 0, i64 %13)
ret i32 0
}