#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 atoi(char *);
int omp_get_max_threads();
int omp_get_thread_num();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc != 2) {
    printf("ERROR: must pass in a number of threads to use!\n");
    return 7;
  }
  int threadArg = atoi(argv[1]);
  int thisThread = 0;
  int allThreads = 0;
#pragma omp parallel num_threads(threadArg)
  {
    thisThread = omp_get_thread_num();
    allThreads = omp_get_max_threads();
    printf("Hello, world!  From thread %d of %d, with love.\n", thisThread,
           allThreads);
  }
  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)
cmpl   $0x2,-0x8(%rbp)
je     117a <main+0x3a>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x7,-0x4(%rbp)
jmp    11c7 <main+0x87>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <omp_get_max_threads@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    116e <main+0x2e>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <omp_get_max_threads@plt>
lea    0xe9f(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    117f <main+0x3f>
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
mov    $0x7,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"ERROR: must pass in a number of threads to use!\0A\00"
@.str.1 = [49 x i8] c"Hello, world! From thread %d of %d, with love.\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
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
store i32 7, i32* %3
br label %23
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%18 = call i32 (...) @omp_get_thread_num()
store i32 %18, i32* %7
%19 = call i32 (...) @omp_get_max_threads()
store i32 %19, i32* %8
%20 = load i32, i32* %7
%21 = load i32, i32* %8
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %21)
store i32 0, i32* %3
br label %23
23: ; preds = %13, %11
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str.1 = [49 x i8] c"Hello, world! From thread %d of %d, with love.\0A\00"
@str = [48 x i8] c"ERROR: must pass in a number of threads to use!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
br label %10
6: ; preds = %2
%7 = tail call i32 (...) @omp_get_thread_num()
%8 = tail call i32 (...) @omp_get_max_threads()
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %8)
br label %10
10: ; preds = %6, %4
%11 = phi i32 [ 7, %4 ], [ 0, %6 ]
ret i32 %11
}