#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*/ exit(int /*<<< orphan*/);
int omp_get_max_threads();
scalar_t__ omp_get_thread_num();
int /*<<< orphan*/ omp_set_dynamic(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
main() {
  int lp, thds;
  thds = omp_get_max_threads();
  if (thds == 1) {
    printf("should be run this program on multi threads.\n");
    exit(0);
  }
  omp_set_dynamic(0);
#pragma omp parallel
  {
#pragma omp for
    for (lp = 0; lp < thds; lp++) {
      if (omp_get_thread_num() == 0)
        break;
    }
  }
  printf("err_for 024 : FAILED, can not compile this program.\n");
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <omp_get_max_threads@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1186 <main+0x36>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
xor    %edi,%edi
call   1050 <omp_set_dynamic@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c9 <main+0x79>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
cmp    $0x0,%rax
jne    11b6 <main+0x66>
jmp    11c9 <main+0x79>
jmp    11bb <main+0x6b>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1194 <main+0x44>
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <omp_get_max_threads@plt>
cmp    $0x1,%eax
je     11ad <main+0x5d>
mov    %eax,%ebp
xor    %edi,%edi
call   1050 <omp_set_dynamic@plt>
test   %ebp,%ebp
jle    1195 <main+0x45>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
test   %rax,%rax
je     1195 <main+0x45>
lea    0x1(%rbx),%eax
cmp    %ebp,%ebx
mov    %eax,%ebx
jl     1180 <main+0x30>
lea    0xe64(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [46 x i8] c"should be run this program on multi threads.\0A\00"
@.str.1 = [53 x i8] c"err_for 024 : FAILED, can not compile this program.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @omp_get_max_threads()
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 0)
unreachable
10: ; preds = %0
%11 = call i32 @omp_set_dynamic(i32 0)
store i32 0, i32* %2
br label %12
12: ; preds = %21, %10
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = call i64 (...) @omp_get_thread_num()
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16
br label %24
20: ; preds = %16
br label %21
21: ; preds = %20
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %12
24: ; preds = %19, %12
%25 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@str = [52 x i8] c"err_for 024 : FAILED, can not compile this program.\00"
@str.2 = [45 x i8] c"should be run this program on multi threads.\00"
define i32 @main() {
%1 = tail call i32 (...) @omp_get_max_threads()
%2 = icmp eq i32 %1, 1
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.2, i64 0, i64 0))
%5 = tail call i32 @exit(i32 0)
unreachable
6: ; preds = %0
%7 = tail call i32 @omp_set_dynamic(i32 0)
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %16
9: ; preds = %6, %9
%10 = phi i32 [ %13, %9 ], [ 0, %6 ]
%11 = tail call i64 (...) @omp_get_thread_num()
%12 = icmp ne i64 %11, 0
%13 = add nuw nsw i32 %10, 1
%14 = icmp slt i32 %13, %1
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %9, label %16
16: ; preds = %9, %6
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
ret i32 1
}