#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(float *);
scalar_t__ malloc(int);
int /*<<< orphan*/ omp_set_num_threads(int);
int /*<<< orphan*/ printf(char *, ...);
main(int argc, char **argv) {
  float *array_A, sum, *checkarray, serialsum;
  int arraysize, i, k, Noofthreads;
  printf("\n\t\t---------------------------------------------------------------"
         "------------");
  printf("\n\t\t Email : RarchK");
  printf("\n\t\t---------------------------------------------------------------"
         "------------");
  printf("\n\t\t Objective : Find the Sum of elements of one-dimensional real "
         "array  ");
  printf("\n\t\t using OpenMP Parallel for directive and Reduction Clause  ");
  printf("\n\t\t..............................................................."
         "...........\n");
  if (argc != 3) {
    printf("\t\t Very Few Arguments\n ");
    printf("\t\t Syntax : exec <Threads> <array-size> \n");
    exit(-1);
  }
  Noofthreads = atoi(argv[1]);
  if ((Noofthreads != 1) && (Noofthreads != 2) && (Noofthreads != 4) &&
      (Noofthreads != 8) && (Noofthreads != 16)) {
    printf("\n\t\t Number of threads should be 1,2,4,8 or 16 for the execution "
           "of program. \n\n");
    exit(-1);
  }
  arraysize = atoi(argv[2]);
  if (arraysize <= 0) {
    printf("\n\t\t Positive Number Required\n");
    exit(1);
  }
  printf("\n\t\t Threads     : %d ", Noofthreads);
  printf("\n\t\t Array Size  : %d", arraysize);
  array_A = (float *)malloc(sizeof(float) * arraysize);
  checkarray = (float *)malloc(sizeof(float) * arraysize);
  for (i = 0; i < arraysize; i++) {
    array_A[i] = i + 5;
    checkarray[i] = array_A[i];
  }
  sum = 0.0;
  omp_set_num_threads(Noofthreads);
#pragma omp parallel for reduction(+ : sum)
  for (i = 0; i < arraysize; i++) {
    sum = sum + array_A[i];
  }
  serialsum = 0.0;
  for (i = 0; i < arraysize; i++)
    serialsum = serialsum + checkarray[i];
  if (serialsum != sum) {
    printf("\n\n\t\t The parallel calculation of array sum is different from "
           "serial calculation \n");
    exit(-1);
  } else
    printf("\n\n\t\t The parallel calculation of array sum is same with serial "
           "calculation \n");
  free(checkarray);
  free(array_A);
  printf(
      "\n\t\t The SumOfElements Of The Array Using OpenMP Directives Is %f\n",
      sum);
  printf("\t\t The SumOfElements Of The Array By Serial Calculation Is  %f\n\n",
         serialsum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x3,-0x8(%rbp)
je     11fa <main+0x9a>
lea    0xf5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x1,-0x3c(%rbp)
je     1254 <main+0xf4>
cmpl   $0x2,-0x3c(%rbp)
je     1254 <main+0xf4>
cmpl   $0x4,-0x3c(%rbp)
je     1254 <main+0xf4>
cmpl   $0x8,-0x3c(%rbp)
je     1254 <main+0xf4>
cmpl   $0x10,-0x3c(%rbp)
je     1254 <main+0xf4>
lea    0xf38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jg     1286 <main+0x126>
lea    0xf55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x3c(%rbp),%esi
lea    0xf58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%esi
lea    0xf5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x30(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0x30(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1320 <main+0x1c0>
mov    -0x34(%rbp),%eax
add    $0x5,%eax
cvtsi2ss %eax,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12d5 <main+0x175>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x3c(%rbp),%edi
call   1060 <omp_set_num_threads@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1368 <main+0x208>
movss  -0x1c(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1337 <main+0x1d7>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    13a8 <main+0x248>
movss  -0x2c(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1377 <main+0x217>
movss  -0x2c(%rbp),%xmm0
ucomiss -0x1c(%rbp),%xmm0
jne    13c2 <main+0x262>
jp     13c2 <main+0x262>
jmp    13da <main+0x27a>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xea8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xed3(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%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,%r14d
lea    0xed8(%rip),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf16(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf11(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf4c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x1043(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x3,%r14d
jne    15ac <main+0x43c>
mov    0x8(%rbx),%rdi
call   1080 <atoi@plt>
cmp    $0x10,%eax
ja     15e2 <main+0x472>
mov    %eax,%r12d
mov    $0x10116,%eax
bt     %r12d,%eax
jae    15e2 <main+0x472>
mov    0x10(%rbx),%rdi
call   1080 <atoi@plt>
test   %eax,%eax
jle    15c3 <main+0x453>
mov    %eax,%r15d
lea    0xf47(%rip),%rdi
xor    %ebp,%ebp
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf4a(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x0(,%r15,4),%r14d
mov    %r14d,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %r14d,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %r15d,%r13d
cmp    $0x8,%r15d
jb     137c <main+0x20c>
lea    (%r14,%r13,4),%rax
cmp    %rax,%rbx
jae    127c <main+0x10c>
lea    (%rbx,%r13,4),%rax
cmp    %rax,%r14
jae    127c <main+0x10c>
xor    %ebp,%ebp
jmp    137c <main+0x20c>
mov    %r13d,%ebp
and    $0xfffffff8,%ebp
lea    -0x8(%rbp),%rax
mov    %rax,%rcx
shr    $0x3,%rcx
add    $0x1,%rcx
test   %rax,%rax
je     1594 <main+0x424>
mov    %rcx,%rdx
and    $0xfffffffffffffffe,%rdx
movdqa 0xd57(%rip),%xmm0
xor    %eax,%eax
movdqa 0xd5d(%rip),%xmm1
movdqa 0xd65(%rip),%xmm2
movdqa 0xd6d(%rip),%xmm3
movdqa 0xd75(%rip),%xmm4
movdqa 0xd7d(%rip),%xmm5
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movdqa %xmm0,%xmm6
paddd  %xmm1,%xmm6
movdqa %xmm0,%xmm7
paddd  %xmm2,%xmm7
cvtdq2ps %xmm6,%xmm6
cvtdq2ps %xmm7,%xmm7
movups %xmm6,(%rbx,%rax,4)
movups %xmm7,0x10(%rbx,%rax,4)
movups %xmm6,(%r14,%rax,4)
movups %xmm7,0x10(%r14,%rax,4)
movdqa %xmm0,%xmm6
paddd  %xmm3,%xmm6
movdqa %xmm0,%xmm7
paddd  %xmm4,%xmm7
cvtdq2ps %xmm6,%xmm6
cvtdq2ps %xmm7,%xmm7
movups %xmm6,0x20(%rbx,%rax,4)
movups %xmm7,0x30(%rbx,%rax,4)
movups %xmm6,0x20(%r14,%rax,4)
movups %xmm7,0x30(%r14,%rax,4)
add    $0x10,%rax
paddd  %xmm5,%xmm0
add    $0xfffffffffffffffe,%rdx
jne    12e0 <main+0x170>
test   $0x1,%cl
je     1377 <main+0x207>
movdqa 0xcbf(%rip),%xmm1
paddd  %xmm0,%xmm1
paddd  0xcc3(%rip),%xmm0
cvtdq2ps %xmm1,%xmm1
cvtdq2ps %xmm0,%xmm0
movups %xmm1,(%rbx,%rax,4)
movups %xmm0,0x10(%rbx,%rax,4)
movups %xmm1,(%r14,%rax,4)
movups %xmm0,0x10(%r14,%rax,4)
cmp    %r13,%rbp
je     13e5 <main+0x275>
mov    %rbp,%rax
not    %rax
test   $0x1,%r13b
je     13a3 <main+0x233>
mov    %ebp,%ecx
or     $0x5,%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
movss  %xmm0,(%rbx,%rbp,4)
movss  %xmm0,(%r14,%rbp,4)
or     $0x1,%rbp
add    %r13,%rax
je     13e5 <main+0x275>
nopl   0x0(%rax,%rax,1)
lea    0x5(%rbp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,(%rbx,%rbp,4)
movss  %xmm0,(%r14,%rbp,4)
lea    0x6(%rbp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x4(%rbx,%rbp,4)
movss  %xmm0,0x4(%r14,%rbp,4)
add    $0x2,%rbp
cmp    %rbp,%r13
jne    13b0 <main+0x240>
mov    %r12d,%edi
call   1070 <omp_set_num_threads@plt>
test   %r15d,%r15d
jle    140a <main+0x29a>
lea    -0x1(%r13),%rax
mov    %r13d,%ecx
and    $0x7,%ecx
cmp    $0x7,%rax
jae    1422 <main+0x2b2>
pxor   %xmm0,%xmm0
xor    %edx,%edx
jmp    1468 <main+0x2f8>
pxor   %xmm0,%xmm0
movd   %xmm0,0x4(%rsp)
pxor   %xmm0,%xmm0
movd   %xmm0,(%rsp)
jmp    1538 <main+0x3c8>
mov    %r13d,%esi
and    $0xfffffff8,%esi
pxor   %xmm0,%xmm0
xor    %edx,%edx
xchg   %ax,%ax
addss  (%rbx,%rdx,4),%xmm0
addss  0x4(%rbx,%rdx,4),%xmm0
addss  0x8(%rbx,%rdx,4),%xmm0
addss  0xc(%rbx,%rdx,4),%xmm0
addss  0x10(%rbx,%rdx,4),%xmm0
addss  0x14(%rbx,%rdx,4),%xmm0
addss  0x18(%rbx,%rdx,4),%xmm0
addss  0x1c(%rbx,%rdx,4),%xmm0
add    $0x8,%rdx
cmp    %rdx,%rsi
jne    1430 <main+0x2c0>
test   %rcx,%rcx
je     148e <main+0x31e>
lea    (%rbx,%rdx,4),%rdx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addss  (%rdx,%rsi,4),%xmm0
add    $0x1,%rsi
cmp    %rsi,%rcx
jne    1480 <main+0x310>
test   %r15d,%r15d
jle    14a7 <main+0x337>
mov    %r13d,%ecx
and    $0x7,%ecx
cmp    $0x7,%rax
jae    14ad <main+0x33d>
pxor   %xmm1,%xmm1
xor    %eax,%eax
jmp    1500 <main+0x390>
pxor   %xmm1,%xmm1
jmp    151e <main+0x3ae>
and    $0xfffffff8,%r13d
pxor   %xmm1,%xmm1
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
addss  (%r14,%rax,4),%xmm1
addss  0x4(%r14,%rax,4),%xmm1
addss  0x8(%r14,%rax,4),%xmm1
addss  0xc(%r14,%rax,4),%xmm1
addss  0x10(%r14,%rax,4),%xmm1
addss  0x14(%r14,%rax,4),%xmm1
addss  0x18(%r14,%rax,4),%xmm1
addss  0x1c(%r14,%rax,4),%xmm1
add    $0x8,%rax
cmp    %rax,%r13
jne    14c0 <main+0x350>
test   %rcx,%rcx
je     151e <main+0x3ae>
lea    (%r14,%rax,4),%rax
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
addss  (%rax,%rdx,4),%xmm1
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1510 <main+0x3a0>
movss  %xmm1,0x4(%rsp)
ucomiss %xmm0,%xmm1
movss  %xmm0,(%rsp)
jne    15d9 <main+0x469>
jp     15d9 <main+0x469>
lea    0xd1f(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc29(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc53(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movdqa 0xa64(%rip),%xmm0
xor    %eax,%eax
test   $0x1,%cl
jne    1349 <main+0x1d9>
jmp    1377 <main+0x207>
lea    0xb97(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xda5(%rip),%rdi
jmp    15e9 <main+0x479>
lea    0xd31(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xcca(%rip),%rdi
jmp    15e9 <main+0x479>
lea    0xd2f(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

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 = [73 x i8] c"\0A\09\09 Objective : Find the Sum of elements of one-dimensional real array \00"
@.str.3 = [63 x i8] c"\0A\09\09 using OpenMP Parallel for directive and Reduction Clause \00"
@.str.4 = [79 x i8] c"\0A\09\09..........................................................................\0A\00"
@.str.5 = [24 x i8] c"\09\09 Very Few Arguments\0A \00"
@.str.6 = [42 x i8] c"\09\09 Syntax : exec <Threads> <array-size> \0A\00"
@.str.7 = [79 x i8] c"\0A\09\09 Number of threads should be 1,2,4,8 or 16 for the execution of program. \0A\0A\00"
@.str.8 = [30 x i8] c"\0A\09\09 Positive Number Required\0A\00"
@.str.9 = [22 x i8] c"\0A\09\09 Threads : %d \00"
@.str.10 = [21 x i8] c"\0A\09\09 Array Size : %d\00"
@.str.11 = [82 x i8] c"\0A\0A\09\09 The parallel calculation of array sum is different from serial calculation \0A\00"
@.str.12 = [77 x i8] c"\0A\0A\09\09 The parallel calculation of array sum is same with serial calculation \0A\00"
@.str.13 = [66 x i8] c"\0A\09\09 The SumOfElements Of The Array Using OpenMP Directives Is %f\0A\00"
@.str.14 = [65 x i8] c"\09\09 The SumOfElements Of The Array By Serial Calculation Is %f\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float*
%7 = alloca float
%8 = alloca float*
%9 = alloca float
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.4, i64 0, i64 0))
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 3
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
%25 = call i32 @exit(i32 -1)
unreachable
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %13
%31 = load i32, i32* %13
%32 = icmp ne i32 %31, 1
br i1 %32, label %33, label %48
33: ; preds = %26
%34 = load i32, i32* %13
%35 = icmp ne i32 %34, 2
br i1 %35, label %36, label %48
36: ; preds = %33
%37 = load i32, i32* %13
%38 = icmp ne i32 %37, 4
br i1 %38, label %39, label %48
39: ; preds = %36
%40 = load i32, i32* %13
%41 = icmp ne i32 %40, 8
br i1 %41, label %42, label %48
42: ; preds = %39
%43 = load i32, i32* %13
%44 = icmp ne i32 %43, 16
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.7, i64 0, i64 0))
%47 = call i32 @exit(i32 -1)
unreachable
48: ; preds = %42, %39, %36, %33, %26
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i32 @atoi(i8* %51)
store i32 %52, i32* %10
%53 = load i32, i32* %10
%54 = icmp sle i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %48
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %48
%59 = load i32, i32* %13
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i32 %59)
%61 = load i32, i32* %10
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %10
%64 = sext i32 %63 to i64
%65 = mul i64 4, %64
%66 = trunc i64 %65 to i32
%67 = call i64 @malloc(i32 %66)
%68 = inttoptr i64 %67 to float*
store float* %68, float** %6
%69 = load i32, i32* %10
%70 = sext i32 %69 to i64
%71 = mul i64 4, %70
%72 = trunc i64 %71 to i32
%73 = call i64 @malloc(i32 %72)
%74 = inttoptr i64 %73 to float*
store float* %74, float** %8
store i32 0, i32* %11
br label %75
75: ; preds = %96, %58
%76 = load i32, i32* %11
%77 = load i32, i32* %10
%78 = icmp slt i32 %76, %77
br i1 %78, label %79, label %99
79: ; preds = %75
%80 = load i32, i32* %11
%81 = add nsw i32 %80, 5
%82 = sitofp i32 %81 to float
%83 = load float*, float** %6
%84 = load i32, i32* %11
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds float, float* %83, i64 %85
store float %82, float* %86
%87 = load float*, float** %6
%88 = load i32, i32* %11
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds float, float* %87, i64 %89
%91 = load float, float* %90
%92 = load float*, float** %8
%93 = load i32, i32* %11
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds float, float* %92, i64 %94
store float %91, float* %95
br label %96
96: ; preds = %79
%97 = load i32, i32* %11
%98 = add nsw i32 %97, 1
store i32 %98, i32* %11
br label %75
99: ; preds = %75
store float 0.000000e+00, float* %7
%100 = load i32, i32* %13
%101 = call i32 @omp_set_num_threads(i32 %100)
store i32 0, i32* %11
br label %102
102: ; preds = %114, %99
%103 = load i32, i32* %11
%104 = load i32, i32* %10
%105 = icmp slt i32 %103, %104
br i1 %105, label %106, label %117
106: ; preds = %102
%107 = load float, float* %7
%108 = load float*, float** %6
%109 = load i32, i32* %11
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds float, float* %108, i64 %110
%112 = load float, float* %111
%113 = fadd float %107, %112
store float %113, float* %7
br label %114
114: ; preds = %106
%115 = load i32, i32* %11
%116 = add nsw i32 %115, 1
store i32 %116, i32* %11
br label %102
117: ; preds = %102
store float 0.000000e+00, float* %9
store i32 0, i32* %11
br label %118
118: ; preds = %130, %117
%119 = load i32, i32* %11
%120 = load i32, i32* %10
%121 = icmp slt i32 %119, %120
br i1 %121, label %122, label %133
122: ; preds = %118
%123 = load float, float* %9
%124 = load float*, float** %8
%125 = load i32, i32* %11
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds float, float* %124, i64 %126
%128 = load float, float* %127
%129 = fadd float %123, %128
store float %129, float* %9
br label %130
130: ; preds = %122
%131 = load i32, i32* %11
%132 = add nsw i32 %131, 1
store i32 %132, i32* %11
br label %118
133: ; preds = %118
%134 = load float, float* %9
%135 = load float, float* %7
%136 = fcmp une float %134, %135
br i1 %136, label %137, label %140
137: ; preds = %133
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.11, i64 0, i64 0))
%139 = call i32 @exit(i32 -1)
unreachable
140: ; preds = %133
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.12, i64 0, i64 0))
br label %142
142: ; preds = %140
%143 = load float*, float** %8
%144 = call i32 @free(float* %143)
%145 = load float*, float** %6
%146 = call i32 @free(float* %145)
%147 = load float, float* %7
%148 = fpext float %147 to double
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.13, i64 0, i64 0), double %148)
%150 = load float, float* %9
%151 = fpext float %150 to double
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.14, i64 0, i64 0), double %151)
%153 = load i32, i32* %3
ret i32 %153
}

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 = [73 x i8] c"\0A\09\09 Objective : Find the Sum of elements of one-dimensional real array \00"
@.str.3 = [63 x i8] c"\0A\09\09 using OpenMP Parallel for directive and Reduction Clause \00"
@.str.5 = [24 x i8] c"\09\09 Very Few Arguments\0A \00"
@.str.9 = [22 x i8] c"\0A\09\09 Threads : %d \00"
@.str.10 = [21 x i8] c"\0A\09\09 Array Size : %d\00"
@.str.13 = [66 x i8] c"\0A\09\09 The SumOfElements Of The Array Using OpenMP Directives Is %f\0A\00"
@.str.14 = [65 x i8] c"\09\09 The SumOfElements Of The Array By Serial Calculation Is %f\0A\0A\00"
@str = [78 x i8] c"\0A\09\09..........................................................................\00"
@str.15 = [76 x i8] c"\0A\0A\09\09 The parallel calculation of array sum is same with serial calculation \00"
@str.16 = [81 x i8] c"\0A\0A\09\09 The parallel calculation of array sum is different from serial calculation \00"
@str.17 = [29 x i8] c"\0A\09\09 Positive Number Required\00"
@str.18 = [78 x i8] c"\0A\09\09 Number of threads should be 1,2,4,8 or 16 for the execution of program. \0A\00"
@str.19 = [41 x i8] c"\09\09 Syntax : exec <Threads> <array-size> \00"
define i32 @main(i32 %0, i8** nocapture %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 ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 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 = icmp eq i32 %0, 3
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.19, i64 0, i64 0))
%13 = tail call i32 @exit(i32 -1)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
switch i32 %17, label %18 [
i32 16, label %21
i32 8, label %21
i32 4, label %21
i32 2, label %21
i32 1, label %21
]
18: ; preds = %14
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.18, i64 0, i64 0))
%20 = tail call i32 @exit(i32 -1)
unreachable
21: ; preds = %14, %14, %14, %14, %14
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32 @atoi(i8* %23)
%25 = icmp slt i32 %24, 1
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.17, i64 0, i64 0))
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %21
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i32 %17)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i32 %24)
%32 = shl i32 %24, 2
%33 = tail call i64 @malloc(i32 %32)
%34 = inttoptr i64 %33 to float*
%35 = tail call i64 @malloc(i32 %32)
%36 = inttoptr i64 %35 to float*
%37 = zext i32 %24 to i64
%38 = icmp ult i32 %24, 8
br i1 %38, label %110, label %39
39: ; preds = %29
%40 = inttoptr i64 %35 to i8*
%41 = inttoptr i64 %33 to i8*
%42 = getelementptr float, float* %34, i64 %37
%43 = bitcast float* %42 to i8*
%44 = getelementptr float, float* %36, i64 %37
%45 = bitcast float* %44 to i8*
%46 = icmp ult i8* %41, %45
%47 = icmp ult i8* %40, %43
%48 = and i1 %46, %47
br i1 %48, label %110, label %49
49: ; preds = %39
%50 = and i64 %37, 4294967288
%51 = add nsw i64 %50, -8
%52 = lshr exact i64 %51, 3
%53 = add nuw nsw i64 %52, 1
%54 = and i64 %53, 1
%55 = icmp eq i64 %51, 0
br i1 %55, label %91, label %56
56: ; preds = %49
%57 = and i64 %53, 4611686018427387902
br label %58
58: ; preds = %58, %56
%59 = phi i64 [ 0, %56 ], [ %87, %58 ]
%60 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %56 ], [ %88, %58 ]
%61 = phi i64 [ 0, %56 ], [ %89, %58 ]
%62 = add <4 x i32> %60, <i32 5, i32 5, i32 5, i32 5>
%63 = add <4 x i32> %60, <i32 9, i32 9, i32 9, i32 9>
%64 = sitofp <4 x i32> %62 to <4 x float>
%65 = sitofp <4 x i32> %63 to <4 x float>
%66 = getelementptr inbounds float, float* %34, i64 %59
%67 = bitcast float* %66 to <4 x float>*
store <4 x float> %64, <4 x float>* %67
%68 = getelementptr inbounds float, float* %66, i64 4
%69 = bitcast float* %68 to <4 x float>*
store <4 x float> %65, <4 x float>* %69
%70 = getelementptr inbounds float, float* %36, i64 %59
%71 = bitcast float* %70 to <4 x float>*
store <4 x float> %64, <4 x float>* %71
%72 = getelementptr inbounds float, float* %70, i64 4
%73 = bitcast float* %72 to <4 x float>*
store <4 x float> %65, <4 x float>* %73
%74 = or i64 %59, 8
%75 = add <4 x i32> %60, <i32 13, i32 13, i32 13, i32 13>
%76 = add <4 x i32> %60, <i32 17, i32 17, i32 17, i32 17>
%77 = sitofp <4 x i32> %75 to <4 x float>
%78 = sitofp <4 x i32> %76 to <4 x float>
%79 = getelementptr inbounds float, float* %34, i64 %74
%80 = bitcast float* %79 to <4 x float>*
store <4 x float> %77, <4 x float>* %80
%81 = getelementptr inbounds float, float* %79, i64 4
%82 = bitcast float* %81 to <4 x float>*
store <4 x float> %78, <4 x float>* %82
%83 = getelementptr inbounds float, float* %36, i64 %74
%84 = bitcast float* %83 to <4 x float>*
store <4 x float> %77, <4 x float>* %84
%85 = getelementptr inbounds float, float* %83, i64 4
%86 = bitcast float* %85 to <4 x float>*
store <4 x float> %78, <4 x float>* %86
%87 = add nuw i64 %59, 16
%88 = add <4 x i32> %60, <i32 16, i32 16, i32 16, i32 16>
%89 = add i64 %61, 2
%90 = icmp eq i64 %89, %57
br i1 %90, label %91, label %58
91: ; preds = %58, %49
%92 = phi i64 [ 0, %49 ], [ %87, %58 ]
%93 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %49 ], [ %88, %58 ]
%94 = icmp eq i64 %54, 0
br i1 %94, label %108, label %95
95: ; preds = %91
%96 = add <4 x i32> %93, <i32 5, i32 5, i32 5, i32 5>
%97 = add <4 x i32> %93, <i32 9, i32 9, i32 9, i32 9>
%98 = sitofp <4 x i32> %96 to <4 x float>
%99 = sitofp <4 x i32> %97 to <4 x float>
%100 = getelementptr inbounds float, float* %34, i64 %92
%101 = bitcast float* %100 to <4 x float>*
store <4 x float> %98, <4 x float>* %101
%102 = getelementptr inbounds float, float* %100, i64 4
%103 = bitcast float* %102 to <4 x float>*
store <4 x float> %99, <4 x float>* %103
%104 = getelementptr inbounds float, float* %36, i64 %92
%105 = bitcast float* %104 to <4 x float>*
store <4 x float> %98, <4 x float>* %105
%106 = getelementptr inbounds float, float* %104, i64 4
%107 = bitcast float* %106 to <4 x float>*
store <4 x float> %99, <4 x float>* %107
br label %108
108: ; preds = %91, %95
%109 = icmp eq i64 %50, %37
br i1 %109, label %141, label %110
110: ; preds = %39, %29, %108
%111 = phi i64 [ 0, %39 ], [ 0, %29 ], [ %50, %108 ]
%112 = xor i64 %111, -1
%113 = and i64 %37, 1
%114 = icmp eq i64 %113, 0
br i1 %114, label %122, label %115
115: ; preds = %110
%116 = trunc i64 %111 to i32
%117 = or i32 %116, 5
%118 = sitofp i32 %117 to float
%119 = getelementptr inbounds float, float* %34, i64 %111
store float %118, float* %119
%120 = getelementptr inbounds float, float* %36, i64 %111
store float %118, float* %120
%121 = or i64 %111, 1
br label %122
122: ; preds = %115, %110
%123 = phi i64 [ %111, %110 ], [ %121, %115 ]
%124 = sub nsw i64 0, %37
%125 = icmp eq i64 %112, %124
br i1 %125, label %141, label %126
126: ; preds = %122, %126
%127 = phi i64 [ %139, %126 ], [ %123, %122 ]
%128 = trunc i64 %127 to i32
%129 = add i32 %128, 5
%130 = sitofp i32 %129 to float
%131 = getelementptr inbounds float, float* %34, i64 %127
store float %130, float* %131
%132 = getelementptr inbounds float, float* %36, i64 %127
store float %130, float* %132
%133 = add nuw nsw i64 %127, 1
%134 = trunc i64 %133 to i32
%135 = add i32 %134, 5
%136 = sitofp i32 %135 to float
%137 = getelementptr inbounds float, float* %34, i64 %133
store float %136, float* %137
%138 = getelementptr inbounds float, float* %36, i64 %133
store float %136, float* %138
%139 = add nuw nsw i64 %127, 2
%140 = icmp eq i64 %139, %37
br i1 %140, label %141, label %126
141: ; preds = %122, %126, %108
%142 = tail call i32 @omp_set_num_threads(i32 %17)
%143 = icmp sgt i32 %24, 0
br i1 %143, label %144, label %269
144: ; preds = %141
%145 = add nsw i64 %37, -1
%146 = and i64 %37, 7
%147 = icmp ult i64 %145, 7
br i1 %147, label %150, label %148
148: ; preds = %144
%149 = and i64 %37, 4294967288
br label %172
150: ; preds = %172, %144
%151 = phi float [ undef, %144 ], [ %206, %172 ]
%152 = phi i64 [ 0, %144 ], [ %207, %172 ]
%153 = phi float [ 0.000000e+00, %144 ], [ %206, %172 ]
%154 = icmp eq i64 %146, 0
br i1 %154, label %165, label %155
155: ; preds = %150, %155
%156 = phi i64 [ %162, %155 ], [ %152, %150 ]
%157 = phi float [ %161, %155 ], [ %153, %150 ]
%158 = phi i64 [ %163, %155 ], [ 0, %150 ]
%159 = getelementptr inbounds float, float* %34, i64 %156
%160 = load float, float* %159
%161 = fadd float %157, %160
%162 = add nuw nsw i64 %156, 1
%163 = add i64 %158, 1
%164 = icmp eq i64 %163, %146
br i1 %164, label %165, label %155
165: ; preds = %155, %150
%166 = phi float [ %151, %150 ], [ %161, %155 ]
br i1 %143, label %167, label %263
167: ; preds = %165
%168 = and i64 %37, 7
%169 = icmp ult i64 %145, 7
br i1 %169, label %248, label %170
170: ; preds = %167
%171 = and i64 %37, 4294967288
br label %210
172: ; preds = %172, %148
%173 = phi i64 [ 0, %148 ], [ %207, %172 ]
%174 = phi float [ 0.000000e+00, %148 ], [ %206, %172 ]
%175 = phi i64 [ 0, %148 ], [ %208, %172 ]
%176 = getelementptr inbounds float, float* %34, i64 %173
%177 = load float, float* %176
%178 = fadd float %174, %177
%179 = or i64 %173, 1
%180 = getelementptr inbounds float, float* %34, i64 %179
%181 = load float, float* %180
%182 = fadd float %178, %181
%183 = or i64 %173, 2
%184 = getelementptr inbounds float, float* %34, i64 %183
%185 = load float, float* %184
%186 = fadd float %182, %185
%187 = or i64 %173, 3
%188 = getelementptr inbounds float, float* %34, i64 %187
%189 = load float, float* %188
%190 = fadd float %186, %189
%191 = or i64 %173, 4
%192 = getelementptr inbounds float, float* %34, i64 %191
%193 = load float, float* %192
%194 = fadd float %190, %193
%195 = or i64 %173, 5
%196 = getelementptr inbounds float, float* %34, i64 %195
%197 = load float, float* %196
%198 = fadd float %194, %197
%199 = or i64 %173, 6
%200 = getelementptr inbounds float, float* %34, i64 %199
%201 = load float, float* %200
%202 = fadd float %198, %201
%203 = or i64 %173, 7
%204 = getelementptr inbounds float, float* %34, i64 %203
%205 = load float, float* %204
%206 = fadd float %202, %205
%207 = add nuw nsw i64 %173, 8
%208 = add i64 %175, 8
%209 = icmp eq i64 %208, %149
br i1 %209, label %150, label %172
210: ; preds = %210, %170
%211 = phi i64 [ 0, %170 ], [ %245, %210 ]
%212 = phi float [ 0.000000e+00, %170 ], [ %244, %210 ]
%213 = phi i64 [ 0, %170 ], [ %246, %210 ]
%214 = getelementptr inbounds float, float* %36, i64 %211
%215 = load float, float* %214
%216 = fadd float %212, %215
%217 = or i64 %211, 1
%218 = getelementptr inbounds float, float* %36, i64 %217
%219 = load float, float* %218
%220 = fadd float %216, %219
%221 = or i64 %211, 2
%222 = getelementptr inbounds float, float* %36, i64 %221
%223 = load float, float* %222
%224 = fadd float %220, %223
%225 = or i64 %211, 3
%226 = getelementptr inbounds float, float* %36, i64 %225
%227 = load float, float* %226
%228 = fadd float %224, %227
%229 = or i64 %211, 4
%230 = getelementptr inbounds float, float* %36, i64 %229
%231 = load float, float* %230
%232 = fadd float %228, %231
%233 = or i64 %211, 5
%234 = getelementptr inbounds float, float* %36, i64 %233
%235 = load float, float* %234
%236 = fadd float %232, %235
%237 = or i64 %211, 6
%238 = getelementptr inbounds float, float* %36, i64 %237
%239 = load float, float* %238
%240 = fadd float %236, %239
%241 = or i64 %211, 7
%242 = getelementptr inbounds float, float* %36, i64 %241
%243 = load float, float* %242
%244 = fadd float %240, %243
%245 = add nuw nsw i64 %211, 8
%246 = add i64 %213, 8
%247 = icmp eq i64 %246, %171
br i1 %247, label %248, label %210
248: ; preds = %210, %167
%249 = phi float [ undef, %167 ], [ %244, %210 ]
%250 = phi i64 [ 0, %167 ], [ %245, %210 ]
%251 = phi float [ 0.000000e+00, %167 ], [ %244, %210 ]
%252 = icmp eq i64 %168, 0
br i1 %252, label %263, label %253
253: ; preds = %248, %253
%254 = phi i64 [ %260, %253 ], [ %250, %248 ]
%255 = phi float [ %259, %253 ], [ %251, %248 ]
%256 = phi i64 [ %261, %253 ], [ 0, %248 ]
%257 = getelementptr inbounds float, float* %36, i64 %254
%258 = load float, float* %257
%259 = fadd float %255, %258
%260 = add nuw nsw i64 %254, 1
%261 = add i64 %256, 1
%262 = icmp eq i64 %261, %168
br i1 %262, label %263, label %253
263: ; preds = %248, %253, %165
%264 = phi float [ 0.000000e+00, %165 ], [ %249, %248 ], [ %259, %253 ]
%265 = fcmp une float %264, %166
br i1 %265, label %266, label %269
266: ; preds = %263
%267 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @str.16, i64 0, i64 0))
%268 = tail call i32 @exit(i32 -1)
unreachable
269: ; preds = %141, %263
%270 = phi float [ %264, %263 ], [ 0.000000e+00, %141 ]
%271 = phi float [ %166, %263 ], [ 0.000000e+00, %141 ]
%272 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @str.15, i64 0, i64 0))
%273 = tail call i32 @free(float* %36)
%274 = tail call i32 @free(float* %34)
%275 = fpext float %271 to double
%276 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.13, i64 0, i64 0), double %275)
%277 = fpext float %270 to double
%278 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.14, i64 0, i64 0), double %277)
ret i32 0
}