#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 omp_get_thread_num();
double omp_get_wtime();
int /*<<< orphan*/ printf(char *, double, ...);
int main() {
  int sum = 0;
  int i;
  double start = omp_get_wtime();
#pragma omp parallel for schedule(dynamic) reduction(+ : sum) private(i)
  for (int j = 0; j < 16; ++j) {
    i = j;
    printf("thread %d has iteration %d\n", omp_get_thread_num(), i);
    sum += i;
  }
  printf("sum = %d\n", sum);
  double end = omp_get_wtime();
  printf("time = %f\n", end - start);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    119c <main+0x6c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
cvtsi2sd %eax,%xmm0
mov    -0xc(%rbp),%esi
lea    0xe82(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1159 <main+0x29>
cvtsi2sdl -0x8(%rbp),%xmm0
lea    0xe74(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xe5a(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xeb1(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0xb,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0xc,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0xd,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0xe,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %rbx,%rdi
mov    $0xf,%esi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xd07(%rip),%rdi
movsd  0xcdb(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
subsd  0x8(%rsp),%xmm0
lea    0xcee(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"thread %d has iteration %d\0A\00"
@.str.1 = [10 x i8] c"sum = %d\0A\00"
@.str.2 = [11 x i8] c"time = %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca i32
%6 = alloca double
store i32 0, i32* %1
store i32 0, i32* %2
%7 = call double (...) @omp_get_wtime()
store double %7, double* %4
store i32 0, i32* %5
br label %8
8: ; preds = %20, %0
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 16
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load i32, i32* %5
store i32 %12, i32* %3
%13 = call i32 (...) @omp_get_thread_num()
%14 = sitofp i32 %13 to double
%15 = load i32, i32* %3
%16 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %14, i32 %15)
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = add nsw i32 %18, %17
store i32 %19, i32* %2
br label %20
20: ; preds = %11
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %8
23: ; preds = %8
%24 = load i32, i32* %2
%25 = sitofp i32 %24 to double
%26 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %25)
%27 = call double (...) @omp_get_wtime()
store double %27, double* %6
%28 = load double, double* %6
%29 = load double, double* %4
%30 = fsub double %28, %29
%31 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"thread %d has iteration %d\0A\00"
@.str.1 = [10 x i8] c"sum = %d\0A\00"
@.str.2 = [11 x i8] c"time = %f\0A\00"
define i32 @main() {
%1 = tail call double (...) @omp_get_wtime()
%2 = tail call i32 (...) @omp_get_thread_num()
%3 = sitofp i32 %2 to double
%4 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %3, i32 0)
%5 = tail call i32 (...) @omp_get_thread_num()
%6 = sitofp i32 %5 to double
%7 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %6, i32 1)
%8 = tail call i32 (...) @omp_get_thread_num()
%9 = sitofp i32 %8 to double
%10 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %9, i32 2)
%11 = tail call i32 (...) @omp_get_thread_num()
%12 = sitofp i32 %11 to double
%13 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %12, i32 3)
%14 = tail call i32 (...) @omp_get_thread_num()
%15 = sitofp i32 %14 to double
%16 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %15, i32 4)
%17 = tail call i32 (...) @omp_get_thread_num()
%18 = sitofp i32 %17 to double
%19 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %18, i32 5)
%20 = tail call i32 (...) @omp_get_thread_num()
%21 = sitofp i32 %20 to double
%22 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %21, i32 6)
%23 = tail call i32 (...) @omp_get_thread_num()
%24 = sitofp i32 %23 to double
%25 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %24, i32 7)
%26 = tail call i32 (...) @omp_get_thread_num()
%27 = sitofp i32 %26 to double
%28 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %27, i32 8)
%29 = tail call i32 (...) @omp_get_thread_num()
%30 = sitofp i32 %29 to double
%31 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %30, i32 9)
%32 = tail call i32 (...) @omp_get_thread_num()
%33 = sitofp i32 %32 to double
%34 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %33, i32 10)
%35 = tail call i32 (...) @omp_get_thread_num()
%36 = sitofp i32 %35 to double
%37 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %36, i32 11)
%38 = tail call i32 (...) @omp_get_thread_num()
%39 = sitofp i32 %38 to double
%40 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %39, i32 12)
%41 = tail call i32 (...) @omp_get_thread_num()
%42 = sitofp i32 %41 to double
%43 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %42, i32 13)
%44 = tail call i32 (...) @omp_get_thread_num()
%45 = sitofp i32 %44 to double
%46 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %45, i32 14)
%47 = tail call i32 (...) @omp_get_thread_num()
%48 = sitofp i32 %47 to double
%49 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %48, i32 15)
%50 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double 1.200000e+02)
%51 = tail call double (...) @omp_get_wtime()
%52 = fsub double %51, %1
%53 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %52)
ret i32 0
}