#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*/ omp_set_num_threads(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int a[100], b[100], c[100];
  int n, i;
  omp_set_num_threads(5);
  printf("Enter n\n");
  scanf("%d", &n);
  printf("Enter elements of array1\n");
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);
  printf("Enter elements of array2\n");
  for (i = 0; i < n; i++)
    scanf("%d", &b[i]);
#pragma omp parallel for shared(c) private(i)
  for (i = 0; i < n; i++) {
    c[i] = a[i] + b[i];
    printf("Thread %d \n", omp_get_thread_num());
  }
  printf("Result\n");
  for (i = 0; i < n; i++)
    printf("%d\n", c[i]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x5,%edi
call   1050 <omp_set_num_threads@plt>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe98(%rip),%rdi
lea    -0x4c4(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4c8(%rbp)
mov    -0x4c8(%rbp),%eax
cmp    -0x4c4(%rbp),%eax
jge    11dc <main+0x9c>
movslq -0x4c8(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe46(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x4c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c8(%rbp)
jmp    1195 <main+0x55>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4c8(%rbp)
mov    -0x4c8(%rbp),%eax
cmp    -0x4c4(%rbp),%eax
jge    123b <main+0xfb>
movslq -0x4c8(%rbp),%rax
lea    -0x330(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xde7(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x4c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c8(%rbp)
jmp    11f4 <main+0xb4>
movl   $0x0,-0x4c8(%rbp)
mov    -0x4c8(%rbp),%eax
cmp    -0x4c4(%rbp),%eax
jge    12ac <main+0x16c>
movslq -0x4c8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%ecx
movslq -0x4c8(%rbp),%rax
add    -0x330(%rbp,%rax,4),%ecx
movslq -0x4c8(%rbp),%rax
mov    %ecx,-0x4c0(%rbp,%rax,4)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,%esi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c8(%rbp)
jmp    1245 <main+0x105>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4c8(%rbp)
mov    -0x4c8(%rbp),%eax
cmp    -0x4c4(%rbp),%eax
jge    1306 <main+0x1c6>
movslq -0x4c8(%rbp),%rax
mov    -0x4c0(%rbp,%rax,4),%esi
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c8(%rbp)
jmp    12c4 <main+0x184>
mov    -0x4(%rbp),%eax
add    $0x4d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x4c0,%rsp
mov    $0x5,%edi
call   1060 <omp_set_num_threads@plt>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe87(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    11cd <main+0x7d>
lea    0x330(%rsp),%r15
xor    %ebx,%ebx
lea    0xe59(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     11b0 <main+0x60>
lea    0xe60(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    1263 <main+0x113>
lea    0x1a0(%rsp),%r15
xor    %ebx,%ebx
lea    0xe0b(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     1200 <main+0xb0>
test   %eax,%eax
jle    1263 <main+0x113>
lea    0xddb(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    0x1a0(%rsp,%rbx,4),%eax
add    0x330(%rsp,%rbx,4),%eax
mov    %eax,0x10(%rsp,%rbx,4)
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1230 <main+0xe0>
lea    0xde3(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    129c <main+0x14c>
lea    0xd92(%rip),%r14
xor    %ebx,%ebx
nop
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1280 <main+0x130>
xor    %eax,%eax
add    $0x4c0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Enter n\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"Enter elements of array1\0A\00"
@.str.3 = [26 x i8] c"Enter elements of array2\0A\00"
@.str.4 = [12 x i8] c"Thread %d \0A\00"
@.str.5 = [8 x i8] c"Result\0A\00"
@.str.6 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca [100 x i32]
%4 = alloca [100 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @omp_set_num_threads(i32 5)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %11
11: ; preds = %20, %0
%12 = load i32, i32* %6
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %17
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
br label %20
20: ; preds = %15
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %11
23: ; preds = %11
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %6
br label %25
25: ; preds = %34, %23
%26 = load i32, i32* %6
%27 = load i32, i32* %5
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %37
29: ; preds = %25
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %31
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %32)
br label %34
34: ; preds = %29
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %25
37: ; preds = %25
store i32 0, i32* %6
br label %38
38: ; preds = %57, %37
%39 = load i32, i32* %6
%40 = load i32, i32* %5
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %60
42: ; preds = %38
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = add nsw i32 %46, %50
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %53
store i32 %51, i32* %54
%55 = call i32 (...) @omp_get_thread_num()
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %42
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %38
60: ; preds = %38
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %6
br label %62
62: ; preds = %72, %60
%63 = load i32, i32* %6
%64 = load i32, i32* %5
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %75
66: ; preds = %62
%67 = load i32, i32* %6
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %68
%70 = load i32, i32* %69
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %66
%73 = load i32, i32* %6
%74 = add nsw i32 %73, 1
store i32 %74, i32* %6
br label %62
75: ; preds = %62
%76 = load i32, i32* %1
ret i32 %76
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [12 x i8] c"Thread %d \0A\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@str = [8 x i8] c"Enter n\00"
@str.7 = [25 x i8] c"Enter elements of array1\00"
@str.8 = [25 x i8] c"Enter elements of array2\00"
@str.9 = [7 x i8] c"Result\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca [100 x i32]
%3 = alloca [100 x i32]
%4 = alloca i32
%5 = bitcast [100 x i32]* %1 to i8*
%6 = bitcast [100 x i32]* %2 to i8*
%7 = bitcast [100 x i32]* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = tail call i32 @omp_set_num_threads(i32 5)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.7, i64 0, i64 0))
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %0, %15
%16 = phi i64 [ %19, %15 ], [ 0, %0 ]
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = add nuw nsw i64 %16, 1
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %15, label %23
23: ; preds = %15, %0
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.8, i64 0, i64 0))
%25 = load i32, i32* %4
%26 = icmp sgt i32 %25, 0
br i1 %26, label %29, label %51
27: ; preds = %29
%28 = icmp sgt i32 %34, 0
br i1 %28, label %37, label %51
29: ; preds = %23, %29
%30 = phi i64 [ %33, %29 ], [ 0, %23 ]
%31 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %30
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %31)
%33 = add nuw nsw i64 %30, 1
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %33, %35
br i1 %36, label %29, label %27
37: ; preds = %27, %37
%38 = phi i64 [ %47, %37 ], [ 0, %27 ]
%39 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %38
%42 = load i32, i32* %41
%43 = add nsw i32 %42, %40
%44 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %38
store i32 %43, i32* %44
%45 = call i32 (...) @omp_get_thread_num()
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %45)
%47 = add nuw nsw i64 %38, 1
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = icmp slt i64 %47, %49
br i1 %50, label %37, label %51
51: ; preds = %37, %23, %27
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.9, i64 0, i64 0))
%53 = load i32, i32* %4
%54 = icmp sgt i32 %53, 0
br i1 %54, label %55, label %64
55: ; preds = %51, %55
%56 = phi i64 [ %60, %55 ], [ 0, %51 ]
%57 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %58)
%60 = add nuw nsw i64 %56, 1
%61 = load i32, i32* %4
%62 = sext i32 %61 to i64
%63 = icmp slt i64 %60, %62
br i1 %63, label %55, label %64
64: ; preds = %55, %51
ret i32 0
}