#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*/ printf(char *, float);
int /*<<< orphan*/ sleep(int);
int main() {
  int i, n, chunk;
  float a[1000000], b[1000000], result;
  n = 1000000;
  chunk = 10;
  result = 0.0;
  for (i = 0; i < n; i++) {
    a[i] = i * 1.0;
    b[i] = i * 2.0;
  }
#pragma omp parallel for default(shared) private(i) schedule(static,chunk) reduction(+:result)
  for (i = 0; i < n; i++)
    result = result + (a[i] * b[i]);
  sleep(1);
  printf("Final result= %f\n", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7a1220,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xf4240,-0xc(%rbp)
movl   $0xa,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x7a1214(%rbp)
ff
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b0 <main+0x90>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe9d(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x8(%rbp),%rax
movss  %xmm0,-0x3d0910(%rbp,%rax,4)
c2 ff
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe73(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x8(%rbp),%rax
movss  %xmm0,-0x7a1210(%rbp,%rax,4)
85 ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1152 <main+0x32>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1203 <main+0xe3>
movss  -0x7a1214(%rbp),%xmm1
ff
movslq -0x8(%rbp),%rax
movss  -0x3d0910(%rbp,%rax,4),%xmm0
c2 ff
movslq -0x8(%rbp),%rax
movss  -0x7a1210(%rbp,%rax,4),%xmm2
85 ff
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x7a1214(%rbp)
ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b7 <main+0x97>
mov    $0x1,%edi
call   1040 <sleep@plt>
movss  -0x7a1214(%rbp),%xmm0
ff
lea    0xdf4(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7a1220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x7a1218,%rsp
movdqa 0xed1(%rip),%xmm0
mov    $0x4,%eax
movdqa 0xed4(%rip),%xmm1
movdqa 0xedc(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cvtdq2pd %xmm0,%xmm3
pshufd $0xee,%xmm0,%xmm4
cvtdq2pd %xmm4,%xmm4
cvtdq2ps %xmm0,%xmm5
movaps %xmm5,0x3d0900(%rsp,%rax,4)
addpd  %xmm3,%xmm3
cvtpd2ps %xmm3,%xmm3
addpd  %xmm4,%xmm4
cvtpd2ps %xmm4,%xmm4
unpcklpd %xmm4,%xmm3
movapd %xmm3,(%rsp,%rax,4)
movdqa %xmm0,%xmm3
paddd  %xmm1,%xmm3
cvtdq2pd %xmm3,%xmm4
pshufd $0xee,%xmm3,%xmm5
cvtdq2pd %xmm5,%xmm5
cvtdq2ps %xmm3,%xmm3
movaps %xmm3,0x3d0910(%rsp,%rax,4)
addpd  %xmm4,%xmm4
cvtpd2ps %xmm4,%xmm3
addpd  %xmm5,%xmm5
cvtpd2ps %xmm5,%xmm4
unpcklpd %xmm4,%xmm3
movapd %xmm3,0x10(%rsp,%rax,4)
paddd  %xmm2,%xmm0
add    $0x8,%rax
cmp    $0xf4244,%rax
jne    1150 <main+0x30>
xorpd  %xmm3,%xmm3
mov    $0x4,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movss  0x3d0900(%rsp,%rax,4),%xmm0
movss  0x3d0904(%rsp,%rax,4),%xmm1
mulss  (%rsp,%rax,4),%xmm0
mulss  0x4(%rsp,%rax,4),%xmm1
addss  %xmm3,%xmm0
movss  0x3d0908(%rsp,%rax,4),%xmm2
mulss  0x8(%rsp,%rax,4),%xmm2
addss  %xmm0,%xmm1
movss  0x3d090c(%rsp,%rax,4),%xmm0
mulss  0xc(%rsp,%rax,4),%xmm0
addss  %xmm1,%xmm2
movss  0x3d0910(%rsp,%rax,4),%xmm3
mulss  0x10(%rsp,%rax,4),%xmm3
addss  %xmm2,%xmm0
addss  %xmm0,%xmm3
add    $0x5,%rax
cmp    $0xf4244,%rax
jne    11e0 <main+0xc0>
mov    $0x1,%edi
movss  %xmm3,0xc(%rsp)
call   1040 <sleep@plt>
lea    0xdcf(%rip),%rdi
movss  0xc(%rsp),%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7a1218,%rsp
ret

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

LLVM IR (-O2):
@.str = [18 x i8] c"Final result= %f\0A\00"
define i32 @main() {
%1 = alloca [1000000 x float]
%2 = alloca [1000000 x float]
%3 = bitcast [1000000 x float]* %1 to i8*
%4 = bitcast [1000000 x float]* %2 to i8*
br label %5
5: ; preds = %5, %0
%6 = phi i64 [ 0, %0 ], [ %26, %5 ]
%7 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %0 ], [ %27, %5 ]
%8 = sitofp <4 x i32> %7 to <4 x double>
%9 = sitofp <4 x i32> %7 to <4 x float>
%10 = getelementptr inbounds [1000000 x float], [1000000 x float]* %1, i64 0, i64 %6
%11 = bitcast float* %10 to <4 x float>*
store <4 x float> %9, <4 x float>* %11
%12 = fmul <4 x double> %8, <double 2.000000e+00, double 2.000000e+00, double 2.000000e+00, double 2.000000e+00>
%13 = fptrunc <4 x double> %12 to <4 x float>
%14 = getelementptr inbounds [1000000 x float], [1000000 x float]* %2, i64 0, i64 %6
%15 = bitcast float* %14 to <4 x float>*
store <4 x float> %13, <4 x float>* %15
%16 = or i64 %6, 4
%17 = add <4 x i32> %7, <i32 4, i32 4, i32 4, i32 4>
%18 = sitofp <4 x i32> %17 to <4 x double>
%19 = sitofp <4 x i32> %17 to <4 x float>
%20 = getelementptr inbounds [1000000 x float], [1000000 x float]* %1, i64 0, i64 %16
%21 = bitcast float* %20 to <4 x float>*
store <4 x float> %19, <4 x float>* %21
%22 = fmul <4 x double> %18, <double 2.000000e+00, double 2.000000e+00, double 2.000000e+00, double 2.000000e+00>
%23 = fptrunc <4 x double> %22 to <4 x float>
%24 = getelementptr inbounds [1000000 x float], [1000000 x float]* %2, i64 0, i64 %16
%25 = bitcast float* %24 to <4 x float>*
store <4 x float> %23, <4 x float>* %25
%26 = add nuw nsw i64 %6, 8
%27 = add <4 x i32> %7, <i32 8, i32 8, i32 8, i32 8>
%28 = icmp eq i64 %26, 1000000
br i1 %28, label %29, label %5
29: ; preds = %5, %29
%30 = phi i64 [ %61, %29 ], [ 0, %5 ]
%31 = phi float [ %60, %29 ], [ 0.000000e+00, %5 ]
%32 = getelementptr inbounds [1000000 x float], [1000000 x float]* %1, i64 0, i64 %30
%33 = load float, float* %32
%34 = getelementptr inbounds [1000000 x float], [1000000 x float]* %2, i64 0, i64 %30
%35 = load float, float* %34
%36 = tail call float @llvm.fmuladd.f32(float %33, float %35, float %31)
%37 = add nuw nsw i64 %30, 1
%38 = getelementptr inbounds [1000000 x float], [1000000 x float]* %1, i64 0, i64 %37
%39 = load float, float* %38
%40 = getelementptr inbounds [1000000 x float], [1000000 x float]* %2, i64 0, i64 %37
%41 = load float, float* %40
%42 = tail call float @llvm.fmuladd.f32(float %39, float %41, float %36)
%43 = add nuw nsw i64 %30, 2
%44 = getelementptr inbounds [1000000 x float], [1000000 x float]* %1, i64 0, i64 %43
%45 = load float, float* %44
%46 = getelementptr inbounds [1000000 x float], [1000000 x float]* %2, i64 0, i64 %43
%47 = load float, float* %46
%48 = tail call float @llvm.fmuladd.f32(float %45, float %47, float %42)
%49 = add nuw nsw i64 %30, 3
%50 = getelementptr inbounds [1000000 x float], [1000000 x float]* %1, i64 0, i64 %49
%51 = load float, float* %50
%52 = getelementptr inbounds [1000000 x float], [1000000 x float]* %2, i64 0, i64 %49
%53 = load float, float* %52
%54 = tail call float @llvm.fmuladd.f32(float %51, float %53, float %48)
%55 = add nuw nsw i64 %30, 4
%56 = getelementptr inbounds [1000000 x float], [1000000 x float]* %1, i64 0, i64 %55
%57 = load float, float* %56
%58 = getelementptr inbounds [1000000 x float], [1000000 x float]* %2, i64 0, i64 %55
%59 = load float, float* %58
%60 = tail call float @llvm.fmuladd.f32(float %57, float %59, float %54)
%61 = add nuw nsw i64 %30, 5
%62 = icmp eq i64 %61, 1000000
br i1 %62, label %63, label %29
63: ; preds = %29
%64 = tail call i32 @sleep(i32 1)
%65 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), float %60)
ret i32 0
}