#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_num_threads();
int omp_get_thread_num();
int /*<<< orphan*/ printf(char *, int, int, int);
int main() {
  int i;
  int threadID, totalNumberThreads;
  float vectorA[10], vectorB[10], vectorC[10], vectorD[10];
  for (i = 0; i < 10; i++) {
    vectorA[i] = i * 1.5;
    vectorB[i] = i + 22.35;
  }
#pragma omp parallel shared(vectorA, vectorB, vectorC,                         \
                            vectorD) private(i, threadID, totalNumberThreads)
  {
    threadID = omp_get_thread_num();
    totalNumberThreads = omp_get_num_threads();
#pragma omp sections nowait
    {
#pragma omp section
      for (i = 0; i < 10; i++) {
        vectorC[i] = vectorA[i] + vectorB[i];
        printf("Thread %d of %d calculates i = %d (section 1)\n", threadID,
               totalNumberThreads, i);
      }
#pragma omp section
      for (i = 0; i < 10; i++) {
        vectorD[i] = vectorA[i] * vectorB[i];
        printf("Thread %d of %d calculates i = %d (section 2)\n", threadID,
               totalNumberThreads, i);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    119f <main+0x6f>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xea8(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x8(%rbp),%rax
movss  %xmm0,-0x40(%rbp,%rax,4)
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x8(%rbp),%rax
movss  %xmm0,-0x70(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1149 <main+0x19>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1050 <omp_get_num_threads@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1208 <main+0xd8>
movslq -0x8(%rbp),%rax
movss  -0x40(%rbp,%rax,4),%xmm0
movslq -0x8(%rbp),%rax
addss  -0x70(%rbp,%rax,4),%xmm0
movslq -0x8(%rbp),%rax
movss  %xmm0,-0xa0(%rbp,%rax,4)
ff ff
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe1b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ba <main+0x8a>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    125d <main+0x12d>
movslq -0x8(%rbp),%rax
movss  -0x40(%rbp,%rax,4),%xmm0
movslq -0x8(%rbp),%rax
mulss  -0x70(%rbp,%rax,4),%xmm0
movslq -0x8(%rbp),%rax
movss  %xmm0,-0xd0(%rbp,%rax,4)
ff ff
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xdf5(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    120f <main+0xdf>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %eax,%ebp
lea    0xeb3(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x1,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x2,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x3,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x4,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x5,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x6,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x7,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x8,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x9,%ecx
call   1040 <printf@plt>
lea    0xe34(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %ecx,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x1,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x2,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x3,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x4,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x5,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x6,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x7,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x8,%ecx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x9,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Thread %d of %d calculates i = %d (section 1)\0A\00"
@.str.1 = [47 x i8] c"Thread %d of %d calculates i = %d (section 2)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10 x float]
%6 = alloca [10 x float]
%7 = alloca [10 x float]
%8 = alloca [10 x float]
store i32 0, i32* %1
store i32 0, i32* %2
br label %9
9: ; preds = %27, %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = load i32, i32* %2
%14 = sitofp i32 %13 to double
%15 = fmul double %14, 1.500000e+00
%16 = fptrunc double %15 to float
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [10 x float], [10 x float]* %5, i64 0, i64 %18
store float %16, float* %19
%20 = load i32, i32* %2
%21 = sitofp i32 %20 to double
%22 = fadd double %21, 2.235000e+01
%23 = fptrunc double %22 to float
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [10 x float], [10 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 %9
30: ; preds = %9
%31 = call i32 (...) @omp_get_thread_num()
store i32 %31, i32* %3
%32 = call i32 (...) @omp_get_num_threads()
store i32 %32, i32* %4
store i32 0, i32* %2
br label %33
33: ; preds = %53, %30
%34 = load i32, i32* %2
%35 = icmp slt i32 %34, 10
br i1 %35, label %36, label %56
36: ; preds = %33
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [10 x float], [10 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 [10 x float], [10 x float]* %6, i64 0, i64 %42
%44 = load float, float* %43
%45 = fadd float %40, %44
%46 = load i32, i32* %2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [10 x float], [10 x float]* %7, i64 0, i64 %47
store float %45, float* %48
%49 = load i32, i32* %3
%50 = load i32, i32* %4
%51 = load i32, i32* %2
%52 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %49, i32 %50, i32 %51)
br label %53
53: ; preds = %36
%54 = load i32, i32* %2
%55 = add nsw i32 %54, 1
store i32 %55, i32* %2
br label %33
56: ; preds = %33
store i32 0, i32* %2
br label %57
57: ; preds = %77, %56
%58 = load i32, i32* %2
%59 = icmp slt i32 %58, 10
br i1 %59, label %60, label %80
60: ; preds = %57
%61 = load i32, i32* %2
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [10 x float], [10 x float]* %5, i64 0, i64 %62
%64 = load float, float* %63
%65 = load i32, i32* %2
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [10 x float], [10 x float]* %6, i64 0, i64 %66
%68 = load float, float* %67
%69 = fmul float %64, %68
%70 = load i32, i32* %2
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [10 x float], [10 x float]* %8, i64 0, i64 %71
store float %69, float* %72
%73 = load i32, i32* %3
%74 = load i32, i32* %4
%75 = load i32, i32* %2
%76 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %73, i32 %74, i32 %75)
br label %77
77: ; preds = %60
%78 = load i32, i32* %2
%79 = add nsw i32 %78, 1
store i32 %79, i32* %2
br label %57
80: ; preds = %57
ret i32 0
}

LLVM IR (-O2):
@.str = [47 x i8] c"Thread %d of %d calculates i = %d (section 1)\0A\00"
@.str.1 = [47 x i8] c"Thread %d of %d calculates i = %d (section 2)\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @omp_get_thread_num()
%2 = tail call i32 (...) @omp_get_num_threads()
%3 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 0)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 1)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 2)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 3)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 4)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 5)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 6)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 7)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 8)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 9)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2, i32 0)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2, i32 1)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2, i32 2)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2, i32 3)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2, i32 4)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2, i32 5)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2, i32 6)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2, i32 7)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2, i32 8)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2, i32 9)
ret i32 0
}