#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 */
struct timeval {
  int tv_sec;
  double tv_usec;
};

/* Variables and functions */
scalar_t__ RAND_MAX;
int /*<<< orphan*/ acc_device_default;
int /*<<< orphan*/ acc_init(int /*<<< orphan*/);
double fabs(double);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/);
int main() {
  int i, j, k;
  double product, known_product;
  int NI, NJ, NK;
  int error;
  double *input;
  double rounding_error = 1.E-9;
  struct timeval tim;
  double start, end;
  NK = 1 << 5;
  NJ = 1 << 5;
  NI = 1 << 5;
  error = 0;
  input = (double *)malloc(NK * NJ * NI * sizeof(double));
  acc_init(acc_device_default);
  srand((unsigned)time(0));
  for (k = 0; k < NK; k++) {
    for (j = 0; j < NJ; j++) {
      for (i = 0; i < NI; i++) {
        input[k * NJ * NI + j * NI + i] =
            (double)rand() / (double)RAND_MAX + 0.1;
      }
    }
  }
  product = 1;
  gettimeofday(&tim, NULL);
  start = tim.tv_sec * 1000 + (tim.tv_usec / 1000.0);
#pragma acc parallel copyin(input [0:NK * NJ * NI]) num_gangs(192)             \
    num_workers(8) vector_length(128)
  {
#pragma acc loop gang reduction(* : product)
    for (k = 0; k < NK; k++) {
#pragma acc loop worker
      for (j = 0; j < NJ; j++) {
#pragma acc loop vector
        for (i = 0; i < NI; i++)
          product *= input[k * NJ * NI + j * NI + i];
      }
    }
  }
  gettimeofday(&tim, NULL);
  end = tim.tv_sec * 1000 + (tim.tv_usec / 1000.0);
  known_product = 1;
  for (k = 0; k < NK; k++) {
    for (j = 0; j < NJ; j++) {
      for (i = 0; i < NI; i++)
        known_product *= input[k * NJ * NI + j * NI + i];
    }
  }
  if (fabs(product - known_product) > rounding_error) {
    error++;
    printf("gang_worker_vector + FAILED! product=%d, known_product=%d\n",
           product, known_product);
  }
  printf("gang_worker_vector + execution time is :%.2lf: ms\n", end - start);
  if (error == 0)
    printf("gang_worker_vector + SUCCESS!\n");
  free(input);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xe69(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x20,-0x2c(%rbp)
movl   $0x20,-0x28(%rbp)
movl   $0x20,-0x24(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x28(%rbp),%eax
imul   -0x24(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1090 <acc_init@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    12a8 <main+0x128>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1295 <main+0x115>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1282 <main+0x102>
mov    $0x0,%al
call   10a0 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2dac(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  0xdcb(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x28(%rbp),%ecx
imul   -0x24(%rbp),%ecx
mov    -0xc(%rbp),%edx
imul   -0x24(%rbp),%edx
add    %edx,%ecx
add    -0x8(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    121d <main+0x9d>
jmp    1287 <main+0x107>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    120a <main+0x8a>
jmp    129a <main+0x11a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11f7 <main+0x77>
movsd  0xd60(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
imul   $0x3e8,-0x50(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xd2e(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1381 <main+0x201>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    136e <main+0x1ee>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    135b <main+0x1db>
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x28(%rbp),%ecx
imul   -0x24(%rbp),%ecx
mov    -0xc(%rbp),%edx
imul   -0x24(%rbp),%edx
add    %edx,%ecx
add    -0x8(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1314 <main+0x194>
jmp    1360 <main+0x1e0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1301 <main+0x181>
jmp    1373 <main+0x1f3>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12ee <main+0x16e>
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
imul   $0x3e8,-0x50(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xc62(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xc55(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    145a <main+0x2da>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1447 <main+0x2c7>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1434 <main+0x2b4>
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x28(%rbp),%ecx
imul   -0x24(%rbp),%ecx
mov    -0xc(%rbp),%edx
imul   -0x24(%rbp),%edx
add    %edx,%ecx
add    -0x8(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    13ed <main+0x26d>
jmp    1439 <main+0x2b9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    13da <main+0x25a>
jmp    144c <main+0x2cc>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    13c7 <main+0x247>
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movaps 0xbb5(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    149b <main+0x31b>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xb9c(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  -0x60(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
lea    0xbbf(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x30(%rbp)
jne    14cb <main+0x34b>
lea    0xbda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    $0x40000,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   10a0 <acc_init@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    0x2e1a(%rip),%r13
mov    %r15,0x30(%rsp)
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   10b0 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq 0x0(%r13),%xmm1
divsd  %xmm1,%xmm0
movsd  0xddc(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rbx,%r14,8)
add    $0x1,%r14
cmp    $0x20,%r14
jne    1200 <main+0x70>
add    $0x1,%rbp
add    $0x100,%rbx
cmp    $0x20,%rbp
jne    11f0 <main+0x60>
add    $0x1,%r12
add    $0x2000,%r15
cmp    $0x20,%r12
jne    11e0 <main+0x50>
xor    %ebx,%ebx
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
imul   $0x3e8,0x18(%rsp),%eax
movsd  0x20(%rsp),%xmm0
divsd  0xd8a(%rip),%xmm0
mov    0x30(%rsp),%rbp
lea    0xf8(%rbp),%rcx
movsd  0xd7e(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mulsd  -0xf8(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xf0(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xe8(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xe0(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xd8(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xd0(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xc8(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xc0(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xb8(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xb0(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xa8(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xa0(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0x98(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0x90(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0x88(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0x80(%rcx,%rdx,1),%xmm1
mulsd  -0x78(%rcx,%rdx,1),%xmm1
mulsd  -0x70(%rcx,%rdx,1),%xmm1
mulsd  -0x68(%rcx,%rdx,1),%xmm1
mulsd  -0x60(%rcx,%rdx,1),%xmm1
mulsd  -0x58(%rcx,%rdx,1),%xmm1
mulsd  -0x50(%rcx,%rdx,1),%xmm1
mulsd  -0x48(%rcx,%rdx,1),%xmm1
mulsd  -0x40(%rcx,%rdx,1),%xmm1
mulsd  -0x38(%rcx,%rdx,1),%xmm1
mulsd  -0x30(%rcx,%rdx,1),%xmm1
mulsd  -0x28(%rcx,%rdx,1),%xmm1
mulsd  -0x20(%rcx,%rdx,1),%xmm1
mulsd  -0x18(%rcx,%rdx,1),%xmm1
mulsd  -0x10(%rcx,%rdx,1),%xmm1
mulsd  -0x8(%rcx,%rdx,1),%xmm1
mulsd  (%rcx,%rdx,1),%xmm1
add    $0x100,%rdx
cmp    $0x2000,%rdx
jne    12b0 <main+0x120>
add    $0x1,%rbx
add    $0x2000,%rcx
cmp    $0x20,%rbx
jne    12a0 <main+0x110>
cvtsi2sd %eax,%xmm2
movsd  %xmm2,0x28(%rsp)
xor    %ebx,%ebx
lea    0x18(%rsp),%rdi
xor    %esi,%esi
movsd  %xmm0,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1060 <gettimeofday@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm3
imul   $0x3e8,0x18(%rsp),%eax
movsd  0x20(%rsp),%xmm5
divsd  0xbfd(%rip),%xmm5
mov    %rbp,%rcx
add    $0xf8,%rcx
movsd  0xbf3(%rip),%xmm1
nopl   (%rax)
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mulsd  -0xf8(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xf0(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xe8(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xe0(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xd8(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xd0(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xc8(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xc0(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xb8(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xb0(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xa8(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0xa0(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0x98(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0x90(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0x88(%rcx,%rdx,1),%xmm1
ff ff
mulsd  -0x80(%rcx,%rdx,1),%xmm1
mulsd  -0x78(%rcx,%rdx,1),%xmm1
mulsd  -0x70(%rcx,%rdx,1),%xmm1
mulsd  -0x68(%rcx,%rdx,1),%xmm1
mulsd  -0x60(%rcx,%rdx,1),%xmm1
mulsd  -0x58(%rcx,%rdx,1),%xmm1
mulsd  -0x50(%rcx,%rdx,1),%xmm1
mulsd  -0x48(%rcx,%rdx,1),%xmm1
mulsd  -0x40(%rcx,%rdx,1),%xmm1
mulsd  -0x38(%rcx,%rdx,1),%xmm1
mulsd  -0x30(%rcx,%rdx,1),%xmm1
mulsd  -0x28(%rcx,%rdx,1),%xmm1
mulsd  -0x20(%rcx,%rdx,1),%xmm1
mulsd  -0x18(%rcx,%rdx,1),%xmm1
mulsd  -0x10(%rcx,%rdx,1),%xmm1
mulsd  -0x8(%rcx,%rdx,1),%xmm1
mulsd  (%rcx,%rdx,1),%xmm1
add    $0x100,%rdx
cmp    $0x2000,%rdx
jne    1430 <main+0x2a0>
add    $0x1,%rbx
add    $0x2000,%rcx
cmp    $0x20,%rbx
jne    1420 <main+0x290>
cvtsi2sd %eax,%xmm4
addsd  0x28(%rsp),%xmm3
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
andpd  0xac1(%rip),%xmm2
addsd  %xmm4,%xmm5
ucomisd 0xaad(%rip),%xmm2
jbe    15a3 <main+0x413>
lea    0xabc(%rip),%rdi
mov    $0x2,%al
movsd  %xmm3,0x10(%rsp)
movsd  %xmm5,0x8(%rsp)
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
lea    0xad1(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    15c5 <main+0x435>
subsd  %xmm3,%xmm5
lea    0xabd(%rip),%rdi
movapd %xmm5,%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xade(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    $0x1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, double }
@acc_device_default = global i32 0
@RAND_MAX = global i64 0
@.str = [59 x i8] c"gang_worker_vector + FAILED! product=%d, known_product=%d\0A\00"
@.str.1 = [51 x i8] c"gang_worker_vector + execution time is :%.2lf: ms\0A\00"
@.str.2 = [31 x i8] c"gang_worker_vector + SUCCESS!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double*
%12 = alloca double
%13 = alloca %struct.timeval
%14 = alloca double
%15 = alloca double
store i32 0, i32* %1
store double 1.000000e-09, double* %12
store i32 32, i32* %9
store i32 32, i32* %8
store i32 32, i32* %7
store i32 0, i32* %10
%16 = load i32, i32* %9
%17 = load i32, i32* %8
%18 = mul nsw i32 %16, %17
%19 = load i32, i32* %7
%20 = mul nsw i32 %18, %19
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 8
%23 = trunc i64 %22 to i32
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to double*
store double* %25, double** %11
%26 = load i32, i32* @acc_device_default
%27 = call i32 @acc_init(i32 %26)
%28 = call i64 @time(i32 0)
%29 = trunc i64 %28 to i32
%30 = call i32 @srand(i32 %29)
store i32 0, i32* %4
br label %31
31: ; preds = %74, %0
%32 = load i32, i32* %4
%33 = load i32, i32* %9
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %77
35: ; preds = %31
store i32 0, i32* %3
br label %36
36: ; preds = %70, %35
%37 = load i32, i32* %3
%38 = load i32, i32* %8
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %73
40: ; preds = %36
store i32 0, i32* %2
br label %41
41: ; preds = %66, %40
%42 = load i32, i32* %2
%43 = load i32, i32* %7
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %69
45: ; preds = %41
%46 = call i64 (...) @rand()
%47 = sitofp i64 %46 to double
%48 = load i64, i64* @RAND_MAX
%49 = sitofp i64 %48 to double
%50 = fdiv double %47, %49
%51 = fadd double %50, 1.000000e-01
%52 = load double*, double** %11
%53 = load i32, i32* %4
%54 = load i32, i32* %8
%55 = mul nsw i32 %53, %54
%56 = load i32, i32* %7
%57 = mul nsw i32 %55, %56
%58 = load i32, i32* %3
%59 = load i32, i32* %7
%60 = mul nsw i32 %58, %59
%61 = add nsw i32 %57, %60
%62 = load i32, i32* %2
%63 = add nsw i32 %61, %62
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %52, i64 %64
store double %51, double* %65
br label %66
66: ; preds = %45
%67 = load i32, i32* %2
%68 = add nsw i32 %67, 1
store i32 %68, i32* %2
br label %41
69: ; preds = %41
br label %70
70: ; preds = %69
%71 = load i32, i32* %3
%72 = add nsw i32 %71, 1
store i32 %72, i32* %3
br label %36
73: ; preds = %36
br label %74
74: ; preds = %73
%75 = load i32, i32* %4
%76 = add nsw i32 %75, 1
store i32 %76, i32* %4
br label %31
77: ; preds = %31
store double 1.000000e+00, double* %5
%78 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%79 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%80 = load i32, i32* %79
%81 = mul nsw i32 %80, 1000
%82 = sitofp i32 %81 to double
%83 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%84 = load double, double* %83
%85 = fdiv double %84, 1.000000e+03
%86 = fadd double %82, %85
store double %86, double* %14
store i32 0, i32* %4
br label %87
87: ; preds = %127, %77
%88 = load i32, i32* %4
%89 = load i32, i32* %9
%90 = icmp slt i32 %88, %89
br i1 %90, label %91, label %130
91: ; preds = %87
store i32 0, i32* %3
br label %92
92: ; preds = %123, %91
%93 = load i32, i32* %3
%94 = load i32, i32* %8
%95 = icmp slt i32 %93, %94
br i1 %95, label %96, label %126
96: ; preds = %92
store i32 0, i32* %2
br label %97
97: ; preds = %119, %96
%98 = load i32, i32* %2
%99 = load i32, i32* %7
%100 = icmp slt i32 %98, %99
br i1 %100, label %101, label %122
101: ; preds = %97
%102 = load double*, double** %11
%103 = load i32, i32* %4
%104 = load i32, i32* %8
%105 = mul nsw i32 %103, %104
%106 = load i32, i32* %7
%107 = mul nsw i32 %105, %106
%108 = load i32, i32* %3
%109 = load i32, i32* %7
%110 = mul nsw i32 %108, %109
%111 = add nsw i32 %107, %110
%112 = load i32, i32* %2
%113 = add nsw i32 %111, %112
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double, double* %102, i64 %114
%116 = load double, double* %115
%117 = load double, double* %5
%118 = fmul double %117, %116
store double %118, double* %5
br label %119
119: ; preds = %101
%120 = load i32, i32* %2
%121 = add nsw i32 %120, 1
store i32 %121, i32* %2
br label %97
122: ; preds = %97
br label %123
123: ; preds = %122
%124 = load i32, i32* %3
%125 = add nsw i32 %124, 1
store i32 %125, i32* %3
br label %92
126: ; preds = %92
br label %127
127: ; preds = %126
%128 = load i32, i32* %4
%129 = add nsw i32 %128, 1
store i32 %129, i32* %4
br label %87
130: ; preds = %87
%131 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%132 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%133 = load i32, i32* %132
%134 = mul nsw i32 %133, 1000
%135 = sitofp i32 %134 to double
%136 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%137 = load double, double* %136
%138 = fdiv double %137, 1.000000e+03
%139 = fadd double %135, %138
store double %139, double* %15
store double 1.000000e+00, double* %6
store i32 0, i32* %4
br label %140
140: ; preds = %180, %130
%141 = load i32, i32* %4
%142 = load i32, i32* %9
%143 = icmp slt i32 %141, %142
br i1 %143, label %144, label %183
144: ; preds = %140
store i32 0, i32* %3
br label %145
145: ; preds = %176, %144
%146 = load i32, i32* %3
%147 = load i32, i32* %8
%148 = icmp slt i32 %146, %147
br i1 %148, label %149, label %179
149: ; preds = %145
store i32 0, i32* %2
br label %150
150: ; preds = %172, %149
%151 = load i32, i32* %2
%152 = load i32, i32* %7
%153 = icmp slt i32 %151, %152
br i1 %153, label %154, label %175
154: ; preds = %150
%155 = load double*, double** %11
%156 = load i32, i32* %4
%157 = load i32, i32* %8
%158 = mul nsw i32 %156, %157
%159 = load i32, i32* %7
%160 = mul nsw i32 %158, %159
%161 = load i32, i32* %3
%162 = load i32, i32* %7
%163 = mul nsw i32 %161, %162
%164 = add nsw i32 %160, %163
%165 = load i32, i32* %2
%166 = add nsw i32 %164, %165
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds double, double* %155, i64 %167
%169 = load double, double* %168
%170 = load double, double* %6
%171 = fmul double %170, %169
store double %171, double* %6
br label %172
172: ; preds = %154
%173 = load i32, i32* %2
%174 = add nsw i32 %173, 1
store i32 %174, i32* %2
br label %150
175: ; preds = %150
br label %176
176: ; preds = %175
%177 = load i32, i32* %3
%178 = add nsw i32 %177, 1
store i32 %178, i32* %3
br label %145
179: ; preds = %145
br label %180
180: ; preds = %179
%181 = load i32, i32* %4
%182 = add nsw i32 %181, 1
store i32 %182, i32* %4
br label %140
183: ; preds = %140
%184 = load double, double* %5
%185 = load double, double* %6
%186 = fsub double %184, %185
%187 = call double @llvm.fabs.f64(double %186)
%188 = load double, double* %12
%189 = fcmp ogt double %187, %188
br i1 %189, label %190, label %196
190: ; preds = %183
%191 = load i32, i32* %10
%192 = add nsw i32 %191, 1
store i32 %192, i32* %10
%193 = load double, double* %5
%194 = load double, double* %6
%195 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), double %193, double %194)
br label %196
196: ; preds = %190, %183
%197 = load double, double* %15
%198 = load double, double* %14
%199 = fsub double %197, %198
%200 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), double %199)
%201 = load i32, i32* %10
%202 = icmp eq i32 %201, 0
br i1 %202, label %203, label %205
203: ; preds = %196
%204 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %205
205: ; preds = %203, %196
%206 = load double*, double** %11
%207 = call i32 @free(double* %206)
ret i32 1
}

LLVM IR (-O2):
%struct.timeval = type { i32, double }
@acc_device_default = global i32 0
@RAND_MAX = global i64 0
@.str = [59 x i8] c"gang_worker_vector + FAILED! product=%d, known_product=%d\0A\00"
@.str.1 = [51 x i8] c"gang_worker_vector + execution time is :%.2lf: ms\0A\00"
@str = [30 x i8] c"gang_worker_vector + SUCCESS!\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = tail call i64 @malloc(i32 262144)
%4 = inttoptr i64 %3 to double*
%5 = load i32, i32* @acc_device_default
%6 = tail call i32 @acc_init(i32 %5)
%7 = tail call i64 @time(i32 0)
%8 = trunc i64 %7 to i32
%9 = tail call i32 @srand(i32 %8)
br label %10
10: ; preds = %0, %32
%11 = phi i64 [ 0, %0 ], [ %33, %32 ]
%12 = shl nsw i64 %11, 10
br label %13
13: ; preds = %10, %29
%14 = phi i64 [ 0, %10 ], [ %30, %29 ]
%15 = shl nsw i64 %14, 5
%16 = add nuw nsw i64 %15, %12
br label %17
17: ; preds = %13, %17
%18 = phi i64 [ 0, %13 ], [ %27, %17 ]
%19 = tail call i64 (...) @rand()
%20 = sitofp i64 %19 to double
%21 = load i64, i64* @RAND_MAX
%22 = sitofp i64 %21 to double
%23 = fdiv double %20, %22
%24 = fadd double %23, 1.000000e-01
%25 = add nuw nsw i64 %16, %18
%26 = getelementptr inbounds double, double* %4, i64 %25
store double %24, double* %26
%27 = add nuw nsw i64 %18, 1
%28 = icmp eq i64 %27, 32
br i1 %28, label %29, label %17
29: ; preds = %17
%30 = add nuw nsw i64 %14, 1
%31 = icmp eq i64 %30, 32
br i1 %31, label %32, label %13
32: ; preds = %29
%33 = add nuw nsw i64 %11, 1
%34 = icmp eq i64 %33, 32
br i1 %34, label %35, label %10
35: ; preds = %32
%36 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%38 = load i32, i32* %37
%39 = mul nsw i32 %38, 1000
%40 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%41 = load double, double* %40
%42 = fdiv double %41, 1.000000e+03
br label %43
43: ; preds = %35, %181
%44 = phi i64 [ 0, %35 ], [ %182, %181 ]
%45 = phi double [ 1.000000e+00, %35 ], [ %178, %181 ]
%46 = shl nsw i64 %44, 10
br label %47
47: ; preds = %43, %47
%48 = phi i64 [ 0, %43 ], [ %179, %47 ]
%49 = phi double [ %45, %43 ], [ %178, %47 ]
%50 = shl nsw i64 %48, 5
%51 = add nuw nsw i64 %50, %46
%52 = getelementptr inbounds double, double* %4, i64 %51
%53 = load double, double* %52
%54 = fmul double %49, %53
%55 = or i64 %51, 1
%56 = getelementptr inbounds double, double* %4, i64 %55
%57 = load double, double* %56
%58 = fmul double %54, %57
%59 = or i64 %51, 2
%60 = getelementptr inbounds double, double* %4, i64 %59
%61 = load double, double* %60
%62 = fmul double %58, %61
%63 = or i64 %51, 3
%64 = getelementptr inbounds double, double* %4, i64 %63
%65 = load double, double* %64
%66 = fmul double %62, %65
%67 = or i64 %51, 4
%68 = getelementptr inbounds double, double* %4, i64 %67
%69 = load double, double* %68
%70 = fmul double %66, %69
%71 = or i64 %51, 5
%72 = getelementptr inbounds double, double* %4, i64 %71
%73 = load double, double* %72
%74 = fmul double %70, %73
%75 = or i64 %51, 6
%76 = getelementptr inbounds double, double* %4, i64 %75
%77 = load double, double* %76
%78 = fmul double %74, %77
%79 = or i64 %51, 7
%80 = getelementptr inbounds double, double* %4, i64 %79
%81 = load double, double* %80
%82 = fmul double %78, %81
%83 = or i64 %51, 8
%84 = getelementptr inbounds double, double* %4, i64 %83
%85 = load double, double* %84
%86 = fmul double %82, %85
%87 = or i64 %51, 9
%88 = getelementptr inbounds double, double* %4, i64 %87
%89 = load double, double* %88
%90 = fmul double %86, %89
%91 = or i64 %51, 10
%92 = getelementptr inbounds double, double* %4, i64 %91
%93 = load double, double* %92
%94 = fmul double %90, %93
%95 = or i64 %51, 11
%96 = getelementptr inbounds double, double* %4, i64 %95
%97 = load double, double* %96
%98 = fmul double %94, %97
%99 = or i64 %51, 12
%100 = getelementptr inbounds double, double* %4, i64 %99
%101 = load double, double* %100
%102 = fmul double %98, %101
%103 = or i64 %51, 13
%104 = getelementptr inbounds double, double* %4, i64 %103
%105 = load double, double* %104
%106 = fmul double %102, %105
%107 = or i64 %51, 14
%108 = getelementptr inbounds double, double* %4, i64 %107
%109 = load double, double* %108
%110 = fmul double %106, %109
%111 = or i64 %51, 15
%112 = getelementptr inbounds double, double* %4, i64 %111
%113 = load double, double* %112
%114 = fmul double %110, %113
%115 = or i64 %51, 16
%116 = getelementptr inbounds double, double* %4, i64 %115
%117 = load double, double* %116
%118 = fmul double %114, %117
%119 = or i64 %51, 17
%120 = getelementptr inbounds double, double* %4, i64 %119
%121 = load double, double* %120
%122 = fmul double %118, %121
%123 = or i64 %51, 18
%124 = getelementptr inbounds double, double* %4, i64 %123
%125 = load double, double* %124
%126 = fmul double %122, %125
%127 = or i64 %51, 19
%128 = getelementptr inbounds double, double* %4, i64 %127
%129 = load double, double* %128
%130 = fmul double %126, %129
%131 = or i64 %51, 20
%132 = getelementptr inbounds double, double* %4, i64 %131
%133 = load double, double* %132
%134 = fmul double %130, %133
%135 = or i64 %51, 21
%136 = getelementptr inbounds double, double* %4, i64 %135
%137 = load double, double* %136
%138 = fmul double %134, %137
%139 = or i64 %51, 22
%140 = getelementptr inbounds double, double* %4, i64 %139
%141 = load double, double* %140
%142 = fmul double %138, %141
%143 = or i64 %51, 23
%144 = getelementptr inbounds double, double* %4, i64 %143
%145 = load double, double* %144
%146 = fmul double %142, %145
%147 = or i64 %51, 24
%148 = getelementptr inbounds double, double* %4, i64 %147
%149 = load double, double* %148
%150 = fmul double %146, %149
%151 = or i64 %51, 25
%152 = getelementptr inbounds double, double* %4, i64 %151
%153 = load double, double* %152
%154 = fmul double %150, %153
%155 = or i64 %51, 26
%156 = getelementptr inbounds double, double* %4, i64 %155
%157 = load double, double* %156
%158 = fmul double %154, %157
%159 = or i64 %51, 27
%160 = getelementptr inbounds double, double* %4, i64 %159
%161 = load double, double* %160
%162 = fmul double %158, %161
%163 = or i64 %51, 28
%164 = getelementptr inbounds double, double* %4, i64 %163
%165 = load double, double* %164
%166 = fmul double %162, %165
%167 = or i64 %51, 29
%168 = getelementptr inbounds double, double* %4, i64 %167
%169 = load double, double* %168
%170 = fmul double %166, %169
%171 = or i64 %51, 30
%172 = getelementptr inbounds double, double* %4, i64 %171
%173 = load double, double* %172
%174 = fmul double %170, %173
%175 = or i64 %51, 31
%176 = getelementptr inbounds double, double* %4, i64 %175
%177 = load double, double* %176
%178 = fmul double %174, %177
%179 = add nuw nsw i64 %48, 1
%180 = icmp eq i64 %179, 32
br i1 %180, label %181, label %47
181: ; preds = %47
%182 = add nuw nsw i64 %44, 1
%183 = icmp eq i64 %182, 32
br i1 %183, label %184, label %43
184: ; preds = %181
%185 = sitofp i32 %39 to double
%186 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%187 = load i32, i32* %37
%188 = mul nsw i32 %187, 1000
%189 = load double, double* %40
%190 = fdiv double %189, 1.000000e+03
br label %191
191: ; preds = %184, %329
%192 = phi i64 [ 0, %184 ], [ %330, %329 ]
%193 = phi double [ 1.000000e+00, %184 ], [ %326, %329 ]
%194 = shl nsw i64 %192, 10
br label %195
195: ; preds = %191, %195
%196 = phi i64 [ 0, %191 ], [ %327, %195 ]
%197 = phi double [ %193, %191 ], [ %326, %195 ]
%198 = shl nsw i64 %196, 5
%199 = add nuw nsw i64 %198, %194
%200 = getelementptr inbounds double, double* %4, i64 %199
%201 = load double, double* %200
%202 = fmul double %197, %201
%203 = or i64 %199, 1
%204 = getelementptr inbounds double, double* %4, i64 %203
%205 = load double, double* %204
%206 = fmul double %202, %205
%207 = or i64 %199, 2
%208 = getelementptr inbounds double, double* %4, i64 %207
%209 = load double, double* %208
%210 = fmul double %206, %209
%211 = or i64 %199, 3
%212 = getelementptr inbounds double, double* %4, i64 %211
%213 = load double, double* %212
%214 = fmul double %210, %213
%215 = or i64 %199, 4
%216 = getelementptr inbounds double, double* %4, i64 %215
%217 = load double, double* %216
%218 = fmul double %214, %217
%219 = or i64 %199, 5
%220 = getelementptr inbounds double, double* %4, i64 %219
%221 = load double, double* %220
%222 = fmul double %218, %221
%223 = or i64 %199, 6
%224 = getelementptr inbounds double, double* %4, i64 %223
%225 = load double, double* %224
%226 = fmul double %222, %225
%227 = or i64 %199, 7
%228 = getelementptr inbounds double, double* %4, i64 %227
%229 = load double, double* %228
%230 = fmul double %226, %229
%231 = or i64 %199, 8
%232 = getelementptr inbounds double, double* %4, i64 %231
%233 = load double, double* %232
%234 = fmul double %230, %233
%235 = or i64 %199, 9
%236 = getelementptr inbounds double, double* %4, i64 %235
%237 = load double, double* %236
%238 = fmul double %234, %237
%239 = or i64 %199, 10
%240 = getelementptr inbounds double, double* %4, i64 %239
%241 = load double, double* %240
%242 = fmul double %238, %241
%243 = or i64 %199, 11
%244 = getelementptr inbounds double, double* %4, i64 %243
%245 = load double, double* %244
%246 = fmul double %242, %245
%247 = or i64 %199, 12
%248 = getelementptr inbounds double, double* %4, i64 %247
%249 = load double, double* %248
%250 = fmul double %246, %249
%251 = or i64 %199, 13
%252 = getelementptr inbounds double, double* %4, i64 %251
%253 = load double, double* %252
%254 = fmul double %250, %253
%255 = or i64 %199, 14
%256 = getelementptr inbounds double, double* %4, i64 %255
%257 = load double, double* %256
%258 = fmul double %254, %257
%259 = or i64 %199, 15
%260 = getelementptr inbounds double, double* %4, i64 %259
%261 = load double, double* %260
%262 = fmul double %258, %261
%263 = or i64 %199, 16
%264 = getelementptr inbounds double, double* %4, i64 %263
%265 = load double, double* %264
%266 = fmul double %262, %265
%267 = or i64 %199, 17
%268 = getelementptr inbounds double, double* %4, i64 %267
%269 = load double, double* %268
%270 = fmul double %266, %269
%271 = or i64 %199, 18
%272 = getelementptr inbounds double, double* %4, i64 %271
%273 = load double, double* %272
%274 = fmul double %270, %273
%275 = or i64 %199, 19
%276 = getelementptr inbounds double, double* %4, i64 %275
%277 = load double, double* %276
%278 = fmul double %274, %277
%279 = or i64 %199, 20
%280 = getelementptr inbounds double, double* %4, i64 %279
%281 = load double, double* %280
%282 = fmul double %278, %281
%283 = or i64 %199, 21
%284 = getelementptr inbounds double, double* %4, i64 %283
%285 = load double, double* %284
%286 = fmul double %282, %285
%287 = or i64 %199, 22
%288 = getelementptr inbounds double, double* %4, i64 %287
%289 = load double, double* %288
%290 = fmul double %286, %289
%291 = or i64 %199, 23
%292 = getelementptr inbounds double, double* %4, i64 %291
%293 = load double, double* %292
%294 = fmul double %290, %293
%295 = or i64 %199, 24
%296 = getelementptr inbounds double, double* %4, i64 %295
%297 = load double, double* %296
%298 = fmul double %294, %297
%299 = or i64 %199, 25
%300 = getelementptr inbounds double, double* %4, i64 %299
%301 = load double, double* %300
%302 = fmul double %298, %301
%303 = or i64 %199, 26
%304 = getelementptr inbounds double, double* %4, i64 %303
%305 = load double, double* %304
%306 = fmul double %302, %305
%307 = or i64 %199, 27
%308 = getelementptr inbounds double, double* %4, i64 %307
%309 = load double, double* %308
%310 = fmul double %306, %309
%311 = or i64 %199, 28
%312 = getelementptr inbounds double, double* %4, i64 %311
%313 = load double, double* %312
%314 = fmul double %310, %313
%315 = or i64 %199, 29
%316 = getelementptr inbounds double, double* %4, i64 %315
%317 = load double, double* %316
%318 = fmul double %314, %317
%319 = or i64 %199, 30
%320 = getelementptr inbounds double, double* %4, i64 %319
%321 = load double, double* %320
%322 = fmul double %318, %321
%323 = or i64 %199, 31
%324 = getelementptr inbounds double, double* %4, i64 %323
%325 = load double, double* %324
%326 = fmul double %322, %325
%327 = add nuw nsw i64 %196, 1
%328 = icmp eq i64 %327, 32
br i1 %328, label %329, label %195
329: ; preds = %195
%330 = add nuw nsw i64 %192, 1
%331 = icmp eq i64 %330, 32
br i1 %331, label %332, label %191
332: ; preds = %329
%333 = fadd double %42, %185
%334 = sitofp i32 %188 to double
%335 = fadd double %190, %334
%336 = fsub double %178, %326
%337 = tail call double @llvm.fabs.f64(double %336)
%338 = fcmp ogt double %337, 1.000000e-09
br i1 %338, label %339, label %343
339: ; preds = %332
%340 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), double %178, double %326)
%341 = fsub double %335, %333
%342 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), double %341)
br label %347
343: ; preds = %332
%344 = fsub double %335, %333
%345 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), double %344)
%346 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %347
347: ; preds = %339, %343
%348 = tail call i32 @free(double* %4)
ret i32 1
}