#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 */
struct timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, long, long);
int /*<<< orphan*/ timersub(struct timeval *, struct timeval *,
                            struct timeval *);
int main(int argc, char *argv[]) {
  struct timeval start_time, end_time, wall_time;
  gettimeofday(&start_time, NULL);
  int N = atoi(argv[1]);
  int a[N], i;
  for (i = 0; i < N; i++)
    a[i] = 1;
  int sum = 0;
#pragma omp parallel for reduction(+ : sum)
  for (i = 0; i < N; i++)
    sum += a[i];
  gettimeofday(&end_time, NULL);
  timersub(&end_time, &start_time, &wall_time);
  printf("%ld.%08ld\n", (long int)wall_time.tv_sec,
         (long int)wall_time.tv_usec);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%esi
lea    -0x20(%rbp),%rdi
call   1040 <gettimeofday@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    11ca <main+0x8a>
mov    -0x68(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11a1 <main+0x61>
movl   $0x0,-0x60(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1203 <main+0xc3>
mov    -0x68(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x60(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11d8 <main+0x98>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
lea    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1060 <timersub@plt>
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
lea    0xdd0(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
lea    0x20(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    %rsp,%r15
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <timersub@plt>
mov    (%rsp),%rdx
mov    0x8(%rsp),%rsi
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    %r15,%rsp
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@.str = [11 x i8] c"%ld.%08ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca %struct.timeval
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%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* %9
%19 = load i32, i32* %9
%20 = zext i32 %19 to i64
%21 = call i8* @llvm.stacksave()
store i8* %21, i8** %10
%22 = alloca i32, i64 %20
store i64 %20, i64* %11
store i32 0, i32* %12
br label %23
23: ; preds = %31, %2
%24 = load i32, i32* %12
%25 = load i32, i32* %9
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %34
27: ; preds = %23
%28 = load i32, i32* %12
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %22, i64 %29
store i32 1, i32* %30
br label %31
31: ; preds = %27
%32 = load i32, i32* %12
%33 = add nsw i32 %32, 1
store i32 %33, i32* %12
br label %23
34: ; preds = %23
store i32 0, i32* %13
store i32 0, i32* %12
br label %35
35: ; preds = %46, %34
%36 = load i32, i32* %12
%37 = load i32, i32* %9
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %49
39: ; preds = %35
%40 = load i32, i32* %12
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %22, i64 %41
%43 = load i32, i32* %42
%44 = load i32, i32* %13
%45 = add nsw i32 %44, %43
store i32 %45, i32* %13
br label %46
46: ; preds = %39
%47 = load i32, i32* %12
%48 = add nsw i32 %47, 1
store i32 %48, i32* %12
br label %35
49: ; preds = %35
%50 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%51 = call i32 @timersub(%struct.timeval* %7, %struct.timeval* %6, %struct.timeval* %8)
%52 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%53 = load i64, i64* %52
%54 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%55 = load i64, i64* %54
%56 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %53, i64 %55)
store i32 0, i32* %3
%57 = load i8*, i8** %10
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@.str = [11 x i8] c"%ld.%08ld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = bitcast %struct.timeval* %3 to i8*
%7 = bitcast %struct.timeval* %4 to i8*
%8 = bitcast %struct.timeval* %5 to i8*
%9 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%10 = tail call i8* @llvm.stacksave()
%11 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%12 = call i32 @timersub(%struct.timeval* %4, %struct.timeval* %3, %struct.timeval* %5)
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%14 = load i64, i64* %13
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%16 = load i64, i64* %15
%17 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 %14, i64 %16)
ret i32 0
}