#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*/ atoi(char *);
int omp_get_thread_num();
int /*<<< orphan*/ omp_set_num_threads(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  const int REPS = 16;
  printf("\n");
  if (argc > 1) {
    omp_set_num_threads(atoi(argv[1]));
  }
#pragma omp parallel for schedule(static, 1)
  for (int i = 0; i < REPS; i++) {
    int id = omp_get_thread_num();
    printf("Thread %d performed iteration %d\n", id, i);
  }
  printf("\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   $0x10,-0x14(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1189 <main+0x49>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
call   1050 <omp_set_num_threads@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x10,-0x18(%rbp)
jge    11c6 <main+0x86>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1190 <main+0x50>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0x2,%ebp
jl     1177 <main+0x27>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
call   1060 <omp_set_num_threads@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    0xe7b(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x4,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x6,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x7,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x8,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x9,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xa,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xb,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xc,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xd,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xe,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xf,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [34 x i8] c"Thread %d performed iteration %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 16, i32* %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
%17 = call i32 @omp_set_num_threads(i32 %16)
br label %18
18: ; preds = %12, %2
store i32 0, i32* %7
br label %19
19: ; preds = %27, %18
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 16
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = call i32 (...) @omp_get_thread_num()
store i32 %23, i32* %8
%24 = load i32, i32* %8
%25 = load i32, i32* %7
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %25)
br label %27
27: ; preds = %22
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %19
30: ; preds = %19
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [34 x i8] c"Thread %d performed iteration %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @putchar(i32 10)
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @atoi(i8* %7)
%9 = tail call i32 @omp_set_num_threads(i32 %8)
br label %10
10: ; preds = %5, %2
%11 = tail call i32 (...) @omp_get_thread_num()
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 0)
%13 = tail call i32 (...) @omp_get_thread_num()
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 1)
%15 = tail call i32 (...) @omp_get_thread_num()
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 2)
%17 = tail call i32 (...) @omp_get_thread_num()
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 3)
%19 = tail call i32 (...) @omp_get_thread_num()
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 4)
%21 = tail call i32 (...) @omp_get_thread_num()
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 5)
%23 = tail call i32 (...) @omp_get_thread_num()
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 6)
%25 = tail call i32 (...) @omp_get_thread_num()
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 7)
%27 = tail call i32 (...) @omp_get_thread_num()
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 8)
%29 = tail call i32 (...) @omp_get_thread_num()
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 9)
%31 = tail call i32 (...) @omp_get_thread_num()
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 10)
%33 = tail call i32 (...) @omp_get_thread_num()
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 11)
%35 = tail call i32 (...) @omp_get_thread_num()
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 12)
%37 = tail call i32 (...) @omp_get_thread_num()
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 13)
%39 = tail call i32 (...) @omp_get_thread_num()
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %39, i32 14)
%41 = tail call i32 (...) @omp_get_thread_num()
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %41, i32 15)
%43 = tail call i32 @putchar(i32 10)
ret i32 0
}