#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 EOF;
int /*<<< orphan*/ assert(int);
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int omp_get_num_threads();
int omp_get_thread_num();
int /*<<< orphan*/ omp_set_dynamic(int /*<<< orphan*/);
int /*<<< orphan*/ omp_set_num_threads(int);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int i;
  int optchar;
  int silent = 0;
  int tid;
  int num_iterations = 2;
  int num_threads = 2;
  while ((optchar = getopt(argc, argv, "hi:qt:")) != EOF) {
    switch (optchar) {
    case 'h':
      usage(argv[0]);
      return 1;
    case 'i':
      num_iterations = atoi(optarg);
      break;
    case 'q':
      silent = 1;
      break;
    case 't':
      num_threads = atoi(optarg);
      break;
    default:
      return 1;
    }
  }
  assert(num_iterations > 0);
  assert(num_threads > 0);
  omp_set_num_threads(num_threads);
  omp_set_dynamic(0);
#pragma omp parallel for private(tid)
  for (i = 0; i < num_iterations; i++) {
    tid = omp_get_thread_num();
    if (!silent) {
      fprintf(stderr,
              "iteration %d; thread number = %d; number of threads = %d\n", i,
              tid, omp_get_num_threads());
    } else {
      fprintf(stderr, "%s", "");
    }
  }
  fprintf(stderr, "Finished.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x2,-0x24(%rbp)
movl   $0x2,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe6b(%rip),%rdx
call   10a0 <getopt@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e08(%rip),%rcx
cmp    (%rcx),%eax
je     126a <main+0xda>
mov    -0x18(%rbp),%eax
add    $0xffffff98,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0xc,%eax
ja     1259 <main+0xc9>
mov    -0x30(%rbp),%rax
lea    0xe00(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    134f <main+0x1bf>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
call   10b0 <atoi@plt>
mov    %eax,-0x24(%rbp)
jmp    1265 <main+0xd5>
movl   $0x1,-0x1c(%rbp)
jmp    1265 <main+0xd5>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
call   10b0 <atoi@plt>
mov    %eax,-0x28(%rbp)
jmp    1265 <main+0xd5>
movl   $0x1,-0x4(%rbp)
jmp    134f <main+0x1bf>
jmp    11bb <main+0x2b>
cmpl   $0x0,-0x24(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
cmpl   $0x0,-0x28(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x28(%rbp),%edi
call   1080 <omp_set_num_threads@plt>
xor    %edi,%edi
call   1050 <omp_set_dynamic@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1331 <main+0x1a1>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1300 <main+0x170>
mov    0x2d07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1040 <omp_get_num_threads@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    %eax,%r8d
lea    0xd47(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    131e <main+0x18e>
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
lea    0xd65(%rip),%rsi
lea    0xd6b(%rip),%rdx
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1323 <main+0x193>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12a2 <main+0x112>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
lea    0xd37(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xe8d(%rip),%rdx
call   10a0 <getopt@plt>
mov    0x2e2d(%rip),%rcx
cmp    (%rcx),%eax
jne    128c <main+0xfc>
mov    $0x2,%ebx
xor    %r13d,%r13d
movl   $0x2,0x4(%rsp)
xor    %edi,%edi
test   %ebx,%ebx
setg   %dil
call   1060 <assert@plt>
xor    %edi,%edi
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
setg   %dil
call   1060 <assert@plt>
mov    %ebp,%edi
call   1080 <omp_set_num_threads@plt>
xor    %edi,%edi
call   1050 <omp_set_dynamic@plt>
test   %ebx,%ebx
jle    1264 <main+0xd4>
mov    0x2dce(%rip),%r12
xor    %ebp,%ebp
jmp    122f <main+0x9f>
cs nopw 0x0(%rax,%rax,1)
mov    %r15d,%edi
lea    0xe5b(%rip),%rsi
lea    0xe61(%rip),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
je     1264 <main+0xd4>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    (%r12),%r15d
test   %r13d,%r13d
jne    1210 <main+0x80>
mov    %eax,%r14d
xor    %eax,%eax
call   1040 <omp_get_num_threads@plt>
mov    %r15d,%edi
lea    0xde8(%rip),%rsi
mov    %ebp,%edx
mov    %r14d,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1228 <main+0x98>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
lea    0xe04(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r12d,%r12d
movl   $0x2,0x4(%rsp)
lea    0xd62(%rip),%r14
mov    $0x2,%ebx
jmp    12e8 <main+0x158>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
call   10b0 <atoi@plt>
mov    %eax,0x4(%rsp)
mov    %r12d,%r13d
mov    %ebp,%edi
mov    %r15,%rsi
lea    0xd63(%rip),%rdx
call   10a0 <getopt@plt>
mov    %r13d,%r12d
mov    0x2d00(%rip),%rcx
cmp    (%rcx),%eax
je     11cb <main+0x3b>
add    $0xffffff98,%eax
cmp    $0xc,%eax
ja     1319 <main+0x189>
mov    $0x1,%r13d
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
mov    0x2cf2(%rip),%rax
mov    (%rax),%edi
call   10b0 <atoi@plt>
mov    %eax,%ebx
jmp    12c2 <main+0x132>
mov    (%r15),%rdi
call   1090 <usage@plt>
mov    $0x1,%eax
jmp    127d <main+0xed>

LLVM IR (-O0):
@.str = [7 x i8] c"hi:qt:\00"
@EOF = global i32 0
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [58 x i8] c"iteration %d; thread number = %d; number of threads = %d\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [11 x i8] c"Finished.\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
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 2, i32* %10
store i32 2, i32* %11
br label %12
12: ; preds = %33, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %7
%16 = load i32, i32* @EOF
%17 = icmp ne i32 %15, %16
br i1 %17, label %18, label %34
18: ; preds = %12
%19 = load i32, i32* %7
switch i32 %19, label %32 [
i32 104, label %20
i32 105, label %25
i32 113, label %28
i32 116, label %29
]
20: ; preds = %18
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @usage(i8* %23)
store i32 1, i32* %3
br label %70
25: ; preds = %18
%26 = load i32, i32* @optarg
%27 = call i32 @atoi(i32 %26)
store i32 %27, i32* %10
br label %33
28: ; preds = %18
store i32 1, i32* %8
br label %33
29: ; preds = %18
%30 = load i32, i32* @optarg
%31 = call i32 @atoi(i32 %30)
store i32 %31, i32* %11
br label %33
32: ; preds = %18
store i32 1, i32* %3
br label %70
33: ; preds = %29, %28, %25
br label %12
34: ; preds = %12
%35 = load i32, i32* %10
%36 = icmp sgt i32 %35, 0
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i32, i32* %11
%40 = icmp sgt i32 %39, 0
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = load i32, i32* %11
%44 = call i32 @omp_set_num_threads(i32 %43)
%45 = call i32 @omp_set_dynamic(i32 0)
store i32 0, i32* %6
br label %46
46: ; preds = %64, %34
%47 = load i32, i32* %6
%48 = load i32, i32* %10
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %67
50: ; preds = %46
%51 = call i32 (...) @omp_get_thread_num()
store i32 %51, i32* %9
%52 = load i32, i32* %8
%53 = icmp ne i32 %52, 0
br i1 %53, label %60, label %54
54: ; preds = %50
%55 = load i32, i32* @stderr
%56 = load i32, i32* %6
%57 = load i32, i32* %9
%58 = call i32 (...) @omp_get_num_threads()
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i32 %56, i32 %57, i32 %58)
br label %63
60: ; preds = %50
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %63
63: ; preds = %60, %54
br label %64
64: ; preds = %63
%65 = load i32, i32* %6
%66 = add nsw i32 %65, 1
store i32 %66, i32* %6
br label %46
67: ; preds = %46
%68 = load i32, i32* @stderr
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %70
70: ; preds = %67, %32, %20
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
@.str = [7 x i8] c"hi:qt:\00"
@EOF = global i32 0
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [58 x i8] c"iteration %d; thread number = %d; number of threads = %d\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [11 x i8] c"Finished.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %27, label %6
6: ; preds = %2, %20
%7 = phi i32 [ %24, %20 ], [ %3, %2 ]
%8 = phi i32 [ %23, %20 ], [ 2, %2 ]
%9 = phi i32 [ %22, %20 ], [ 2, %2 ]
%10 = phi i32 [ %21, %20 ], [ 0, %2 ]
switch i32 %7, label %56 [
i32 104, label %11
i32 105, label %14
i32 113, label %20
i32 116, label %17
]
11: ; preds = %6
%12 = load i8*, i8** %1
%13 = tail call i32 @usage(i8* %12)
br label %56
14: ; preds = %6
%15 = load i32, i32* @optarg
%16 = tail call i32 @atoi(i32 %15)
br label %20
17: ; preds = %6
%18 = load i32, i32* @optarg
%19 = tail call i32 @atoi(i32 %18)
br label %20
20: ; preds = %6, %17, %14
%21 = phi i32 [ %10, %17 ], [ %10, %14 ], [ 1, %6 ]
%22 = phi i32 [ %9, %17 ], [ %16, %14 ], [ %9, %6 ]
%23 = phi i32 [ %19, %17 ], [ %8, %14 ], [ %8, %6 ]
%24 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %6
27: ; preds = %20, %2
%28 = phi i32 [ 0, %2 ], [ %21, %20 ]
%29 = phi i32 [ 2, %2 ], [ %22, %20 ]
%30 = phi i32 [ 2, %2 ], [ %23, %20 ]
%31 = icmp sgt i32 %29, 0
%32 = zext i1 %31 to i32
%33 = tail call i32 @assert(i32 %32)
%34 = icmp sgt i32 %30, 0
%35 = zext i1 %34 to i32
%36 = tail call i32 @assert(i32 %35)
%37 = tail call i32 @omp_set_num_threads(i32 %30)
%38 = tail call i32 @omp_set_dynamic(i32 0)
br i1 %31, label %39, label %53
39: ; preds = %27
%40 = icmp eq i32 %28, 0
br label %41
41: ; preds = %39, %50
%42 = phi i32 [ 0, %39 ], [ %51, %50 ]
%43 = tail call i32 (...) @omp_get_thread_num()
%44 = load i32, i32* @stderr
br i1 %40, label %45, label %48
45: ; preds = %41
%46 = tail call i32 (...) @omp_get_num_threads()
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i32 %42, i32 %43, i32 %46)
br label %50
48: ; preds = %41
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %50
50: ; preds = %45, %48
%51 = add nuw nsw i32 %42, 1
%52 = icmp eq i32 %51, %29
br i1 %52, label %53, label %41
53: ; preds = %50, %27
%54 = load i32, i32* @stderr
%55 = tail call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %56
56: ; preds = %6, %53, %11
%57 = phi i32 [ 1, %11 ], [ 0, %53 ], [ 1, %6 ]
ret i32 %57
}