#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 atoi(char *);
int omp_get_thread_num();
scalar_t__ omp_quiesce();
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  int thr_num = 4;
  if (argc >= 2)
    thr_num = (atoi(argv[1]));
#pragma omp parallel num_threads(thr_num)
  {
    int tid = omp_get_thread_num();
    if (omp_quiesce() == 0) {
      printf("Error: omp_quiesce() returns SUCCESS when calling it with a "
             "parallel region\n");
    } else {
      printf("Expected: omp_quiesce() returns FAILURE when calling it with a "
             "parallel region\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x4,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1177 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <omp_quiesce@plt>
cmp    $0x0,%rax
jne    11a3 <main+0x63>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
jmp    11af <main+0x6f>
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
xor    %eax,%eax
call   1050 <omp_quiesce@plt>
test   %rax,%rax
lea    0xf06(%rip),%rax
lea    0xeb0(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [77 x i8] c"Error: omp_quiesce() returns SUCCESS when calling it with a parallel region\0A\00"
@.str.1 = [80 x i8] c"Expected: omp_quiesce() returns FAILURE when calling it with a parallel region\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 4, i32* %6
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %6
br label %15
15: ; preds = %10, %2
%16 = call i32 (...) @omp_get_thread_num()
store i32 %16, i32* %7
%17 = call i64 (...) @omp_quiesce()
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0))
br label %23
21: ; preds = %15
%22 = call i32 @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %19
ret i32 0
}

LLVM IR (-O2):
@str = [79 x i8] c"Expected: omp_quiesce() returns FAILURE when calling it with a parallel region\00"
@str.2 = [76 x i8] c"Error: omp_quiesce() returns SUCCESS when calling it with a parallel region\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @omp_get_thread_num()
%4 = tail call i64 (...) @omp_quiesce()
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @str.2, i64 0, i64 0), i8* getelementptr inbounds ([79 x i8], [79 x i8]* @str, i64 0, i64 0)
%7 = tail call i32 @puts(i8* dereferenceable(1) %6)
ret i32 0
}