#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*/ printf(char *, double);
main() {
  int i, tid, NTHR;
  float a[100000], b[100000], c[100000];
  float sum = 0;
  for (i = 0; i < 100000; i++)
    a[i] = b[i] = i * 1.0;
  double start = omp_get_wtime();
  for (i = 0; i < 100000; i++)
    sum += 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    $0x124fb0,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x124f94(%rbp)
ff
movl   $0x0,-0x8(%rbp)
cmpl   $0x186a0,-0x8(%rbp)
jge    118e <main+0x6e>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xea2(%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    1144 <main+0x24>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x124fa0(%rbp)
ff
movl   $0x0,-0x8(%rbp)
cmpl   $0x186a0,-0x8(%rbp)
jge    11f1 <main+0xd1>
movslq -0x8(%rbp),%rax
movss  -0x61a90(%rbp,%rax,4),%xmm0
f9 ff
movslq -0x8(%rbp),%rax
movss  -0xc3510(%rbp,%rax,4),%xmm2
f3 ff
movss  -0x124f94(%rbp),%xmm1
ff
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x124f94(%rbp)
ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a4 <main+0x84>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x124fa8(%rbp)
ff
movsd  -0x124fa0(%rbp),%xmm0
ff
lea    0xdf9(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x124fa8(%rbp),%xmm0
ff
lea    0xdf6(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x124fa8(%rbp),%xmm0
ff
subsd  -0x124fa0(%rbp),%xmm0
ff
lea    0xde9(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x124fb0,%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    %eax,%eax
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xebb(%rip),%rdi
movsd  0x10(%rsp),%xmm0
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
lea    0xeab(%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 float
%9 = alloca double
%10 = alloca double
store i32 0, i32* %1
store float 0.000000e+00, float* %8
store i32 0, i32* %2
br label %11
11: ; preds = %25, %0
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 100000
br i1 %13, label %14, label %28
14: ; preds = %11
%15 = load i32, i32* %2
%16 = sitofp i32 %15 to double
%17 = fmul double %16, 1.000000e+00
%18 = fptrunc double %17 to float
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100000 x float], [100000 x float]* %6, i64 0, i64 %20
store float %18, float* %21
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [100000 x float], [100000 x float]* %5, i64 0, i64 %23
store float %18, float* %24
br label %25
25: ; preds = %14
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %11
28: ; preds = %11
%29 = call double (...) @omp_get_wtime()
store double %29, double* %9
store i32 0, i32* %2
br label %30
30: ; preds = %44, %28
%31 = load i32, i32* %2
%32 = icmp slt i32 %31, 100000
br i1 %32, label %33, label %47
33: ; preds = %30
%34 = load i32, i32* %2
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [100000 x float], [100000 x float]* %5, i64 0, i64 %35
%37 = load float, float* %36
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [100000 x float], [100000 x float]* %6, i64 0, i64 %39
%41 = load float, float* %40
%42 = load float, float* %8
%43 = call float @llvm.fmuladd.f32(float %37, float %41, float %42)
store float %43, float* %8
br label %44
44: ; preds = %33
%45 = load i32, i32* %2
%46 = add nsw i32 %45, 1
store i32 %46, i32* %2
br label %30
47: ; preds = %30
%48 = call double (...) @omp_get_wtime()
store double %48, double* %10
%49 = load double, double* %9
%50 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %49)
%51 = load double, double* %10
%52 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %51)
%53 = load double, double* %10
%54 = load double, double* %9
%55 = fsub double %53, %54
%56 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %55)
%57 = load i32, i32* %1
ret i32 %57
}

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 double (...) @omp_get_wtime()
%3 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %1)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %2)
%5 = fsub double %2, %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %5)
ret i32 0
}