#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 main() {
  int numberOfThreads, threadID;
  omp_set_num_threads(16);
#pragma omp parallel private(threadID)
  {
#pragma omp sections
    {
#pragma omp section
      {
        threadID = omp_get_thread_num();
        numberOfThreads = omp_get_num_threads();
        printf("Thread %d of %d calculates section 1\n", threadID,
               numberOfThreads);
      }
#pragma omp section
      {
        threadID = omp_get_thread_num();
        numberOfThreads = omp_get_num_threads();
        printf("Thread %d of %d calculates section 2\n", threadID,
               numberOfThreads);
      }
#pragma omp section
      {
        threadID = omp_get_thread_num();
        numberOfThreads = omp_get_num_threads();
        printf("Thread %d of %d calculates section 3\n", threadID,
               numberOfThreads);
      }
#pragma omp section
      {
        threadID = omp_get_thread_num();
        numberOfThreads = omp_get_num_threads();
        printf("Thread %d of %d calculates section 4\n", threadID,
               numberOfThreads);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
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,-0x8(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe86(%rip),%rdi
call   1040 <printf@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,-0x8(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe86(%rip),%rdi
call   1040 <printf@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,-0x8(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe86(%rip),%rdi
call   1040 <printf@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,-0x8(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
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>
lea    0xe9e(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
lea    0xea4(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
lea    0xeaa(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
lea    0xeb0(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [38 x i8] c"Thread %d of %d calculates section 1\0A\00"
@.str.1 = [38 x i8] c"Thread %d of %d calculates section 2\0A\00"
@.str.2 = [38 x i8] c"Thread %d of %d calculates section 3\0A\00"
@.str.3 = [38 x i8] c"Thread %d of %d calculates section 4\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 ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3)
%5 = tail call i32 (...) @omp_get_thread_num()
%6 = tail call i32 (...) @omp_get_num_threads()
%7 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %5, i32 %6)
%8 = tail call i32 (...) @omp_get_thread_num()
%9 = tail call i32 (...) @omp_get_num_threads()
%10 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %9)
%11 = tail call i32 (...) @omp_get_thread_num()
%12 = tail call i32 (...) @omp_get_num_threads()
%13 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %11, i32 %12)
ret i32 0
}