#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, int);
int main() {
  int N = 12, i, iam, np;
  int array[] = {12, 432, 23, 435, 65, 2, 657, 456, 4, 45, 89, 20};
#pragma omp parallel private(i, iam)
  {
#pragma omp for
    for (i = 0; i < N; i++) {
      np = omp_get_num_threads();
      iam = omp_get_thread_num();
      printf("Thread %d of %d - array[%d] %d\n", iam + 1, np, i, array[i]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xc,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x30,%edx
call   1060 <memcpy@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c1 <main+0x81>
mov    $0x0,%al
call   1050 <omp_get_num_threads@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
add    $0x1,%esi
mov    -0x14(%rbp),%edx
mov    -0xc(%rbp),%ecx
movslq -0xc(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%r8d
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1172 <main+0x32>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0x1(%rax),%esi
lea    0xeb3(%rip),%rbx
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %ecx,%ecx
mov    $0xc,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    $0x1,%ecx
mov    $0x1b0,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    $0x2,%ecx
mov    $0x17,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    $0x3,%ecx
mov    $0x1b3,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    $0x4,%ecx
mov    $0x41,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    $0x5,%ecx
mov    $0x2,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    $0x6,%ecx
mov    $0x291,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    $0x7,%ecx
mov    $0x1c8,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    $0x8,%ecx
mov    $0x4,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    $0x9,%ecx
mov    $0x2d,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    $0xa,%ecx
mov    $0x59,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    $0xb,%ecx
mov    $0x14,%r8d
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.array = [12 x i32] [i32 12, i32 432, i32 23, i32 435, i32 65, i32 2, i32 657, i32 456, i32 4, i32 45, i32 89, i32 20]
@.str = [32 x i8] c"Thread %d of %d - array[%d] %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [12 x i32]
store i32 0, i32* %1
store i32 12, i32* %2
%7 = bitcast [12 x i32]* %6 to i8*
store i32 0, i32* %3
br label %8
8: ; preds = %24, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %27
12: ; preds = %8
%13 = call i32 (...) @omp_get_num_threads()
store i32 %13, i32* %5
%14 = call i32 (...) @omp_get_thread_num()
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
%17 = load i32, i32* %5
%18 = load i32, i32* %3
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [12 x i32], [12 x i32]* %6, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17, i32 %18, i32 %22)
br label %24
24: ; preds = %12
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %8
27: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Thread %d of %d - array[%d] %d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @omp_get_num_threads()
%2 = tail call i32 (...) @omp_get_thread_num()
%3 = add nsw i32 %2, 1
%4 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %1, i32 0, i32 12)
%5 = tail call i32 (...) @omp_get_num_threads()
%6 = tail call i32 (...) @omp_get_thread_num()
%7 = add nsw i32 %6, 1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %5, i32 1, i32 432)
%9 = tail call i32 (...) @omp_get_num_threads()
%10 = tail call i32 (...) @omp_get_thread_num()
%11 = add nsw i32 %10, 1
%12 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %9, i32 2, i32 23)
%13 = tail call i32 (...) @omp_get_num_threads()
%14 = tail call i32 (...) @omp_get_thread_num()
%15 = add nsw i32 %14, 1
%16 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %13, i32 3, i32 435)
%17 = tail call i32 (...) @omp_get_num_threads()
%18 = tail call i32 (...) @omp_get_thread_num()
%19 = add nsw i32 %18, 1
%20 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %17, i32 4, i32 65)
%21 = tail call i32 (...) @omp_get_num_threads()
%22 = tail call i32 (...) @omp_get_thread_num()
%23 = add nsw i32 %22, 1
%24 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %21, i32 5, i32 2)
%25 = tail call i32 (...) @omp_get_num_threads()
%26 = tail call i32 (...) @omp_get_thread_num()
%27 = add nsw i32 %26, 1
%28 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %25, i32 6, i32 657)
%29 = tail call i32 (...) @omp_get_num_threads()
%30 = tail call i32 (...) @omp_get_thread_num()
%31 = add nsw i32 %30, 1
%32 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %31, i32 %29, i32 7, i32 456)
%33 = tail call i32 (...) @omp_get_num_threads()
%34 = tail call i32 (...) @omp_get_thread_num()
%35 = add nsw i32 %34, 1
%36 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %35, i32 %33, i32 8, i32 4)
%37 = tail call i32 (...) @omp_get_num_threads()
%38 = tail call i32 (...) @omp_get_thread_num()
%39 = add nsw i32 %38, 1
%40 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %39, i32 %37, i32 9, i32 45)
%41 = tail call i32 (...) @omp_get_num_threads()
%42 = tail call i32 (...) @omp_get_thread_num()
%43 = add nsw i32 %42, 1
%44 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %43, i32 %41, i32 10, i32 89)
%45 = tail call i32 (...) @omp_get_num_threads()
%46 = tail call i32 (...) @omp_get_thread_num()
%47 = add nsw i32 %46, 1
%48 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %47, i32 %45, i32 11, i32 20)
ret i32 0
}