#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 */
double omp_get_wtime();
int /*<<< orphan*/ omp_set_dynamic(int /*<<< orphan*/);
int /*<<< orphan*/ omp_set_num_threads(int);
int /*<<< orphan*/ printf(char *, double);
main() {
  int i, tid, NTHR;
  float a[100000], b[100000], c[100000];
  for (i = 0; i < 100000; i++)
    a[i] = b[i] = i * 1.0;
  double start = omp_get_wtime();
  omp_set_dynamic(0);
  omp_set_num_threads(4);
#pragma omp parallel shared(a, b, c) private(i)
  {
#pragma omp for schedule(static)
    for (i = 0; i < 100000; i++)
      c[i] = a[i] + b[i];
  }
  double end = omp_get_wtime();
  printf("start time = %f\n", start);
  printf("end time = %f\n", end);
  printf("diff time = %f\n", end - start);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x124fa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x186a0,-0x8(%rbp)
jge    11a3 <main+0x63>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe8d(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x8(%rbp),%rax
movss  %xmm0,-0xc3510(%rbp,%rax,4)
f3 ff
movslq -0x8(%rbp),%rax
movss  %xmm0,-0x61a90(%rbp,%rax,4)
f9 ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1159 <main+0x19>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x124f98(%rbp)
ff
xor    %edi,%edi
call   1050 <omp_set_dynamic@plt>
mov    $0x4,%edi
call   1060 <omp_set_num_threads@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x186a0,-0x8(%rbp)
jge    120c <main+0xcc>
movslq -0x8(%rbp),%rax
movss  -0x61a90(%rbp,%rax,4),%xmm0
f9 ff
movslq -0x8(%rbp),%rax
addss  -0xc3510(%rbp,%rax,4),%xmm0
f3 ff
movslq -0x8(%rbp),%rax
movss  %xmm0,-0x124f90(%rbp,%rax,4)
ed ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ca <main+0x8a>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x124fa0(%rbp)
ff
movsd  -0x124f98(%rbp),%xmm0
ff
lea    0xdde(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x124fa0(%rbp),%xmm0
ff
lea    0xddb(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x124fa0(%rbp),%xmm0
ff
subsd  -0x124f98(%rbp),%xmm0
ff
lea    0xdce(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x124fa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,0x10(%rsp)
xor    %edi,%edi
call   1050 <omp_set_dynamic@plt>
mov    $0x4,%edi
call   1060 <omp_set_num_threads@plt>
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe8a(%rip),%rdi
movsd  0x10(%rsp),%xmm0
call   1040 <printf@plt>
lea    0xe89(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"start time = %f\0A\00"
@.str.1 = [15 x i8] c"end time = %f\0A\00"
@.str.2 = [16 x i8] c"diff time = %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100000 x float]
%6 = alloca [100000 x float]
%7 = alloca [100000 x float]
%8 = alloca double
%9 = alloca double
store i32 0, i32* %1
store i32 0, i32* %2
br label %10
10: ; preds = %24, %0
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 100000
br i1 %12, label %13, label %27
13: ; preds = %10
%14 = load i32, i32* %2
%15 = sitofp i32 %14 to double
%16 = fmul double %15, 1.000000e+00
%17 = fptrunc double %16 to float
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100000 x float], [100000 x float]* %6, i64 0, i64 %19
store float %17, float* %20
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [100000 x float], [100000 x float]* %5, i64 0, i64 %22
store float %17, float* %23
br label %24
24: ; preds = %13
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %10
27: ; preds = %10
%28 = call double (...) @omp_get_wtime()
store double %28, double* %8
%29 = call i32 @omp_set_dynamic(i32 0)
%30 = call i32 @omp_set_num_threads(i32 4)
store i32 0, i32* %2
br label %31
31: ; preds = %47, %27
%32 = load i32, i32* %2
%33 = icmp slt i32 %32, 100000
br i1 %33, label %34, label %50
34: ; preds = %31
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [100000 x float], [100000 x float]* %5, i64 0, i64 %36
%38 = load float, float* %37
%39 = load i32, i32* %2
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [100000 x float], [100000 x float]* %6, i64 0, i64 %40
%42 = load float, float* %41
%43 = fadd float %38, %42
%44 = load i32, i32* %2
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [100000 x float], [100000 x float]* %7, i64 0, i64 %45
store float %43, float* %46
br label %47
47: ; preds = %34
%48 = load i32, i32* %2
%49 = add nsw i32 %48, 1
store i32 %49, i32* %2
br label %31
50: ; preds = %31
%51 = call double (...) @omp_get_wtime()
store double %51, double* %9
%52 = load double, double* %8
%53 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %52)
%54 = load double, double* %9
%55 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %54)
%56 = load double, double* %9
%57 = load double, double* %8
%58 = fsub double %56, %57
%59 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %58)
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@.str = [17 x i8] c"start time = %f\0A\00"
@.str.1 = [15 x i8] c"end time = %f\0A\00"
@.str.2 = [16 x i8] c"diff time = %f\0A\00"
define i32 @main() {
%1 = tail call double (...) @omp_get_wtime()
%2 = tail call i32 @omp_set_dynamic(i32 0)
%3 = tail call i32 @omp_set_num_threads(i32 4)
%4 = tail call double (...) @omp_get_wtime()
%5 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %1)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %4)
%7 = fsub double %4, %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %7)
ret i32 0
}