#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*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
int omp_get_num_threads();
int omp_get_thread_num();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int i;
  int optchar;
  int silent = 0;
  int tid;
  while ((optchar = getopt(argc, argv, "hq")) != EOF) {
    switch (optchar) {
    case 'h':
      usage(argv[0]);
      return 1;
    case 'q':
      silent = 1;
      break;
    default:
      return 1;
    }
  }
#pragma omp parallel private(tid)
  for (i = 0; i < 2; i++) {
    tid = omp_get_thread_num();
    if (!silent) {
      printf("omp_get_thread_num() = %d/%d\n", tid, omp_get_num_threads());
    } else {
      printf("%s", "");
    }
  }
  fprintf(stderr, "Finished.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe75(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e4e(%rip),%rcx
cmp    (%rcx),%eax
je     11fc <main+0x9c>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x68,%eax
je     11c7 <main+0x67>
jmp    11b6 <main+0x56>
mov    -0x24(%rbp),%eax
sub    $0x71,%eax
je     11df <main+0x7f>
jmp    11eb <main+0x8b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    128a <main+0x12a>
movl   $0x1,-0x1c(%rbp)
jmp    11f7 <main+0x97>
movl   $0x1,-0x4(%rbp)
jmp    128a <main+0x12a>
jmp    117d <main+0x1d>
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    126e <main+0x10e>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1246 <main+0xe6>
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1050 <omp_get_num_threads@plt>
mov    -0x28(%rbp),%esi
mov    %eax,%edx
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125b <main+0xfb>
lea    0xdd4(%rip),%rdi
lea    0xdda(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1260 <main+0x100>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1203 <main+0xa3>
mov    0x2d63(%rip),%rax
mov    (%rax),%edi
lea    0xda6(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%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,%rbx
mov    %edi,%ebp
lea    0xe89(%rip),%rdx
call   1080 <getopt@plt>
mov    0x2e65(%rip),%r13
mov    0x0(%r13),%r12d
cmp    %r12d,%eax
jne    11e8 <main+0x88>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
lea    0xe60(%rip),%rbp
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
lea    0xe42(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
jmp    1243 <main+0xe3>
mov    %eax,%r14d
lea    0xe0e(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x71,%eax
jne    1231 <main+0xd1>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1080 <getopt@plt>
cmp    0x0(%r13),%eax
jne    1200 <main+0xa0>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
cmp    %r12d,%r14d
je     1193 <main+0x33>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
jmp    11cf <main+0x6f>
cmp    $0x68,%eax
jne    123e <main+0xde>
mov    (%rbx),%rdi
call   1070 <usage@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"hq\00"
@EOF = global i32 0
@.str.1 = [30 x i8] c"omp_get_thread_num() = %d/%d\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [1 x i8] zeroinitializer
@stderr = global i32 0
@.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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
br label %10
10: ; preds = %25, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %7
%14 = load i32, i32* @EOF
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %10
%17 = load i32, i32* %7
switch i32 %17, label %24 [
i32 104, label %18
i32 113, label %23
]
18: ; preds = %16
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 @usage(i8* %21)
store i32 1, i32* %3
br label %47
23: ; preds = %16
store i32 1, i32* %8
br label %25
24: ; preds = %16
store i32 1, i32* %3
br label %47
25: ; preds = %23
br label %10
26: ; preds = %10
store i32 0, i32* %6
br label %27
27: ; preds = %41, %26
%28 = load i32, i32* %6
%29 = icmp slt i32 %28, 2
br i1 %29, label %30, label %44
30: ; preds = %27
%31 = call i32 (...) @omp_get_thread_num()
store i32 %31, i32* %9
%32 = load i32, i32* %8
%33 = icmp ne i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load i32, i32* %9
%36 = call i32 (...) @omp_get_num_threads()
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %36)
br label %40
38: ; preds = %30
%39 = call i32 (i8*, ...) @printf(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 %40
40: ; preds = %38, %34
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %27
44: ; preds = %27
%45 = load i32, i32* @stderr
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %47
47: ; preds = %44, %24, %18
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@.str = [3 x i8] c"hq\00"
@EOF = global i32 0
@.str.1 = [30 x i8] c"omp_get_thread_num() = %d/%d\0A\00"
@stderr = global i32 0
@.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 ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = tail call i32 (...) @omp_get_thread_num()
br label %21
8: ; preds = %14
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = tail call i32 (...) @omp_get_thread_num()
br i1 %5, label %21, label %19
14: ; preds = %2, %8
%15 = phi i32 [ %9, %8 ], [ %3, %2 ]
switch i32 %15, label %31 [
i32 104, label %16
i32 113, label %8
]
16: ; preds = %14
%17 = load i8*, i8** %1
%18 = tail call i32 @usage(i8* %17)
br label %31
19: ; preds = %12
%20 = tail call i32 (...) @omp_get_thread_num()
br label %28
21: ; preds = %12, %6
%22 = phi i32 [ %7, %6 ], [ %13, %12 ]
%23 = tail call i32 (...) @omp_get_num_threads()
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23)
%25 = tail call i32 (...) @omp_get_thread_num()
%26 = tail call i32 (...) @omp_get_num_threads()
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %26)
br label %28
28: ; preds = %19, %21
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %14, %28, %16
%32 = phi i32 [ 1, %16 ], [ 0, %28 ], [ 1, %14 ]
ret i32 %32
}