#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*/ exit(int /*<<< orphan*/);
int omp_get_num_threads();
int omp_get_thread_num();
int /*<<< orphan*/ printf(char *, double);
int main(int argc, char *argv[]) {
  double a[100], b[100];
  double localsum, sum = 0.0;
  int i, tid, nthreads;
#pragma omp parallel shared(a, b, sum) private(i, localsum)
  {
    tid = omp_get_thread_num();
#pragma omp master
    {
      nthreads = omp_get_num_threads();
      printf("Number of threads = %d\n", nthreads);
    }
#pragma omp for
    for (i = 0; i < 100; i++)
      a[i] = b[i] = (double)i;
    localsum = 0.0;
#pragma omp for
    for (i = 0; i < 100; i++)
      localsum = localsum + (a[i] * b[i]);
#pragma omp critical
    sum = sum + localsum;
  }
  printf("   Sum = %2.1f\n", sum);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x670,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x660(%rbp)
ff
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x668(%rbp)
mov    $0x0,%al
call   1050 <omp_get_num_threads@plt>
mov    %eax,-0x66c(%rbp)
cvtsi2sdl -0x66c(%rbp),%xmm0
ff
lea    0xe73(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x664(%rbp)
cmpl   $0x64,-0x664(%rbp)
jge    11e5 <main+0xa5>
cvtsi2sdl -0x664(%rbp),%xmm0
ff
movslq -0x664(%rbp),%rax
movsd  %xmm0,-0x650(%rbp,%rax,8)
ff ff
movslq -0x664(%rbp),%rax
movsd  %xmm0,-0x330(%rbp,%rax,8)
ff ff
mov    -0x664(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x664(%rbp)
jmp    119c <main+0x5c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x658(%rbp)
ff
movl   $0x0,-0x664(%rbp)
cmpl   $0x64,-0x664(%rbp)
jge    1253 <main+0x113>
movsd  -0x658(%rbp),%xmm1
ff
movslq -0x664(%rbp),%rax
movsd  -0x330(%rbp,%rax,8),%xmm0
ff ff
movslq -0x664(%rbp),%rax
movsd  -0x650(%rbp,%rax,8),%xmm2
ff ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x658(%rbp)
ff
mov    -0x664(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x664(%rbp)
jmp    11fa <main+0xba>
movsd  -0x660(%rbp),%xmm0
ff
addsd  -0x658(%rbp),%xmm0
ff
movsd  %xmm0,-0x660(%rbp)
ff
movsd  -0x660(%rbp),%xmm0
ff
lea    0xd9e(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x648,%rsp
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
cvtsi2sd %eax,%xmm0
lea    0xf00(%rip),%rdi
call   1040 <printf@plt>
movdqa 0xe93(%rip),%xmm0
mov    $0x8,%eax
movdqa 0xe96(%rip),%xmm1
movdqa 0xe9e(%rip),%xmm2
movdqa 0xea6(%rip),%xmm3
movdqa 0xeae(%rip),%xmm4
movdqa 0xeb6(%rip),%xmm5
nopw   0x0(%rax,%rax,1)
cvtdq2pd %xmm0,%xmm6
movaps %xmm6,-0x40(%rsp,%rax,8)
movaps %xmm6,0x2e0(%rsp,%rax,8)
movdqa %xmm0,%xmm6
paddd  %xmm1,%xmm6
cvtdq2pd %xmm6,%xmm6
movaps %xmm6,-0x30(%rsp,%rax,8)
movdqa %xmm0,%xmm7
paddd  %xmm2,%xmm7
cvtdq2pd %xmm7,%xmm7
movaps %xmm6,0x2f0(%rsp,%rax,8)
movaps %xmm7,-0x20(%rsp,%rax,8)
movaps %xmm7,0x300(%rsp,%rax,8)
movdqa %xmm0,%xmm6
paddd  %xmm3,%xmm6
cvtdq2pd %xmm6,%xmm6
movaps %xmm6,-0x10(%rsp,%rax,8)
movaps %xmm6,0x310(%rsp,%rax,8)
movdqa %xmm0,%xmm6
paddd  %xmm4,%xmm6
cvtdq2pd %xmm6,%xmm6
movaps %xmm6,(%rsp,%rax,8)
movaps %xmm6,0x320(%rsp,%rax,8)
paddd  %xmm5,%xmm0
add    $0xa,%rax
cmp    $0x6c,%rax
jne    11a0 <main+0x60>
pxor   %xmm0,%xmm0
mov    $0x4,%eax
nop
movsd  0x300(%rsp,%rax,8),%xmm1
movsd  0x308(%rsp,%rax,8),%xmm2
mulsd  -0x20(%rsp,%rax,8),%xmm1
mulsd  -0x18(%rsp,%rax,8),%xmm2
addsd  %xmm0,%xmm1
movsd  0x310(%rsp,%rax,8),%xmm3
mulsd  -0x10(%rsp,%rax,8),%xmm3
addsd  %xmm1,%xmm2
movsd  0x318(%rsp,%rax,8),%xmm1
mulsd  -0x8(%rsp,%rax,8),%xmm1
addsd  %xmm2,%xmm3
movsd  0x320(%rsp,%rax,8),%xmm0
mulsd  (%rsp,%rax,8),%xmm0
addsd  %xmm3,%xmm1
addsd  %xmm1,%xmm0
add    $0x5,%rax
cmp    $0x68,%rax
jne    1230 <main+0xf0>
pxor   %xmm1,%xmm1
addsd  %xmm1,%xmm0
lea    0xdd1(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Number of threads = %d\0A\00"
@.str.1 = [16 x i8] c" Sum = %2.1f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x double]
%7 = alloca [100 x double]
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %9
%13 = call i32 (...) @omp_get_thread_num()
store i32 %13, i32* %11
%14 = call i32 (...) @omp_get_num_threads()
store i32 %14, i32* %12
%15 = load i32, i32* %12
%16 = sitofp i32 %15 to double
%17 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), double %16)
store i32 0, i32* %10
br label %18
18: ; preds = %30, %2
%19 = load i32, i32* %10
%20 = icmp slt i32 %19, 100
br i1 %20, label %21, label %33
21: ; preds = %18
%22 = load i32, i32* %10
%23 = sitofp i32 %22 to double
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x double], [100 x double]* %7, i64 0, i64 %25
store double %23, double* %26
%27 = load i32, i32* %10
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x double], [100 x double]* %6, i64 0, i64 %28
store double %23, double* %29
br label %30
30: ; preds = %21
%31 = load i32, i32* %10
%32 = add nsw i32 %31, 1
store i32 %32, i32* %10
br label %18
33: ; preds = %18
store double 0.000000e+00, double* %8
store i32 0, i32* %10
br label %34
34: ; preds = %48, %33
%35 = load i32, i32* %10
%36 = icmp slt i32 %35, 100
br i1 %36, label %37, label %51
37: ; preds = %34
%38 = load double, double* %8
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [100 x double], [100 x double]* %6, i64 0, i64 %40
%42 = load double, double* %41
%43 = load i32, i32* %10
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [100 x double], [100 x double]* %7, i64 0, i64 %44
%46 = load double, double* %45
%47 = call double @llvm.fmuladd.f64(double %42, double %46, double %38)
store double %47, double* %8
br label %48
48: ; preds = %37
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
store i32 %50, i32* %10
br label %34
51: ; preds = %34
%52 = load double, double* %9
%53 = load double, double* %8
%54 = fadd double %52, %53
store double %54, double* %9
%55 = load double, double* %9
%56 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %55)
%57 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [24 x i8] c"Number of threads = %d\0A\00"
@.str.1 = [16 x i8] c" Sum = %2.1f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x double]
%4 = alloca [100 x double]
%5 = bitcast [100 x double]* %3 to i8*
%6 = bitcast [100 x double]* %4 to i8*
%7 = tail call i32 (...) @omp_get_thread_num()
%8 = tail call i32 (...) @omp_get_num_threads()
%9 = sitofp i32 %8 to double
%10 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), double %9)
br label %11
11: ; preds = %11, %2
%12 = phi i64 [ 0, %2 ], [ %47, %11 ]
%13 = phi <2 x i32> [ <i32 0, i32 1>, %2 ], [ %48, %11 ]
%14 = sitofp <2 x i32> %13 to <2 x double>
%15 = getelementptr inbounds [100 x double], [100 x double]* %4, i64 0, i64 %12
%16 = bitcast double* %15 to <2 x double>*
store <2 x double> %14, <2 x double>* %16
%17 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %12
%18 = bitcast double* %17 to <2 x double>*
store <2 x double> %14, <2 x double>* %18
%19 = add nuw nsw i64 %12, 2
%20 = add <2 x i32> %13, <i32 2, i32 2>
%21 = sitofp <2 x i32> %20 to <2 x double>
%22 = getelementptr inbounds [100 x double], [100 x double]* %4, i64 0, i64 %19
%23 = bitcast double* %22 to <2 x double>*
store <2 x double> %21, <2 x double>* %23
%24 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %19
%25 = bitcast double* %24 to <2 x double>*
store <2 x double> %21, <2 x double>* %25
%26 = add nuw nsw i64 %12, 4
%27 = add <2 x i32> %13, <i32 4, i32 4>
%28 = sitofp <2 x i32> %27 to <2 x double>
%29 = getelementptr inbounds [100 x double], [100 x double]* %4, i64 0, i64 %26
%30 = bitcast double* %29 to <2 x double>*
store <2 x double> %28, <2 x double>* %30
%31 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %26
%32 = bitcast double* %31 to <2 x double>*
store <2 x double> %28, <2 x double>* %32
%33 = add nuw nsw i64 %12, 6
%34 = add <2 x i32> %13, <i32 6, i32 6>
%35 = sitofp <2 x i32> %34 to <2 x double>
%36 = getelementptr inbounds [100 x double], [100 x double]* %4, i64 0, i64 %33
%37 = bitcast double* %36 to <2 x double>*
store <2 x double> %35, <2 x double>* %37
%38 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %33
%39 = bitcast double* %38 to <2 x double>*
store <2 x double> %35, <2 x double>* %39
%40 = add nuw nsw i64 %12, 8
%41 = add <2 x i32> %13, <i32 8, i32 8>
%42 = sitofp <2 x i32> %41 to <2 x double>
%43 = getelementptr inbounds [100 x double], [100 x double]* %4, i64 0, i64 %40
%44 = bitcast double* %43 to <2 x double>*
store <2 x double> %42, <2 x double>* %44
%45 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %40
%46 = bitcast double* %45 to <2 x double>*
store <2 x double> %42, <2 x double>* %46
%47 = add nuw nsw i64 %12, 10
%48 = add <2 x i32> %13, <i32 10, i32 10>
%49 = icmp eq i64 %47, 100
br i1 %49, label %50, label %11
50: ; preds = %11, %50
%51 = phi i64 [ %82, %50 ], [ 0, %11 ]
%52 = phi double [ %81, %50 ], [ 0.000000e+00, %11 ]
%53 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %51
%54 = load double, double* %53
%55 = getelementptr inbounds [100 x double], [100 x double]* %4, i64 0, i64 %51
%56 = load double, double* %55
%57 = tail call double @llvm.fmuladd.f64(double %54, double %56, double %52)
%58 = add nuw nsw i64 %51, 1
%59 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %58
%60 = load double, double* %59
%61 = getelementptr inbounds [100 x double], [100 x double]* %4, i64 0, i64 %58
%62 = load double, double* %61
%63 = tail call double @llvm.fmuladd.f64(double %60, double %62, double %57)
%64 = add nuw nsw i64 %51, 2
%65 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %64
%66 = load double, double* %65
%67 = getelementptr inbounds [100 x double], [100 x double]* %4, i64 0, i64 %64
%68 = load double, double* %67
%69 = tail call double @llvm.fmuladd.f64(double %66, double %68, double %63)
%70 = add nuw nsw i64 %51, 3
%71 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %70
%72 = load double, double* %71
%73 = getelementptr inbounds [100 x double], [100 x double]* %4, i64 0, i64 %70
%74 = load double, double* %73
%75 = tail call double @llvm.fmuladd.f64(double %72, double %74, double %69)
%76 = add nuw nsw i64 %51, 4
%77 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %76
%78 = load double, double* %77
%79 = getelementptr inbounds [100 x double], [100 x double]* %4, i64 0, i64 %76
%80 = load double, double* %79
%81 = tail call double @llvm.fmuladd.f64(double %78, double %80, double %75)
%82 = add nuw nsw i64 %51, 5
%83 = icmp eq i64 %82, 100
br i1 %83, label %84, label %50
84: ; preds = %50
%85 = fadd double %81, 0.000000e+00
%86 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %85)
%87 = tail call i32 @exit(i32 0)
unreachable
}