#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 *, ...);
main(int argc, char **argv) {
  int threadid, Noofthreads;
  printf("\n\t\t---------------------------------------------------------------"
         "------------");
  printf("\n\t\t Email : RarchK");
  printf("\n\t\t---------------------------------------------------------------"
         "------------");
  printf("\n\t\t Objective : OpenMP program to print unique thread identifier "
         "for ");
  printf("\n\t\t each thread using OpenMP PARALLEL directive.");
  printf("\n\t\t..............................................................."
         "...........\n");
  printf("\n\n\t\t Master thread  prints this before forking the team of "
         "thread \n");
#pragma omp parallel private(threadid)
  {
    threadid = omp_get_thread_num();
    printf("\n\t\t My thread id is : %d\n", threadid);
  }
  printf(
      "\n\t\t Master thread  prints this after the end parallel region \n \n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xfc7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xfd3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf06(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf01(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf39(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf76(%rip),%rdi
call   1030 <puts@plt>
lea    0xfb8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    0xf3d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xfd8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [79 x i8] c"\0A\09\09---------------------------------------------------------------------------\00"
@.str.1 = [19 x i8] c"\0A\09\09 Email : RarchK\00"
@.str.2 = [70 x i8] c"\0A\09\09 Objective : OpenMP program to print unique thread identifier for \00"
@.str.3 = [49 x i8] c"\0A\09\09 each thread using OpenMP PARALLEL directive.\00"
@.str.4 = [79 x i8] c"\0A\09\09..........................................................................\0A\00"
@.str.5 = [68 x i8] c"\0A\0A\09\09 Master thread prints this before forking the team of thread \0A\00"
@.str.6 = [26 x i8] c"\0A\09\09 My thread id is : %d\0A\00"
@.str.7 = [65 x i8] c"\0A\09\09 Master thread prints this after the end parallel region \0A \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 (...) @omp_get_thread_num()
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [79 x i8] c"\0A\09\09---------------------------------------------------------------------------\00"
@.str.1 = [19 x i8] c"\0A\09\09 Email : RarchK\00"
@.str.2 = [70 x i8] c"\0A\09\09 Objective : OpenMP program to print unique thread identifier for \00"
@.str.3 = [49 x i8] c"\0A\09\09 each thread using OpenMP PARALLEL directive.\00"
@.str.6 = [26 x i8] c"\0A\09\09 My thread id is : %d\0A\00"
@str = [78 x i8] c"\0A\09\09..........................................................................\00"
@str.8 = [67 x i8] c"\0A\0A\09\09 Master thread prints this before forking the team of thread \00"
@str.9 = [64 x i8] c"\0A\09\09 Master thread prints this after the end parallel region \0A \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.8, i64 0, i64 0))
%10 = tail call i32 (...) @omp_get_thread_num()
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %10)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.9, i64 0, i64 0))
ret i32 0
}