#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*/ abort();
size_t omp_get_thread_num();
int /*<<< orphan*/ omp_set_dynamic(int /*<<< orphan*/);
int /*<<< orphan*/ omp_set_nested(int);
int /*<<< orphan*/ omp_set_num_threads(int);
int main() {
  int n[4] = {-1, -1, -1, -1};
  static int a = 2, b = 4;
  omp_set_num_threads(4);
  omp_set_dynamic(0);
  omp_set_nested(1);
#pragma omp parallel private(b)
  {
    b = omp_get_thread_num();
#pragma omp parallel firstprivate(a)
    {
      a = (omp_get_thread_num() + a) + 1;
      if (b == omp_get_thread_num())
        n[omp_get_thread_num()] = a + (b << 4);
    }
  }
  if (n[0] != 3)
    abort();
  if (n[3] != -1 && (n[1] != 0x14 || n[2] != 0x25 || n[3] != 0x36))
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x4,%edi
call   1070 <omp_set_num_threads@plt>
xor    %edi,%edi
call   1050 <omp_set_dynamic@plt>
mov    $0x1,%edi
call   1060 <omp_set_nested@plt>
mov    $0x0,%al
call   1040 <omp_get_thread_num@plt>
mov    %eax,0x2eaf(%rip)
mov    $0x0,%al
call   1040 <omp_get_thread_num@plt>
movslq 0x2e9d(%rip),%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %eax,0x2e90(%rip)
movslq 0x2e8d(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <omp_get_thread_num@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jne    11fc <main+0xac>
mov    0x2e68(%rip),%eax
mov    0x2e66(%rip),%ecx
shl    $0x4,%ecx
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1040 <omp_get_thread_num@plt>
mov    -0x2c(%rbp),%ecx
mov    %ecx,-0x20(%rbp,%rax,4)
cmpl   $0x3,-0x20(%rbp)
je     120d <main+0xbd>
mov    $0x0,%al
call   1030 <abort@plt>
cmpl   $0xffffffff,-0x14(%rbp)
je     123c <main+0xec>
cmpl   $0x14,-0x1c(%rbp)
jne    1235 <main+0xe5>
cmpl   $0x25,-0x18(%rbp)
jne    1235 <main+0xe5>
cmpl   $0x36,-0x14(%rbp)
je     123c <main+0xec>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
pcmpeqd %xmm0,%xmm0
movdqa %xmm0,(%rsp)
mov    $0x4,%edi
call   1070 <omp_set_num_threads@plt>
xor    %edi,%edi
call   1050 <omp_set_dynamic@plt>
mov    $0x1,%edi
call   1060 <omp_set_nested@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %eax,0x2ec6(%rip)
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    0x2eb5(%rip),%ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,0x2eaa(%rip)
movslq 0x2ea7(%rip),%rbx
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
cmp    %rbx,%rax
jne    11f4 <main+0xa4>
mov    0x2e95(%rip),%ebx
shl    $0x4,%ebx
add    0x2e88(%rip),%ebx
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %ebx,(%rsp,%rax,4)
cmpl   $0x3,(%rsp)
jne    11f4 <main+0xa4>
mov    0xc(%rsp),%eax
cmp    $0xffffffff,%eax
je     11ec <main+0x9c>
cmpl   $0x14,0x4(%rsp)
jne    11f4 <main+0xa4>
cmpl   $0x25,0x8(%rsp)
jne    11f4 <main+0xa4>
cmp    $0x36,%eax
jne    11f4 <main+0xa4>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@__const.main.n = [4 x i32] [i32 -1, i32 -1, i32 -1, i32 -1]
@main.a = internal global i32 2
@main.b = internal global i32 4
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
store i32 0, i32* %1
%3 = bitcast [4 x i32]* %2 to i8*
%4 = call i32 @omp_set_num_threads(i32 4)
%5 = call i32 @omp_set_dynamic(i32 0)
%6 = call i32 @omp_set_nested(i32 1)
%7 = call i64 (...) @omp_get_thread_num()
%8 = trunc i64 %7 to i32
store i32 %8, i32* @main.b
%9 = call i64 (...) @omp_get_thread_num()
%10 = load i32, i32* @main.a
%11 = sext i32 %10 to i64
%12 = add i64 %9, %11
%13 = add i64 %12, 1
%14 = trunc i64 %13 to i32
store i32 %14, i32* @main.a
%15 = load i32, i32* @main.b
%16 = sext i32 %15 to i64
%17 = call i64 (...) @omp_get_thread_num()
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %26
19: ; preds = %0
%20 = load i32, i32* @main.a
%21 = load i32, i32* @main.b
%22 = shl i32 %21, 4
%23 = add nsw i32 %20, %22
%24 = call i64 (...) @omp_get_thread_num()
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %24
store i32 %23, i32* %25
br label %26
26: ; preds = %19, %0
%27 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%28 = load i32, i32* %27
%29 = icmp ne i32 %28, 3
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 (...) @abort()
unreachable
32: ; preds = %26
%33 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%34 = load i32, i32* %33
%35 = icmp ne i32 %34, -1
br i1 %35, label %36, label %50
36: ; preds = %32
%37 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%38 = load i32, i32* %37
%39 = icmp ne i32 %38, 20
br i1 %39, label %48, label %40
40: ; preds = %36
%41 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%42 = load i32, i32* %41
%43 = icmp ne i32 %42, 37
br i1 %43, label %48, label %44
44: ; preds = %40
%45 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%46 = load i32, i32* %45
%47 = icmp ne i32 %46, 54
br i1 %47, label %48, label %50
48: ; preds = %44, %40, %36
%49 = call i32 (...) @abort()
unreachable
50: ; preds = %44, %32
ret i32 0
}

LLVM IR (-O2):
@main.a = internal unnamed_addr global i32 2
@main.b = internal unnamed_addr global i32 4
define i32 @main() {
%1 = alloca [4 x i32]
%2 = bitcast [4 x i32]* %1 to i8*
%3 = tail call i32 @omp_set_num_threads(i32 4)
%4 = tail call i32 @omp_set_dynamic(i32 0)
%5 = tail call i32 @omp_set_nested(i32 1)
%6 = tail call i64 (...) @omp_get_thread_num()
%7 = trunc i64 %6 to i32
store i32 %7, i32* @main.b
%8 = tail call i64 (...) @omp_get_thread_num()
%9 = load i32, i32* @main.a
%10 = trunc i64 %8 to i32
%11 = add i32 %10, 1
%12 = add i32 %11, %9
store i32 %12, i32* @main.a
%13 = load i32, i32* @main.b
%14 = sext i32 %13 to i64
%15 = tail call i64 (...) @omp_get_thread_num()
%16 = icmp eq i64 %15, %14
br i1 %16, label %17, label %27
17: ; preds = %0
%18 = load i32, i32* @main.a
%19 = load i32, i32* @main.b
%20 = shl i32 %19, 4
%21 = add nsw i32 %20, %18
%22 = tail call i64 (...) @omp_get_thread_num()
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %22
store i32 %21, i32* %23
%24 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, 3
br i1 %26, label %29, label %27
27: ; preds = %0, %17
%28 = tail call i32 (...) @abort()
unreachable
29: ; preds = %17
%30 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, -1
br i1 %32, label %45, label %33
33: ; preds = %29
%34 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%35 = load i32, i32* %34
%36 = icmp ne i32 %35, 20
%37 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%38 = load i32, i32* %37
%39 = icmp ne i32 %38, 37
%40 = select i1 %36, i1 true, i1 %39
%41 = icmp ne i32 %31, 54
%42 = select i1 %40, i1 true, i1 %41
br i1 %42, label %43, label %45
43: ; preds = %33
%44 = tail call i32 (...) @abort()
unreachable
45: ; preds = %33, %29
ret i32 0
}