#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_max_threads();
int omp_get_num_procs();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int main() {
  int i;
  int r = 0;
  static const int N = 4096;
  int x[N];
  printf("Number of threads in the pool: %d\n", omp_get_max_threads());
  printf("Number of processors: %d\n", omp_get_num_procs());
  puts("Running test loop...");
#pragma omp parallel for schedule(dynamic)
  for (i = 0; i < N; i++) {
    x[i] = N / 2 - i;
  }
  puts("...done - verifying...");
  for (i = 0; i < N; i++) {
    if (x[i] != (N / 2 - i)) {
      printf("Failure on index %d\n", i);
      r = -1;
    }
  }
  if (!r)
    puts("OK");
  return r;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4020,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    %rsp,%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <omp_get_max_threads@plt>
mov    %eax,%esi
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <omp_get_num_procs@plt>
mov    %eax,%esi
lea    0xea2(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x1000,-0x8(%rbp)
jge    11cb <main+0x8b>
mov    $0x800,%ecx
sub    -0x8(%rbp),%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x4020(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119d <main+0x5d>
lea    0xe84(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x1000,-0x8(%rbp)
jge    122f <main+0xef>
movslq -0x8(%rbp),%rax
mov    -0x4020(%rbp,%rax,4),%eax
mov    $0x800,%ecx
sub    -0x8(%rbp),%ecx
cmp    %ecx,%eax
je     121c <main+0xdc>
mov    -0x8(%rbp),%esi
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    1221 <main+0xe1>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11de <main+0x9e>
cmpl   $0x0,-0xc(%rbp)
jne    1245 <main+0x105>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x4020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x4008,%rsp
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <omp_get_max_threads@plt>
lea    0xf46(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_num_procs@plt>
lea    0xf54(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    0xf60(%rip),%rdi
call   1030 <puts@plt>
movdqa 0xe76(%rip),%xmm0
movdqa 0xe7d(%rip),%xmm8
movdqa 0xe84(%rip),%xmm9
movdqa 0xe8b(%rip),%xmm10
movdqa 0xe92(%rip),%xmm11
movdqa 0xe9a(%rip),%xmm5
movdqa 0xea2(%rip),%xmm6
movdqa 0xeaa(%rip),%xmm7
movdqa 0xeb2(%rip),%xmm1
movdqa 0xeba(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
movdqa %xmm8,%xmm3
psubd  %xmm0,%xmm3
movdqa %xmm9,%xmm4
psubd  %xmm0,%xmm4
movdqa %xmm3,(%rsp,%rbx,4)
movdqa %xmm4,0x10(%rsp,%rbx,4)
movdqa %xmm10,%xmm3
psubd  %xmm0,%xmm3
movdqa %xmm11,%xmm4
psubd  %xmm0,%xmm4
movdqa %xmm3,0x20(%rsp,%rbx,4)
movdqa %xmm4,0x30(%rsp,%rbx,4)
movdqa %xmm5,%xmm3
psubd  %xmm0,%xmm3
movdqa %xmm6,%xmm4
psubd  %xmm0,%xmm4
movdqa %xmm3,0x40(%rsp,%rbx,4)
movdqa %xmm4,0x50(%rsp,%rbx,4)
movdqa %xmm7,%xmm3
psubd  %xmm0,%xmm3
movdqa %xmm1,%xmm4
psubd  %xmm0,%xmm4
movdqa %xmm3,0x60(%rsp,%rbx,4)
movdqa %xmm4,0x70(%rsp,%rbx,4)
add    $0x20,%rbx
paddd  %xmm2,%xmm0
cmp    $0x1000,%rbx
jne    11e0 <main+0xa0>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    $0x1,%cl
lea    0xe8a(%rip),%r14
xor    %eax,%eax
mov    $0x800,%edx
sub    %ebx,%edx
add    $0x1,%rbx
nopl   0x0(%rax)
cmp    -0x4(%rsp,%rbx,4),%edx
jne    12b0 <main+0x170>
add    $0x1,%rbx
add    $0xffffffff,%edx
cmp    $0x1001,%rbx
jne    1290 <main+0x150>
jmp    12cd <main+0x18d>
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rbx),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%eax
xor    %ecx,%ecx
cmp    $0x1000,%rbx
jne    1281 <main+0x141>
jmp    12e0 <main+0x1a0>
test   $0x1,%cl
je     12e0 <main+0x1a0>
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x4008,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@main.N = internal constant i32 4096
@.str = [35 x i8] c"Number of threads in the pool: %d\0A\00"
@.str.1 = [26 x i8] c"Number of processors: %d\0A\00"
@.str.2 = [21 x i8] c"Running test loop...\00"
@.str.3 = [23 x i8] c"...done - verifying...\00"
@.str.4 = [21 x i8] c"Failure on index %d\0A\00"
@.str.5 = [3 x i8] c"OK\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %3
%5 = call i8* @llvm.stacksave()
store i8* %5, i8** %4
%6 = alloca i32, i64 4096
%7 = call i32 (...) @omp_get_max_threads()
%8 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 (...) @omp_get_num_procs()
%10 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %12
12: ; preds = %21, %0
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 4096
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = load i32, i32* %2
%17 = sub nsw i32 2048, %16
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %6, i64 %19
store i32 %17, i32* %20
br label %21
21: ; preds = %15
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %12
24: ; preds = %12
%25 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %26
26: ; preds = %41, %24
%27 = load i32, i32* %2
%28 = icmp slt i32 %27, 4096
br i1 %28, label %29, label %44
29: ; preds = %26
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %6, i64 %31
%33 = load i32, i32* %32
%34 = load i32, i32* %2
%35 = sub nsw i32 2048, %34
%36 = icmp ne i32 %33, %35
br i1 %36, label %37, label %40
37: ; preds = %29
%38 = load i32, i32* %2
%39 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %38)
store i32 -1, i32* %3
br label %40
40: ; preds = %37, %29
br label %41
41: ; preds = %40
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %26
44: ; preds = %26
%45 = load i32, i32* %3
%46 = icmp ne i32 %45, 0
br i1 %46, label %49, label %47
47: ; preds = %44
%48 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %47, %44
%50 = load i32, i32* %3
store i32 %50, i32* %1
%51 = load i8*, i8** %4
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
@.str = [35 x i8] c"Number of threads in the pool: %d\0A\00"
@.str.1 = [26 x i8] c"Number of processors: %d\0A\00"
@.str.2 = [21 x i8] c"Running test loop...\00"
@.str.3 = [23 x i8] c"...done - verifying...\00"
@.str.4 = [21 x i8] c"Failure on index %d\0A\00"
@.str.5 = [3 x i8] c"OK\00"
define i32 @main() {
%1 = alloca [4096 x i32]
%2 = tail call i32 (...) @omp_get_max_threads()
%3 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = tail call i32 (...) @omp_get_num_procs()
%5 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %7, %0
%8 = phi i64 [ 0, %0 ], [ %37, %7 ]
%9 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %0 ], [ %38, %7 ]
%10 = getelementptr inbounds [4096 x i32], [4096 x i32]* %1, i64 0, i64 %8
%11 = sub <4 x i32> <i32 2048, i32 2048, i32 2048, i32 2048>, %9
%12 = sub <4 x i32> <i32 2044, i32 2044, i32 2044, i32 2044>, %9
%13 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> %11, <4 x i32>* %13
%14 = getelementptr inbounds i32, i32* %10, i64 4
%15 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> %12, <4 x i32>* %15
%16 = or i64 %8, 8
%17 = getelementptr inbounds [4096 x i32], [4096 x i32]* %1, i64 0, i64 %16
%18 = sub <4 x i32> <i32 2040, i32 2040, i32 2040, i32 2040>, %9
%19 = sub <4 x i32> <i32 2036, i32 2036, i32 2036, i32 2036>, %9
%20 = bitcast i32* %17 to <4 x i32>*
store <4 x i32> %18, <4 x i32>* %20
%21 = getelementptr inbounds i32, i32* %17, i64 4
%22 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> %19, <4 x i32>* %22
%23 = or i64 %8, 16
%24 = getelementptr inbounds [4096 x i32], [4096 x i32]* %1, i64 0, i64 %23
%25 = sub <4 x i32> <i32 2032, i32 2032, i32 2032, i32 2032>, %9
%26 = sub <4 x i32> <i32 2028, i32 2028, i32 2028, i32 2028>, %9
%27 = bitcast i32* %24 to <4 x i32>*
store <4 x i32> %25, <4 x i32>* %27
%28 = getelementptr inbounds i32, i32* %24, i64 4
%29 = bitcast i32* %28 to <4 x i32>*
store <4 x i32> %26, <4 x i32>* %29
%30 = or i64 %8, 24
%31 = getelementptr inbounds [4096 x i32], [4096 x i32]* %1, i64 0, i64 %30
%32 = sub <4 x i32> <i32 2024, i32 2024, i32 2024, i32 2024>, %9
%33 = sub <4 x i32> <i32 2020, i32 2020, i32 2020, i32 2020>, %9
%34 = bitcast i32* %31 to <4 x i32>*
store <4 x i32> %32, <4 x i32>* %34
%35 = getelementptr inbounds i32, i32* %31, i64 4
%36 = bitcast i32* %35 to <4 x i32>*
store <4 x i32> %33, <4 x i32>* %36
%37 = add nuw nsw i64 %8, 32
%38 = add <4 x i32> %9, <i32 32, i32 32, i32 32, i32 32>
%39 = icmp eq i64 %37, 4096
br i1 %39, label %40, label %7
40: ; preds = %7
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %56, %40
%43 = phi i64 [ %59, %56 ], [ 0, %40 ]
%44 = phi i1 [ false, %56 ], [ true, %40 ]
%45 = phi i32 [ -1, %56 ], [ 0, %40 ]
br label %46
46: ; preds = %42, %53
%47 = phi i64 [ %54, %53 ], [ %43, %42 ]
%48 = getelementptr inbounds [4096 x i32], [4096 x i32]* %1, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = trunc i64 %47 to i32
%51 = sub i32 2048, %50
%52 = icmp eq i32 %49, %51
br i1 %52, label %53, label %56
53: ; preds = %46
%54 = add nuw nsw i64 %47, 1
%55 = icmp eq i64 %54, 4096
br i1 %55, label %61, label %46
56: ; preds = %46
%57 = trunc i64 %47 to i32
%58 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %57)
%59 = add nuw nsw i64 %47, 1
%60 = icmp eq i64 %59, 4096
br i1 %60, label %64, label %42
61: ; preds = %53
br i1 %44, label %62, label %64
62: ; preds = %61
%63 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %64
64: ; preds = %56, %62, %61
%65 = phi i32 [ 0, %62 ], [ %45, %61 ], [ -1, %56 ]
ret i32 %65
}