#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*/ atoi(char *);
int /*<<< orphan*/ initialize(int *, int);
int /*<<< orphan*/ omp_set_num_threads(int /*<<< orphan*/);
int parallelSum(int *, int);
int /*<<< orphan*/ printf(char *, int, int);
int sequentialSum(int *, int);
int main(int argc, char **argv) {
  int array[1000000];
  if (argc > 1) {
    omp_set_num_threads(atoi(argv[1]));
  }
  initialize(array, 1000000);
  printf("\nSeq. sum: \t%d\nPar. sum: \t%d\n\n", sequentialSum(array, 1000000),
         parallelSum(array, 1000000));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3d0920,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1197 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1070 <omp_set_num_threads@plt>
lea    -0x3d0910(%rbp),%rdi
mov    $0xf4240,%esi
call   1050 <initialize@plt>
lea    -0x3d0910(%rbp),%rdi
mov    $0xf4240,%esi
call   1060 <sequentialSum@plt>
mov    %eax,-0x3d0914(%rbp)
lea    -0x3d0910(%rbp),%rdi
mov    $0xf4240,%esi
call   1030 <parallelSum@plt>
mov    -0x3d0914(%rbp),%esi
mov    %eax,%edx
lea    0xe21(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x3d0920,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x3d0908,%rsp
cmp    $0x2,%edi
jl     117e <main+0x1e>
mov    0x8(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%edi
call   1070 <omp_set_num_threads@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xf4240,%esi
call   1050 <initialize@plt>
mov    %rbx,%rdi
mov    $0xf4240,%esi
call   1060 <sequentialSum@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0xf4240,%esi
call   1030 <parallelSum@plt>
lea    0xe4f(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x3d0908,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"\0ASeq. sum: \09%d\0APar. sum: \09%d\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000000 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @atoi(i8* %12)
%14 = call i32 @omp_set_num_threads(i32 %13)
br label %15
15: ; preds = %9, %2
%16 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %6, i64 0, i64 0
%17 = call i32 @initialize(i32* %16, i32 1000000)
%18 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %6, i64 0, i64 0
%19 = call i32 @sequentialSum(i32* %18, i32 1000000)
%20 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %6, i64 0, i64 0
%21 = call i32 @parallelSum(i32* %20, i32 1000000)
%22 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"\0ASeq. sum: \09%d\0APar. sum: \09%d\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000000 x i32]
%4 = bitcast [1000000 x i32]* %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %11
6: ; preds = %2
%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)
br label %11
11: ; preds = %6, %2
%12 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %3, i64 0, i64 0
%13 = call i32 @initialize(i32* %12, i32 1000000)
%14 = call i32 @sequentialSum(i32* %12, i32 1000000)
%15 = call i32 @parallelSum(i32* %12, i32 1000000)
%16 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15)
ret i32 0
}