#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 /*<<< orphan*/ sleep_rand_ns(int, int);
void sections() {
#pragma omp parallel num_threads(3)
  {
#pragma omp sections
    {
      {
        sleep_rand_ns(100000, 200000);
        printf("Section 0: thread %d / %d\n", omp_get_thread_num(),
               omp_get_num_threads());
      }
#pragma omp section
      {
        sleep_rand_ns(100000, 200000);
        printf("Section 1: thread %d / %d\n", omp_get_thread_num(),
               omp_get_num_threads());
      }
#pragma omp section
      {
        sleep_rand_ns(100000, 200000);
        printf("Section 2: thread %d / %d\n", omp_get_thread_num(),
               omp_get_num_threads());
      }
#pragma omp section
      {
        sleep_rand_ns(100000, 200000);
        printf("Section 3: thread %d / %d\n", omp_get_thread_num(),
               omp_get_num_threads());
      }
    }
  }
}


x86 assembly (clang, -O0):
<sections>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x186a0,%edi
mov    $0x30d40,%esi
call   1060 <sleep_rand_ns@plt>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <omp_get_num_threads@plt>
mov    -0x10(%rbp),%esi
mov    %eax,%edx
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x186a0,%edi
mov    $0x30d40,%esi
call   1060 <sleep_rand_ns@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    -0xc(%rbp),%esi
mov    %eax,%edx
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
mov    $0x186a0,%edi
mov    $0x30d40,%esi
call   1060 <sleep_rand_ns@plt>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1050 <omp_get_num_threads@plt>
mov    -0x8(%rbp),%esi
mov    %eax,%edx
lea    0xe60(%rip),%rdi
call   1040 <printf@plt>
mov    $0x186a0,%edi
mov    $0x30d40,%esi
call   1060 <sleep_rand_ns@plt>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1050 <omp_get_num_threads@plt>
mov    -0x4(%rbp),%esi
mov    %eax,%edx
lea    0xe4a(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sections>:
push   %rbx
mov    $0x186a0,%edi
mov    $0x30d40,%esi
call   1060 <sleep_rand_ns@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    0xe99(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x186a0,%edi
mov    $0x30d40,%esi
call   1060 <sleep_rand_ns@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    0xe85(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x186a0,%edi
mov    $0x30d40,%esi
call   1060 <sleep_rand_ns@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    0xe71(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x186a0,%edi
mov    $0x30d40,%esi
call   1060 <sleep_rand_ns@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    0xe5d(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"Section 0: thread %d / %d\0A\00"
@.str.1 = [27 x i8] c"Section 1: thread %d / %d\0A\00"
@.str.2 = [27 x i8] c"Section 2: thread %d / %d\0A\00"
@.str.3 = [27 x i8] c"Section 3: thread %d / %d\0A\00"
define void @sections() {
%1 = call i32 @sleep_rand_ns(i32 100000, i32 200000)
%2 = call i32 (...) @omp_get_thread_num()
%3 = call i32 (...) @omp_get_num_threads()
%4 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3)
%5 = call i32 @sleep_rand_ns(i32 100000, i32 200000)
%6 = call i32 (...) @omp_get_thread_num()
%7 = call i32 (...) @omp_get_num_threads()
%8 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %7)
%9 = call i32 @sleep_rand_ns(i32 100000, i32 200000)
%10 = call i32 (...) @omp_get_thread_num()
%11 = call i32 (...) @omp_get_num_threads()
%12 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %11)
%13 = call i32 @sleep_rand_ns(i32 100000, i32 200000)
%14 = call i32 (...) @omp_get_thread_num()
%15 = call i32 (...) @omp_get_num_threads()
%16 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %14, i32 %15)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"Section 0: thread %d / %d\0A\00"
@.str.1 = [27 x i8] c"Section 1: thread %d / %d\0A\00"
@.str.2 = [27 x i8] c"Section 2: thread %d / %d\0A\00"
@.str.3 = [27 x i8] c"Section 3: thread %d / %d\0A\00"
define void @sections() {
%1 = tail call i32 @sleep_rand_ns(i32 100000, i32 200000)
%2 = tail call i32 (...) @omp_get_thread_num()
%3 = tail call i32 (...) @omp_get_num_threads()
%4 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3)
%5 = tail call i32 @sleep_rand_ns(i32 100000, i32 200000)
%6 = tail call i32 (...) @omp_get_thread_num()
%7 = tail call i32 (...) @omp_get_num_threads()
%8 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %7)
%9 = tail call i32 @sleep_rand_ns(i32 100000, i32 200000)
%10 = tail call i32 (...) @omp_get_thread_num()
%11 = tail call i32 (...) @omp_get_num_threads()
%12 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %11)
%13 = tail call i32 @sleep_rand_ns(i32 100000, i32 200000)
%14 = tail call i32 (...) @omp_get_thread_num()
%15 = tail call i32 (...) @omp_get_num_threads()
%16 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %14, i32 %15)
ret void
}