#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*/ omp_set_num_threads(int);
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;
  }
  omp_set_num_threads(16);
#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    11af <main+0x6f>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe98(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x8(%rbp),%rax
movss  %xmm0,-0x40(%rbp,%rax,4)
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe71(%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    1159 <main+0x19>
mov    $0x10,%edi
call   1060 <omp_set_num_threads@plt>
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    1222 <main+0xe2>
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    0xe01(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d4 <main+0x94>
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1277 <main+0x137>
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    0xddb(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1229 <main+0xe9>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x10,%edi
call   1060 <omp_set_num_threads@plt>
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    0xe99(%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    0xe1a(%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_set_num_threads(i32 16)
%32 = call i32 (...) @omp_get_thread_num()
store i32 %32, i32* %3
%33 = call i32 (...) @omp_get_num_threads()
store i32 %33, i32* %4
store i32 0, i32* %2
br label %34
34: ; preds = %54, %30
%35 = load i32, i32* %2
%36 = icmp slt i32 %35, 10
br i1 %36, label %37, label %57
37: ; preds = %34
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [10 x float], [10 x float]* %5, i64 0, i64 %39
%41 = load float, float* %40
%42 = load i32, i32* %2
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [10 x float], [10 x float]* %6, i64 0, i64 %43
%45 = load float, float* %44
%46 = fadd float %41, %45
%47 = load i32, i32* %2
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [10 x float], [10 x float]* %7, i64 0, i64 %48
store float %46, float* %49
%50 = load i32, i32* %3
%51 = load i32, i32* %4
%52 = load i32, i32* %2
%53 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %50, i32 %51, i32 %52)
br label %54
54: ; preds = %37
%55 = load i32, i32* %2
%56 = add nsw i32 %55, 1
store i32 %56, i32* %2
br label %34
57: ; preds = %34
store i32 0, i32* %2
br label %58
58: ; preds = %78, %57
%59 = load i32, i32* %2
%60 = icmp slt i32 %59, 10
br i1 %60, label %61, label %81
61: ; preds = %58
%62 = load i32, i32* %2
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [10 x float], [10 x float]* %5, i64 0, i64 %63
%65 = load float, float* %64
%66 = load i32, i32* %2
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [10 x float], [10 x float]* %6, i64 0, i64 %67
%69 = load float, float* %68
%70 = fmul float %65, %69
%71 = load i32, i32* %2
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [10 x float], [10 x float]* %8, i64 0, i64 %72
store float %70, float* %73
%74 = load i32, i32* %3
%75 = load i32, i32* %4
%76 = load i32, i32* %2
%77 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %74, i32 %75, i32 %76)
br label %78
78: ; preds = %61
%79 = load i32, i32* %2
%80 = add nsw i32 %79, 1
store i32 %80, i32* %2
br label %58
81: ; preds = %58
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_set_num_threads(i32 16)
%2 = tail call i32 (...) @omp_get_thread_num()
%3 = tail call i32 (...) @omp_get_num_threads()
%4 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3, i32 0)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3, i32 1)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3, i32 2)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3, i32 3)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3, i32 4)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3, i32 5)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3, i32 6)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3, i32 7)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3, i32 8)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3, i32 9)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %3, i32 0)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %3, i32 1)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %3, i32 2)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %3, i32 3)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %3, i32 4)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %3, i32 5)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %3, i32 6)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %3, i32 7)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %3, i32 8)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %3, i32 9)
ret i32 0
}