#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_thread_num();
int /*<<< orphan*/ printf(char *, int, int, int);
int main() {
  int A[16], i;
#pragma omp parallel for schedule(static, 2) num_threads(4) ordered
  for (i = 0; i < 16; i++) {
    A[i] = i * i;
#pragma omp ordered
    { printf("Th[ %d ]: %02d = %03d\n", omp_get_thread_num(), i, A[i]); }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x10,-0x54(%rbp)
jge    117d <main+0x5d>
mov    -0x54(%rbp),%ecx
imul   -0x54(%rbp),%ecx
movslq -0x54(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,%esi
mov    -0x54(%rbp),%edx
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%ecx
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0xed1(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x2,%edx
mov    $0x4,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x3,%edx
mov    $0x9,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x4,%edx
mov    $0x10,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x5,%edx
mov    $0x19,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x6,%edx
mov    $0x24,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x7,%edx
mov    $0x31,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x8,%edx
mov    $0x40,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x9,%edx
mov    $0x51,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xa,%edx
mov    $0x64,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xb,%edx
mov    $0x79,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xc,%edx
mov    $0x90,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xd,%edx
mov    $0xa9,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xe,%edx
mov    $0xc4,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xf,%edx
mov    $0xe1,%ecx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Th[ %d ]: %02d = %03d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i32]
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %21, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 16
br i1 %6, label %7, label %24
7: ; preds = %4
%8 = load i32, i32* %3
%9 = load i32, i32* %3
%10 = mul nsw i32 %8, %9
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 %12
store i32 %10, i32* %13
%14 = call i32 (...) @omp_get_thread_num()
%15 = load i32, i32* %3
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15, i32 %19)
br label %21
21: ; preds = %7
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %4
24: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Th[ %d ]: %02d = %03d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @omp_get_thread_num()
%2 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %1, i32 0, i32 0)
%3 = tail call i32 (...) @omp_get_thread_num()
%4 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %3, i32 1, i32 1)
%5 = tail call i32 (...) @omp_get_thread_num()
%6 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %5, i32 2, i32 4)
%7 = tail call i32 (...) @omp_get_thread_num()
%8 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %7, i32 3, i32 9)
%9 = tail call i32 (...) @omp_get_thread_num()
%10 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %9, i32 4, i32 16)
%11 = tail call i32 (...) @omp_get_thread_num()
%12 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %11, i32 5, i32 25)
%13 = tail call i32 (...) @omp_get_thread_num()
%14 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %13, i32 6, i32 36)
%15 = tail call i32 (...) @omp_get_thread_num()
%16 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %15, i32 7, i32 49)
%17 = tail call i32 (...) @omp_get_thread_num()
%18 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %17, i32 8, i32 64)
%19 = tail call i32 (...) @omp_get_thread_num()
%20 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %19, i32 9, i32 81)
%21 = tail call i32 (...) @omp_get_thread_num()
%22 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %21, i32 10, i32 100)
%23 = tail call i32 (...) @omp_get_thread_num()
%24 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %23, i32 11, i32 121)
%25 = tail call i32 (...) @omp_get_thread_num()
%26 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %25, i32 12, i32 144)
%27 = tail call i32 (...) @omp_get_thread_num()
%28 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %27, i32 13, i32 169)
%29 = tail call i32 (...) @omp_get_thread_num()
%30 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %29, i32 14, i32 196)
%31 = tail call i32 (...) @omp_get_thread_num()
%32 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %31, i32 15, i32 225)
ret i32 0
}