#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 fib(int);
int omp_get_num_threads();
int /*<<< orphan*/ omp_set_num_threads(int);
int /*<<< orphan*/ printf(char *, ...);
int random_num();
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int fibno[100] = {0};
  int i, j, temp, n, tid;
  printf("Enter the no range :");
  scanf("%d", &n);
  omp_set_num_threads(2);
#pragma omp parallel
  {
    printf("No of threads ; %d\n", omp_get_num_threads());
#pragma omp for private(tid, temp, fibno)
    for (j = 1; j <= n; j++) {
      temp = random_num();
      printf("Thread id %d\n", tid);
#pragma omp critical
      {
        for (i = 0; i < temp; i++)
          fibno[i] = fib(i);
        printf("No of values in the series \n");
        for (i = 0; i < temp; i++)
          printf("%d\t", fibno[i]);
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6b(%rip),%rdi
lea    -0x1b0(%rbp),%rsi
call   1080 <scanf@plt>
mov    $0x2,%edi
call   1070 <omp_set_num_threads@plt>
mov    $0x0,%al
call   1050 <omp_get_num_threads@plt>
mov    %eax,%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1b0(%rbp),%eax
jg     12d2 <main+0x162>
mov    $0x0,%al
call   1060 <random_num@plt>
mov    %eax,-0x1ac(%rbp)
mov    -0x1b4(%rbp),%esi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x1ac(%rbp),%eax
jge    125f <main+0xef>
mov    -0x1a4(%rbp),%edi
call   1090 <fib@plt>
mov    %eax,%ecx
movslq -0x1a4(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    121e <main+0xae>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a4(%rbp)
mov    -0x1a4(%rbp),%eax
cmp    -0x1ac(%rbp),%eax
jge    12b9 <main+0x149>
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    1277 <main+0x107>
jmp    12be <main+0x14e>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    11e1 <main+0x71>
mov    -0x4(%rbp),%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0x10(%rsp),%rdi
mov    $0x190,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5e(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1090 <scanf@plt>
mov    $0x2,%edi
call   1080 <omp_set_num_threads@plt>
xor    %eax,%eax
call   1060 <omp_get_num_threads@plt>
lea    0xe3f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    129c <main+0x11c>
mov    $0x1,%r13d
lea    0xe44(%rip),%r15
lea    0xe39(%rip),%rbx
jmp    1226 <main+0xa6>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1030 <puts@plt>
lea    0x1(%r13),%eax
cmp    0xc(%rsp),%r13d
mov    %eax,%r13d
jge    129c <main+0x11c>
xor    %eax,%eax
call   1070 <random_num@plt>
mov    %eax,%r12d
lea    0xdf5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r12d,%r12d
jle    1210 <main+0x90>
mov    %r12d,%r14d
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   10a0 <fib@plt>
mov    %eax,0x10(%rsp,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1250 <main+0xd0>
mov    %r15,%rdi
call   1030 <puts@plt>
test   %r12d,%r12d
jle    1218 <main+0x98>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%rsp,%rbp,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1280 <main+0x100>
jmp    1218 <main+0x98>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Enter the no range :\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"No of threads ; %d\0A\00"
@.str.3 = [14 x i8] c"Thread id %d\0A\00"
@.str.4 = [29 x i8] c"No of values in the series \0A\00"
@.str.5 = [4 x i8] c"%d\09\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [100 x i32]* %2 to i8*
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%11 = call i32 @omp_set_num_threads(i32 2)
%12 = call i32 (...) @omp_get_num_threads()
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %12)
store i32 1, i32* %4
br label %14
14: ; preds = %51, %0
%15 = load i32, i32* %4
%16 = load i32, i32* %6
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %54
18: ; preds = %14
%19 = call i32 (...) @random_num()
store i32 %19, i32* %5
%20 = load i32, i32* %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %20)
store i32 0, i32* %3
br label %22
22: ; preds = %32, %18
%23 = load i32, i32* %3
%24 = load i32, i32* %5
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = load i32, i32* %3
%28 = call i32 @fib(i32 %27)
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %30
store i32 %28, i32* %31
br label %32
32: ; preds = %26
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %22
35: ; preds = %22
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %37
37: ; preds = %47, %35
%38 = load i32, i32* %3
%39 = load i32, i32* %5
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %50
41: ; preds = %37
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %41
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 1
store i32 %49, i32* %3
br label %37
50: ; preds = %37
br label %51
51: ; preds = %50
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
br label %14
54: ; preds = %14
%55 = load i32, i32* %1
ret i32 %55
}

LLVM IR (-O2):
@.str = [21 x i8] c"Enter the no range :\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"No of threads ; %d\0A\00"
@.str.3 = [14 x i8] c"Thread id %d\0A\00"
@.str.5 = [4 x i8] c"%d\09\00"
@str = [28 x i8] c"No of values in the series \00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = bitcast [100 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 @omp_set_num_threads(i32 2)
%8 = call i32 (...) @omp_get_num_threads()
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 1
br i1 %11, label %43, label %12
12: ; preds = %0, %39
%13 = phi i32 [ %40, %39 ], [ 1, %0 ]
%14 = call i32 (...) @random_num()
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 undef)
%16 = icmp sgt i32 %14, 0
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %39
19: ; preds = %12
%20 = zext i32 %14 to i64
br label %21
21: ; preds = %19, %21
%22 = phi i64 [ 0, %19 ], [ %26, %21 ]
%23 = trunc i64 %22 to i32
%24 = call i32 @fib(i32 %23)
%25 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %22
store i32 %24, i32* %25
%26 = add nuw nsw i64 %22, 1
%27 = icmp eq i64 %26, %20
br i1 %27, label %28, label %21
28: ; preds = %21
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br i1 %16, label %30, label %39
30: ; preds = %28
%31 = zext i32 %14 to i64
br label %32
32: ; preds = %30, %32
%33 = phi i64 [ 0, %30 ], [ %37, %32 ]
%34 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%37 = add nuw nsw i64 %33, 1
%38 = icmp eq i64 %37, %31
br i1 %38, label %39, label %32
39: ; preds = %32, %17, %28
%40 = add nuw nsw i32 %13, 1
%41 = load i32, i32* %2
%42 = icmp slt i32 %13, %41
br i1 %42, label %12, label %43
43: ; preds = %39, %0
ret i32 0
}