#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*/);
float fabsf(float);
int /*<<< orphan*/ free(float *);
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;
  float product, known_product;
  int NI, NJ, NK;
  int error;
  float *input, *temp;
  float rounding_error = 1.E-9;
  struct timeval tim;
  double start, end;
  NK = 1 << 10;
  NJ = 1 << 10;
  NI = 64;
  error = 0;
  input = (float *)malloc(NK * NJ * NI * sizeof(float));
  temp = (float *)malloc(NK * NJ * NI * sizeof(float));
  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] = (float)rand() / (float)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])                            \
    create(temp [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++)
          temp[k * NJ * NI + j * NI + i] = input[k * NJ * NI + j * NI + i];
        product *= temp[k * NJ * NI + j * NI];
      }
    }
  }
  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++) {
      known_product *= input[k * NJ * NI + j * NI];
    }
  }
  if (fabsf(product - known_product) > rounding_error) {
    error++;
    printf("gang_worker + FAILED! product=%d, known_product=%d\n", product,
           known_product);
  }
  printf("gang_worker + execution time is :%.2lf: ms\n", end - start);
  if (error == 0)
    printf("gang_worker + SUCCESS!\n");
  free(input);
  free(temp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xe69(%rip),%xmm0
movss  %xmm0,-0x3c(%rbp)
movl   $0x400,-0x24(%rbp)
movl   $0x400,-0x20(%rbp)
movl   $0x40,-0x1c(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x24(%rbp),%eax
imul   -0x20(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
imul   -0x20(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    0x2de1(%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    -0x24(%rbp),%eax
jge    12cc <main+0x14c>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    12b9 <main+0x139>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12a6 <main+0x126>
mov    $0x0,%al
call   10a0 <rand@plt>
cvtsi2ss %rax,%xmm0
mov    0x2d90(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xda3(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x20(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    -0xc(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
add    -0x8(%rbp),%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1239 <main+0xb9>
jmp    12ab <main+0x12b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1226 <main+0xa6>
jmp    12be <main+0x13e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1213 <main+0x93>
movss  0xd30(%rip),%xmm0
movss  %xmm0,-0x14(%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  0xd0a(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    13e3 <main+0x263>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    13d0 <main+0x250>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1398 <main+0x218>
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x20(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    -0xc(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
add    -0x8(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x20(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    -0xc(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
add    -0x8(%rbp),%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1338 <main+0x1b8>
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x20(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    -0xc(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1325 <main+0x1a5>
jmp    13d5 <main+0x255>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1312 <main+0x192>
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  0xc00(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movss  0xbe7(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1493 <main+0x313>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1480 <main+0x300>
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x20(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    -0xc(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    143c <main+0x2bc>
jmp    1485 <main+0x305>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1429 <main+0x2a9>
movss  -0x14(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
movaps 0xb7c(%rip),%xmm1
pand   %xmm1,%xmm0
ucomiss -0x3c(%rbp),%xmm0
jbe    14db <main+0x35b>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xb5c(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  -0x60(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
lea    0xb78(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x28(%rbp)
jne    150b <main+0x38b>
lea    0xb8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%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    $0x28,%rsp
mov    $0x10000000,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    $0x10000000,%edi
call   1090 <malloc@plt>
mov    %rax,%r13
mov    0x2e19(%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    0x2e0d(%rip),%rbx
mov    %r14,%rbp
xor    %eax,%eax
mov    %rax,(%rsp)
mov    %rbp,0x8(%rsp)
xor    %r15d,%r15d
nopl   0x0(%rax)
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   10b0 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssq (%rbx),%xmm1
divss  %xmm1,%xmm0
movsd  0xddd(%rip),%xmm1
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x0(%rbp,%r12,4)
add    $0x1,%r12
cmp    $0x40,%r12
jne    1200 <main+0x70>
add    $0x1,%r15
add    $0x100,%rbp
cmp    $0x400,%r15
jne    11f0 <main+0x60>
mov    (%rsp),%rax
add    $0x1,%rax
mov    0x8(%rsp),%rbp
add    $0x40000,%rbp
cmp    $0x400,%rax
jne    11e0 <main+0x50>
xor    %r15d,%r15d
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
imul   $0x3e8,0x10(%rsp),%r8d
movsd  0x18(%rsp),%xmm1
divsd  0xd6e(%rip),%xmm1
lea    0xc(%r13),%r9
lea    0xc(%r14),%r10
movss  0xd66(%rip),%xmm2
jmp    12cf <main+0x13f>
nopl   0x0(%rax)
add    $0x1,%r15
add    $0x40000,%r9
add    $0x40000,%r10
cmp    $0x400,%r15
je     14cd <main+0x33d>
mov    %r15,%r12
shl    $0x10,%r12
lea    0x40(%r12),%r11
mov    %r10,%rdx
mov    %r9,%rcx
xor    %eax,%eax
jmp    144b <main+0x2bb>
nopl   0x0(%rax,%rax,1)
lea    0x0(,%rdi,4),%rsi
movups (%r14,%rdi,4),%xmm0
movups %xmm0,0x0(%r13,%rdi,4)
mov    %rsi,%rbx
or     $0x10,%rbx
movups (%r14,%rbx,1),%xmm0
movups %xmm0,0x0(%r13,%rbx,1)
mov    %rsi,%rbx
or     $0x20,%rbx
movups (%r14,%rbx,1),%xmm0
movups %xmm0,0x0(%r13,%rbx,1)
mov    %rsi,%rbx
or     $0x30,%rbx
movups (%r14,%rbx,1),%xmm0
movups %xmm0,0x0(%r13,%rbx,1)
mov    %rsi,%rbx
or     $0x40,%rbx
movups (%r14,%rbx,1),%xmm0
movups %xmm0,0x0(%r13,%rbx,1)
mov    %rsi,%rbx
or     $0x50,%rbx
movups (%r14,%rbx,1),%xmm0
movups %xmm0,0x0(%r13,%rbx,1)
mov    %rsi,%rbx
or     $0x60,%rbx
movups (%r14,%rbx,1),%xmm0
movups %xmm0,0x0(%r13,%rbx,1)
mov    %rsi,%rbx
or     $0x70,%rbx
movups (%r14,%rbx,1),%xmm0
movups %xmm0,0x0(%r13,%rbx,1)
mov    %rsi,%rbx
or     $0x80,%rbx
movups (%r14,%rbx,1),%xmm0
movups %xmm0,0x0(%r13,%rbx,1)
mov    %rsi,%rbx
or     $0x90,%rbx
movups (%r14,%rbx,1),%xmm0
movups %xmm0,0x0(%r13,%rbx,1)
mov    %rsi,%rbx
or     $0xa0,%rbx
movups (%r14,%rbx,1),%xmm0
movups %xmm0,0x0(%r13,%rbx,1)
mov    %rsi,%rbx
or     $0xb0,%rbx
movups (%r14,%rbx,1),%xmm0
movups %xmm0,0x0(%r13,%rbx,1)
mov    %rsi,%rbx
or     $0xc0,%rbx
movups (%r14,%rbx,1),%xmm0
movups %xmm0,0x0(%r13,%rbx,1)
mov    %rsi,%rbx
or     $0xd0,%rbx
movups (%r14,%rbx,1),%xmm0
movups %xmm0,0x0(%r13,%rbx,1)
mov    %rsi,%rbx
or     $0xe0,%rbx
movups (%r14,%rbx,1),%xmm0
movups %xmm0,0x0(%r13,%rbx,1)
or     $0xf0,%rsi
movups (%r14,%rsi,1),%xmm0
movups %xmm0,0x0(%r13,%rsi,1)
mulss  0x0(%r13,%rdi,4),%xmm2
add    $0x1,%rax
add    $0x100,%rcx
add    $0x100,%rdx
cmp    $0x400,%rax
je     12b0 <main+0x120>
mov    %rax,%rsi
shl    $0x6,%rsi
lea    (%r12,%rsi,1),%rdi
add    %r11,%rsi
lea    (%r14,%rsi,4),%rbx
lea    0x0(,%rdi,4),%rbp
add    %r13,%rbp
cmp    %rbx,%rbp
jae    12f0 <main+0x160>
lea    (%r14,%rdi,4),%rbx
lea    0x0(,%rsi,4),%rsi
add    %r13,%rsi
cmp    %rsi,%rbx
jae    12f0 <main+0x160>
xor    %esi,%esi
nopl   0x0(%rax,%rax,1)
movss  -0xc(%rdx,%rsi,4),%xmm0
movss  %xmm0,-0xc(%rcx,%rsi,4)
movss  -0x8(%rdx,%rsi,4),%xmm0
movss  %xmm0,-0x8(%rcx,%rsi,4)
movss  -0x4(%rdx,%rsi,4),%xmm0
movss  %xmm0,-0x4(%rcx,%rsi,4)
movss  (%rdx,%rsi,4),%xmm0
movss  %xmm0,(%rcx,%rsi,4)
add    $0x4,%rsi
cmp    $0x40,%rsi
jne    1490 <main+0x300>
jmp    1426 <main+0x296>
xorps  %xmm0,%xmm0
cvtsi2sd %r8d,%xmm0
movsd  %xmm0,0x20(%rsp)
xor    %ebx,%ebx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
movsd  %xmm1,0x8(%rsp)
movss  %xmm2,(%rsp)
call   1060 <gettimeofday@plt>
movss  (%rsp),%xmm4
movsd  0x8(%rsp),%xmm3
imul   $0x3e8,0x10(%rsp),%eax
movsd  0x18(%rsp),%xmm5
divsd  0xaf3(%rip),%xmm5
mov    %r14,%rcx
add    $0x300,%rcx
movss  0xae9(%rip),%xmm1
nopw   0x0(%rax,%rax,1)
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mulss  -0x300(%rcx,%rdx,1),%xmm1
ff ff
mulss  -0x200(%rcx,%rdx,1),%xmm1
ff ff
mulss  -0x100(%rcx,%rdx,1),%xmm1
ff ff
mulss  (%rcx,%rdx,1),%xmm1
add    $0x400,%rdx
cmp    $0x40000,%rdx
jne    1540 <main+0x3b0>
add    $0x1,%rbx
add    $0x40000,%rcx
cmp    $0x400,%rbx
jne    1530 <main+0x3a0>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x20(%rsp),%xmm3
movaps %xmm4,%xmm2
subss  %xmm1,%xmm2
andps  0xa81(%rip),%xmm2
addsd  %xmm0,%xmm5
ucomiss 0xa6a(%rip),%xmm2
jbe    15eb <main+0x45b>
xorps  %xmm0,%xmm0
cvtss2sd %xmm4,%xmm0
cvtss2sd %xmm1,%xmm1
lea    0xa72(%rip),%rdi
mov    $0x2,%al
movsd  %xmm3,0x8(%rsp)
movsd  %xmm5,(%rsp)
call   1050 <printf@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
lea    0xa82(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    160d <main+0x47d>
subsd  %xmm3,%xmm5
lea    0xa6e(%rip),%rdi
movapd %xmm5,%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xa88(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x28,%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 = [52 x i8] c"gang_worker + FAILED! product=%d, known_product=%d\0A\00"
@.str.1 = [44 x i8] c"gang_worker + execution time is :%.2lf: ms\0A\00"
@.str.2 = [24 x i8] c"gang_worker + SUCCESS!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca float*
%12 = alloca float*
%13 = alloca float
%14 = alloca %struct.timeval
%15 = alloca double
%16 = alloca double
store i32 0, i32* %1
store float 0x3E112E0BE0000000, float* %13
store i32 1024, i32* %9
store i32 1024, i32* %8
store i32 64, i32* %7
store i32 0, i32* %10
%17 = load i32, i32* %9
%18 = load i32, i32* %8
%19 = mul nsw i32 %17, %18
%20 = load i32, i32* %7
%21 = mul nsw i32 %19, %20
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 4
%24 = trunc i64 %23 to i32
%25 = call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to float*
store float* %26, float** %11
%27 = load i32, i32* %9
%28 = load i32, i32* %8
%29 = mul nsw i32 %27, %28
%30 = load i32, i32* %7
%31 = mul nsw i32 %29, %30
%32 = sext i32 %31 to i64
%33 = mul i64 %32, 4
%34 = trunc i64 %33 to i32
%35 = call i64 @malloc(i32 %34)
%36 = inttoptr i64 %35 to float*
store float* %36, float** %12
%37 = load i32, i32* @acc_device_default
%38 = call i32 @acc_init(i32 %37)
%39 = call i64 @time(i32 0)
%40 = trunc i64 %39 to i32
%41 = call i32 @srand(i32 %40)
store i32 0, i32* %4
br label %42
42: ; preds = %87, %0
%43 = load i32, i32* %4
%44 = load i32, i32* %9
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %90
46: ; preds = %42
store i32 0, i32* %3
br label %47
47: ; preds = %83, %46
%48 = load i32, i32* %3
%49 = load i32, i32* %8
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %86
51: ; preds = %47
store i32 0, i32* %2
br label %52
52: ; preds = %79, %51
%53 = load i32, i32* %2
%54 = load i32, i32* %7
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %82
56: ; preds = %52
%57 = call i64 (...) @rand()
%58 = sitofp i64 %57 to float
%59 = load i64, i64* @RAND_MAX
%60 = sitofp i64 %59 to float
%61 = fdiv float %58, %60
%62 = fpext float %61 to double
%63 = fadd double %62, 1.000000e-01
%64 = fptrunc double %63 to float
%65 = load float*, float** %11
%66 = load i32, i32* %4
%67 = load i32, i32* %8
%68 = mul nsw i32 %66, %67
%69 = load i32, i32* %7
%70 = mul nsw i32 %68, %69
%71 = load i32, i32* %3
%72 = load i32, i32* %7
%73 = mul nsw i32 %71, %72
%74 = add nsw i32 %70, %73
%75 = load i32, i32* %2
%76 = add nsw i32 %74, %75
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds float, float* %65, i64 %77
store float %64, float* %78
br label %79
79: ; preds = %56
%80 = load i32, i32* %2
%81 = add nsw i32 %80, 1
store i32 %81, i32* %2
br label %52
82: ; preds = %52
br label %83
83: ; preds = %82
%84 = load i32, i32* %3
%85 = add nsw i32 %84, 1
store i32 %85, i32* %3
br label %47
86: ; preds = %47
br label %87
87: ; preds = %86
%88 = load i32, i32* %4
%89 = add nsw i32 %88, 1
store i32 %89, i32* %4
br label %42
90: ; preds = %42
store float 1.000000e+00, float* %5
%91 = call i32 @gettimeofday(%struct.timeval* %14, i32* null)
%92 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%93 = load i32, i32* %92
%94 = mul nsw i32 %93, 1000
%95 = sitofp i32 %94 to double
%96 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%97 = load double, double* %96
%98 = fdiv double %97, 1.000000e+03
%99 = fadd double %95, %98
store double %99, double* %15
store i32 0, i32* %4
br label %100
100: ; preds = %167, %90
%101 = load i32, i32* %4
%102 = load i32, i32* %9
%103 = icmp slt i32 %101, %102
br i1 %103, label %104, label %170
104: ; preds = %100
store i32 0, i32* %3
br label %105
105: ; preds = %163, %104
%106 = load i32, i32* %3
%107 = load i32, i32* %8
%108 = icmp slt i32 %106, %107
br i1 %108, label %109, label %166
109: ; preds = %105
store i32 0, i32* %2
br label %110
110: ; preds = %144, %109
%111 = load i32, i32* %2
%112 = load i32, i32* %7
%113 = icmp slt i32 %111, %112
br i1 %113, label %114, label %147
114: ; preds = %110
%115 = load float*, float** %11
%116 = load i32, i32* %4
%117 = load i32, i32* %8
%118 = mul nsw i32 %116, %117
%119 = load i32, i32* %7
%120 = mul nsw i32 %118, %119
%121 = load i32, i32* %3
%122 = load i32, i32* %7
%123 = mul nsw i32 %121, %122
%124 = add nsw i32 %120, %123
%125 = load i32, i32* %2
%126 = add nsw i32 %124, %125
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds float, float* %115, i64 %127
%129 = load float, float* %128
%130 = load float*, float** %12
%131 = load i32, i32* %4
%132 = load i32, i32* %8
%133 = mul nsw i32 %131, %132
%134 = load i32, i32* %7
%135 = mul nsw i32 %133, %134
%136 = load i32, i32* %3
%137 = load i32, i32* %7
%138 = mul nsw i32 %136, %137
%139 = add nsw i32 %135, %138
%140 = load i32, i32* %2
%141 = add nsw i32 %139, %140
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds float, float* %130, i64 %142
store float %129, float* %143
br label %144
144: ; preds = %114
%145 = load i32, i32* %2
%146 = add nsw i32 %145, 1
store i32 %146, i32* %2
br label %110
147: ; preds = %110
%148 = load float*, float** %12
%149 = load i32, i32* %4
%150 = load i32, i32* %8
%151 = mul nsw i32 %149, %150
%152 = load i32, i32* %7
%153 = mul nsw i32 %151, %152
%154 = load i32, i32* %3
%155 = load i32, i32* %7
%156 = mul nsw i32 %154, %155
%157 = add nsw i32 %153, %156
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds float, float* %148, i64 %158
%160 = load float, float* %159
%161 = load float, float* %5
%162 = fmul float %161, %160
store float %162, float* %5
br label %163
163: ; preds = %147
%164 = load i32, i32* %3
%165 = add nsw i32 %164, 1
store i32 %165, i32* %3
br label %105
166: ; preds = %105
br label %167
167: ; preds = %166
%168 = load i32, i32* %4
%169 = add nsw i32 %168, 1
store i32 %169, i32* %4
br label %100
170: ; preds = %100
%171 = call i32 @gettimeofday(%struct.timeval* %14, i32* null)
%172 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%173 = load i32, i32* %172
%174 = mul nsw i32 %173, 1000
%175 = sitofp i32 %174 to double
%176 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%177 = load double, double* %176
%178 = fdiv double %177, 1.000000e+03
%179 = fadd double %175, %178
store double %179, double* %16
store float 1.000000e+00, float* %6
store i32 0, i32* %4
br label %180
180: ; preds = %209, %170
%181 = load i32, i32* %4
%182 = load i32, i32* %9
%183 = icmp slt i32 %181, %182
br i1 %183, label %184, label %212
184: ; preds = %180
store i32 0, i32* %3
br label %185
185: ; preds = %205, %184
%186 = load i32, i32* %3
%187 = load i32, i32* %8
%188 = icmp slt i32 %186, %187
br i1 %188, label %189, label %208
189: ; preds = %185
%190 = load float*, float** %11
%191 = load i32, i32* %4
%192 = load i32, i32* %8
%193 = mul nsw i32 %191, %192
%194 = load i32, i32* %7
%195 = mul nsw i32 %193, %194
%196 = load i32, i32* %3
%197 = load i32, i32* %7
%198 = mul nsw i32 %196, %197
%199 = add nsw i32 %195, %198
%200 = sext i32 %199 to i64
%201 = getelementptr inbounds float, float* %190, i64 %200
%202 = load float, float* %201
%203 = load float, float* %6
%204 = fmul float %203, %202
store float %204, float* %6
br label %205
205: ; preds = %189
%206 = load i32, i32* %3
%207 = add nsw i32 %206, 1
store i32 %207, i32* %3
br label %185
208: ; preds = %185
br label %209
209: ; preds = %208
%210 = load i32, i32* %4
%211 = add nsw i32 %210, 1
store i32 %211, i32* %4
br label %180
212: ; preds = %180
%213 = load float, float* %5
%214 = load float, float* %6
%215 = fsub float %213, %214
%216 = call float @llvm.fabs.f32(float %215)
%217 = load float, float* %13
%218 = fcmp ogt float %216, %217
br i1 %218, label %219, label %227
219: ; preds = %212
%220 = load i32, i32* %10
%221 = add nsw i32 %220, 1
store i32 %221, i32* %10
%222 = load float, float* %5
%223 = fpext float %222 to double
%224 = load float, float* %6
%225 = fpext float %224 to double
%226 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), double %223, double %225)
br label %227
227: ; preds = %219, %212
%228 = load double, double* %16
%229 = load double, double* %15
%230 = fsub double %228, %229
%231 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), double %230)
%232 = load i32, i32* %10
%233 = icmp eq i32 %232, 0
br i1 %233, label %234, label %236
234: ; preds = %227
%235 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %236
236: ; preds = %234, %227
%237 = load float*, float** %11
%238 = call i32 @free(float* %237)
%239 = load float*, float** %12
%240 = call i32 @free(float* %239)
%241 = load i32, i32* %1
ret i32 %241
}

LLVM IR (-O2):
%struct.timeval = type { i32, double }
@acc_device_default = global i32 0
@RAND_MAX = global i64 0
@.str = [52 x i8] c"gang_worker + FAILED! product=%d, known_product=%d\0A\00"
@.str.1 = [44 x i8] c"gang_worker + execution time is :%.2lf: ms\0A\00"
@str = [23 x i8] c"gang_worker + SUCCESS!\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = tail call i64 @malloc(i32 268435456)
%4 = inttoptr i64 %3 to float*
%5 = tail call i64 @malloc(i32 268435456)
%6 = load i32, i32* @acc_device_default
%7 = tail call i32 @acc_init(i32 %6)
%8 = tail call i64 @time(i32 0)
%9 = trunc i64 %8 to i32
%10 = tail call i32 @srand(i32 %9)
br label %11
11: ; preds = %0, %35
%12 = phi i64 [ 0, %0 ], [ %36, %35 ]
%13 = shl nsw i64 %12, 16
br label %14
14: ; preds = %11, %32
%15 = phi i64 [ 0, %11 ], [ %33, %32 ]
%16 = shl nsw i64 %15, 6
%17 = add nuw nsw i64 %16, %13
br label %18
18: ; preds = %14, %18
%19 = phi i64 [ 0, %14 ], [ %30, %18 ]
%20 = tail call i64 (...) @rand()
%21 = sitofp i64 %20 to float
%22 = load i64, i64* @RAND_MAX
%23 = sitofp i64 %22 to float
%24 = fdiv float %21, %23
%25 = fpext float %24 to double
%26 = fadd double %25, 1.000000e-01
%27 = fptrunc double %26 to float
%28 = add nuw nsw i64 %17, %19
%29 = getelementptr inbounds float, float* %4, i64 %28
store float %27, float* %29
%30 = add nuw nsw i64 %19, 1
%31 = icmp eq i64 %30, 64
br i1 %31, label %32, label %18
32: ; preds = %18
%33 = add nuw nsw i64 %15, 1
%34 = icmp eq i64 %33, 1024
br i1 %34, label %35, label %14
35: ; preds = %32
%36 = add nuw nsw i64 %12, 1
%37 = icmp eq i64 %36, 1024
br i1 %37, label %38, label %11
38: ; preds = %35
%39 = inttoptr i64 %5 to float*
%40 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%41 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%42 = load i32, i32* %41
%43 = mul nsw i32 %42, 1000
%44 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%45 = load double, double* %44
%46 = fdiv double %45, 1.000000e+03
br label %47
47: ; preds = %38, %193
%48 = phi i64 [ 0, %38 ], [ %194, %193 ]
%49 = phi float [ 1.000000e+00, %38 ], [ %190, %193 ]
%50 = shl nuw nsw i64 %48, 16
%51 = or i64 %50, 64
%52 = shl nsw i64 %48, 16
br label %53
53: ; preds = %47, %187
%54 = phi i64 [ 0, %47 ], [ %191, %187 ]
%55 = phi float [ %49, %47 ], [ %190, %187 ]
%56 = shl nuw nsw i64 %54, 6
%57 = add nuw i64 %50, %56
%58 = add nuw i64 %51, %56
%59 = shl nsw i64 %54, 6
%60 = add nuw nsw i64 %59, %52
%61 = getelementptr float, float* %4, i64 %58
%62 = getelementptr float, float* %4, i64 %57
%63 = getelementptr float, float* %39, i64 %58
%64 = getelementptr float, float* %39, i64 %57
%65 = icmp ult float* %64, %61
%66 = icmp ult float* %62, %63
%67 = and i1 %65, %66
br i1 %67, label %164, label %68
68: ; preds = %53
%69 = getelementptr inbounds float, float* %4, i64 %60
%70 = bitcast float* %69 to <4 x float>*
%71 = load <4 x float>, <4 x float>* %70
%72 = getelementptr inbounds float, float* %39, i64 %60
%73 = bitcast float* %72 to <4 x float>*
store <4 x float> %71, <4 x float>* %73
%74 = or i64 %60, 4
%75 = getelementptr inbounds float, float* %4, i64 %74
%76 = bitcast float* %75 to <4 x float>*
%77 = load <4 x float>, <4 x float>* %76
%78 = getelementptr inbounds float, float* %39, i64 %74
%79 = bitcast float* %78 to <4 x float>*
store <4 x float> %77, <4 x float>* %79
%80 = or i64 %60, 8
%81 = getelementptr inbounds float, float* %4, i64 %80
%82 = bitcast float* %81 to <4 x float>*
%83 = load <4 x float>, <4 x float>* %82
%84 = getelementptr inbounds float, float* %39, i64 %80
%85 = bitcast float* %84 to <4 x float>*
store <4 x float> %83, <4 x float>* %85
%86 = or i64 %60, 12
%87 = getelementptr inbounds float, float* %4, i64 %86
%88 = bitcast float* %87 to <4 x float>*
%89 = load <4 x float>, <4 x float>* %88
%90 = getelementptr inbounds float, float* %39, i64 %86
%91 = bitcast float* %90 to <4 x float>*
store <4 x float> %89, <4 x float>* %91
%92 = or i64 %60, 16
%93 = getelementptr inbounds float, float* %4, i64 %92
%94 = bitcast float* %93 to <4 x float>*
%95 = load <4 x float>, <4 x float>* %94
%96 = getelementptr inbounds float, float* %39, i64 %92
%97 = bitcast float* %96 to <4 x float>*
store <4 x float> %95, <4 x float>* %97
%98 = or i64 %60, 20
%99 = getelementptr inbounds float, float* %4, i64 %98
%100 = bitcast float* %99 to <4 x float>*
%101 = load <4 x float>, <4 x float>* %100
%102 = getelementptr inbounds float, float* %39, i64 %98
%103 = bitcast float* %102 to <4 x float>*
store <4 x float> %101, <4 x float>* %103
%104 = or i64 %60, 24
%105 = getelementptr inbounds float, float* %4, i64 %104
%106 = bitcast float* %105 to <4 x float>*
%107 = load <4 x float>, <4 x float>* %106
%108 = getelementptr inbounds float, float* %39, i64 %104
%109 = bitcast float* %108 to <4 x float>*
store <4 x float> %107, <4 x float>* %109
%110 = or i64 %60, 28
%111 = getelementptr inbounds float, float* %4, i64 %110
%112 = bitcast float* %111 to <4 x float>*
%113 = load <4 x float>, <4 x float>* %112
%114 = getelementptr inbounds float, float* %39, i64 %110
%115 = bitcast float* %114 to <4 x float>*
store <4 x float> %113, <4 x float>* %115
%116 = or i64 %60, 32
%117 = getelementptr inbounds float, float* %4, i64 %116
%118 = bitcast float* %117 to <4 x float>*
%119 = load <4 x float>, <4 x float>* %118
%120 = getelementptr inbounds float, float* %39, i64 %116
%121 = bitcast float* %120 to <4 x float>*
store <4 x float> %119, <4 x float>* %121
%122 = or i64 %60, 36
%123 = getelementptr inbounds float, float* %4, i64 %122
%124 = bitcast float* %123 to <4 x float>*
%125 = load <4 x float>, <4 x float>* %124
%126 = getelementptr inbounds float, float* %39, i64 %122
%127 = bitcast float* %126 to <4 x float>*
store <4 x float> %125, <4 x float>* %127
%128 = or i64 %60, 40
%129 = getelementptr inbounds float, float* %4, i64 %128
%130 = bitcast float* %129 to <4 x float>*
%131 = load <4 x float>, <4 x float>* %130
%132 = getelementptr inbounds float, float* %39, i64 %128
%133 = bitcast float* %132 to <4 x float>*
store <4 x float> %131, <4 x float>* %133
%134 = or i64 %60, 44
%135 = getelementptr inbounds float, float* %4, i64 %134
%136 = bitcast float* %135 to <4 x float>*
%137 = load <4 x float>, <4 x float>* %136
%138 = getelementptr inbounds float, float* %39, i64 %134
%139 = bitcast float* %138 to <4 x float>*
store <4 x float> %137, <4 x float>* %139
%140 = or i64 %60, 48
%141 = getelementptr inbounds float, float* %4, i64 %140
%142 = bitcast float* %141 to <4 x float>*
%143 = load <4 x float>, <4 x float>* %142
%144 = getelementptr inbounds float, float* %39, i64 %140
%145 = bitcast float* %144 to <4 x float>*
store <4 x float> %143, <4 x float>* %145
%146 = or i64 %60, 52
%147 = getelementptr inbounds float, float* %4, i64 %146
%148 = bitcast float* %147 to <4 x float>*
%149 = load <4 x float>, <4 x float>* %148
%150 = getelementptr inbounds float, float* %39, i64 %146
%151 = bitcast float* %150 to <4 x float>*
store <4 x float> %149, <4 x float>* %151
%152 = or i64 %60, 56
%153 = getelementptr inbounds float, float* %4, i64 %152
%154 = bitcast float* %153 to <4 x float>*
%155 = load <4 x float>, <4 x float>* %154
%156 = getelementptr inbounds float, float* %39, i64 %152
%157 = bitcast float* %156 to <4 x float>*
store <4 x float> %155, <4 x float>* %157
%158 = or i64 %60, 60
%159 = getelementptr inbounds float, float* %4, i64 %158
%160 = bitcast float* %159 to <4 x float>*
%161 = load <4 x float>, <4 x float>* %160
%162 = getelementptr inbounds float, float* %39, i64 %158
%163 = bitcast float* %162 to <4 x float>*
store <4 x float> %161, <4 x float>* %163
br label %187
164: ; preds = %53, %164
%165 = phi i64 [ %185, %164 ], [ 0, %53 ]
%166 = add nuw nsw i64 %60, %165
%167 = getelementptr inbounds float, float* %4, i64 %166
%168 = load float, float* %167
%169 = getelementptr inbounds float, float* %39, i64 %166
store float %168, float* %169
%170 = or i64 %165, 1
%171 = add nuw nsw i64 %60, %170
%172 = getelementptr inbounds float, float* %4, i64 %171
%173 = load float, float* %172
%174 = getelementptr inbounds float, float* %39, i64 %171
store float %173, float* %174
%175 = or i64 %165, 2
%176 = add nuw nsw i64 %60, %175
%177 = getelementptr inbounds float, float* %4, i64 %176
%178 = load float, float* %177
%179 = getelementptr inbounds float, float* %39, i64 %176
store float %178, float* %179
%180 = or i64 %165, 3
%181 = add nuw nsw i64 %60, %180
%182 = getelementptr inbounds float, float* %4, i64 %181
%183 = load float, float* %182
%184 = getelementptr inbounds float, float* %39, i64 %181
store float %183, float* %184
%185 = add nuw nsw i64 %165, 4
%186 = icmp eq i64 %185, 64
br i1 %186, label %187, label %164
187: ; preds = %164, %68
%188 = getelementptr inbounds float, float* %39, i64 %60
%189 = load float, float* %188
%190 = fmul float %55, %189
%191 = add nuw nsw i64 %54, 1
%192 = icmp eq i64 %191, 1024
br i1 %192, label %193, label %53
193: ; preds = %187
%194 = add nuw nsw i64 %48, 1
%195 = icmp eq i64 %194, 1024
br i1 %195, label %196, label %47
196: ; preds = %193
%197 = sitofp i32 %43 to double
%198 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%199 = load i32, i32* %41
%200 = mul nsw i32 %199, 1000
%201 = load double, double* %44
%202 = fdiv double %201, 1.000000e+03
br label %203
203: ; preds = %196, %235
%204 = phi i64 [ 0, %196 ], [ %236, %235 ]
%205 = phi float [ 1.000000e+00, %196 ], [ %232, %235 ]
%206 = shl nsw i64 %204, 16
br label %207
207: ; preds = %207, %203
%208 = phi i64 [ 0, %203 ], [ %233, %207 ]
%209 = phi float [ %205, %203 ], [ %232, %207 ]
%210 = shl nuw nsw i64 %208, 6
%211 = add nuw nsw i64 %210, %206
%212 = getelementptr inbounds float, float* %4, i64 %211
%213 = load float, float* %212
%214 = fmul float %209, %213
%215 = shl i64 %208, 6
%216 = or i64 %215, 64
%217 = add nuw nsw i64 %216, %206
%218 = getelementptr inbounds float, float* %4, i64 %217
%219 = load float, float* %218
%220 = fmul float %214, %219
%221 = shl i64 %208, 6
%222 = or i64 %221, 128
%223 = add nuw nsw i64 %222, %206
%224 = getelementptr inbounds float, float* %4, i64 %223
%225 = load float, float* %224
%226 = fmul float %220, %225
%227 = shl i64 %208, 6
%228 = or i64 %227, 192
%229 = add nuw nsw i64 %228, %206
%230 = getelementptr inbounds float, float* %4, i64 %229
%231 = load float, float* %230
%232 = fmul float %226, %231
%233 = add nuw nsw i64 %208, 4
%234 = icmp eq i64 %233, 1024
br i1 %234, label %235, label %207
235: ; preds = %207
%236 = add nuw nsw i64 %204, 1
%237 = icmp eq i64 %236, 1024
br i1 %237, label %238, label %203
238: ; preds = %235
%239 = fadd double %46, %197
%240 = sitofp i32 %200 to double
%241 = fadd double %202, %240
%242 = fsub float %190, %232
%243 = tail call float @llvm.fabs.f32(float %242)
%244 = fcmp ogt float %243, 0x3E112E0BE0000000
br i1 %244, label %245, label %251
245: ; preds = %238
%246 = fpext float %190 to double
%247 = fpext float %232 to double
%248 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), double %246, double %247)
%249 = fsub double %241, %239
%250 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), double %249)
br label %255
251: ; preds = %238
%252 = fsub double %241, %239
%253 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), double %252)
%254 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %255
255: ; preds = %245, %251
%256 = tail call i32 @free(float* %4)
%257 = tail call i32 @free(float* %39)
ret i32 0
}