#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*/ 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;
  int sum, known_sum;
  int NI, NJ, NK;
  int error;
  float *input, *temp;
  float rounding_error = 1.E-9;
  struct timeval tim;
  double start, end;
  NK = 1 << 20;
  NJ = 2;
  NI = 32;
  input = (float *)malloc(NK * NJ * NI * sizeof(float));
  temp = (float *)malloc(NK * NJ * NI * sizeof(float));
  error = 0;
  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;
      }
    }
  }
  float 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];
    }
  }
  gettimeofday(&tim, NULL);
  end = tim.tv_sec * 1000 + (tim.tv_usec / 1000.0);
  float known_product = 1;
  for (k = 0; k < NK; k++)
    known_product *= input[k * NJ * NI];
  if (fabsf(product - known_product) > rounding_error) {
    error++;
    printf("gang * FAILED! product=%d, known_product=%d\n", product,
           known_product);
  }
  printf("gang * execution time is :%.2lf: ms\n", end - start);
  if (error == 0)
    printf("gang * SUCCESS!\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xe79(%rip),%xmm0
movss  %xmm0,-0x3c(%rbp)
movl   $0x100000,-0x24(%rbp)
movl   $0x2,-0x20(%rbp)
movl   $0x20,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
imul   -0x20(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <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   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x28(%rbp)
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
call   1080 <acc_init@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12bc <main+0x14c>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    12a9 <main+0x139>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1296 <main+0x126>
mov    $0x0,%al
call   1090 <rand@plt>
cvtsi2ss %rax,%xmm0
mov    0x2da0(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdb3(%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    1229 <main+0xb9>
jmp    129b <main+0x12b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1216 <main+0xa6>
jmp    12ae <main+0x13e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1203 <main+0x93>
movss  0xd40(%rip),%xmm0
movss  %xmm0,-0x64(%rbp)
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
imul   $0x3e8,-0x50(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xd1a(%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    13ca <main+0x25a>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    139b <main+0x22b>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1388 <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    1328 <main+0x1b8>
jmp    138d <main+0x21d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1315 <main+0x1a5>
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x20(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mulss  -0x64(%rbp),%xmm0
movss  %xmm0,-0x64(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1302 <main+0x192>
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
imul   $0x3e8,-0x50(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xc19(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movss  0xc00(%rip),%xmm0
movss  %xmm0,-0x68(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    144b <main+0x2db>
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x20(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mulss  -0x68(%rbp),%xmm0
movss  %xmm0,-0x68(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1410 <main+0x2a0>
movss  -0x64(%rbp),%xmm0
subss  -0x68(%rbp),%xmm0
movaps 0xbc4(%rip),%xmm1
pand   %xmm1,%xmm0
ucomiss -0x3c(%rbp),%xmm0
jbe    1493 <main+0x323>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
movss  -0x64(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x68(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xba4(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x60(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
lea    0xbb9(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x28(%rbp)
jne    14c3 <main+0x353>
lea    0xbc6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%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   1080 <malloc@plt>
mov    %rax,%r12
mov    $0x10000000,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
call   1090 <acc_init@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    0x2e1d(%rip),%r15
mov    %r12,%rbx
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   10a0 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssq (%r15),%xmm1
divss  %xmm1,%xmm0
movsd  0xded(%rip),%xmm1
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rbx,%rbp,4)
add    $0x1,%rbp
cmp    $0x20,%rbp
jne    11f0 <main+0x70>
mov    $0x20,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   10a0 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssq (%r15),%xmm1
divss  %xmm1,%xmm0
movsd  0xd9d(%rip),%xmm1
cvtss2sd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rbx,%rbp,4)
add    $0x1,%rbp
cmp    $0x40,%rbp
jne    1240 <main+0xc0>
add    $0x1,%r13
add    $0x100,%rbx
cmp    $0x100000,%r13
jne    11e0 <main+0x60>
xor    %r15d,%r15d
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
imul   $0x3e8,0x10(%rsp),%r8d
movsd  0x18(%rsp),%xmm1
divsd  0xd4c(%rip),%xmm1
lea    0xc(%r14),%rcx
lea    0xc(%r12),%rdx
lea    0x8c(%r14),%rsi
lea    0x8c(%r12),%rdi
movss  0xd34(%rip),%xmm2
jmp    13c4 <main+0x244>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r9,%rax
or     $0x20,%rax
movups (%r12,%rax,4),%xmm0
movups %xmm0,(%r14,%rax,4)
lea    0x0(,%r9,4),%rax
mov    %rax,%rbp
or     $0x90,%rbp
movups (%r12,%rbp,1),%xmm0
movups %xmm0,(%r14,%rbp,1)
mov    %rax,%rbp
or     $0xa0,%rbp
movups (%r12,%rbp,1),%xmm0
movups %xmm0,(%r14,%rbp,1)
mov    %rax,%rbp
or     $0xb0,%rbp
movups (%r12,%rbp,1),%xmm0
movups %xmm0,(%r14,%rbp,1)
mov    %rax,%rbp
or     $0xc0,%rbp
movups (%r12,%rbp,1),%xmm0
movups %xmm0,(%r14,%rbp,1)
mov    %rax,%rbp
or     $0xd0,%rbp
movups (%r12,%rbp,1),%xmm0
movups %xmm0,(%r14,%rbp,1)
mov    %rax,%rbp
or     $0xe0,%rbp
movups (%r12,%rbp,1),%xmm0
movups %xmm0,(%r14,%rbp,1)
or     $0xf0,%rax
movups (%r12,%rax,1),%xmm0
movups %xmm0,(%r14,%rax,1)
mulss  (%r14,%r9,4),%xmm2
add    $0x1,%r15
add    $0x100,%rcx
add    $0x100,%rdx
add    $0x100,%rsi
add    $0x100,%rdi
cmp    $0x100000,%r15
je     152d <main+0x3ad>
mov    %r15,%r9
shl    $0x6,%r9
mov    %r15,%rax
shl    $0x8,%rax
lea    (%r14,%rax,1),%r11
add    $0x80,%r11
lea    (%r12,%rax,1),%r10
add    $0x80,%r10
lea    (%r14,%rax,1),%rbp
cmp    %r10,%rbp
jae    1440 <main+0x2c0>
lea    (%r12,%rax,1),%rbp
cmp    %r11,%rbp
jae    1440 <main+0x2c0>
xor    %ebp,%ebp
nopl   0x0(%rax)
movss  -0xc(%rdx,%rbp,4),%xmm0
movss  %xmm0,-0xc(%rcx,%rbp,4)
movss  -0x8(%rdx,%rbp,4),%xmm0
movss  %xmm0,-0x8(%rcx,%rbp,4)
movss  -0x4(%rdx,%rbp,4),%xmm0
movss  %xmm0,-0x4(%rcx,%rbp,4)
movss  (%rdx,%rbp,4),%xmm0
movss  %xmm0,(%rcx,%rbp,4)
add    $0x4,%rbp
cmp    $0x20,%rbp
jne    1400 <main+0x280>
jmp    14c6 <main+0x346>
nopl   (%rax)
lea    0x0(,%r9,4),%rbp
movups (%r12,%r9,4),%xmm0
movups %xmm0,(%r14,%r9,4)
mov    %rbp,%rbx
or     $0x10,%rbx
movups (%r12,%rbx,1),%xmm0
movups %xmm0,(%r14,%rbx,1)
mov    %rbp,%rbx
or     $0x20,%rbx
movups (%r12,%rbx,1),%xmm0
movups %xmm0,(%r14,%rbx,1)
mov    %rbp,%rbx
or     $0x30,%rbx
movups (%r12,%rbx,1),%xmm0
movups %xmm0,(%r14,%rbx,1)
mov    %rbp,%rbx
or     $0x40,%rbx
movups (%r12,%rbx,1),%xmm0
movups %xmm0,(%r14,%rbx,1)
mov    %rbp,%rbx
or     $0x50,%rbx
movups (%r12,%rbx,1),%xmm0
movups %xmm0,(%r14,%rbx,1)
mov    %rbp,%rbx
or     $0x60,%rbx
movups (%r12,%rbx,1),%xmm0
movups %xmm0,(%r14,%rbx,1)
or     $0x70,%rbp
movups (%r12,%rbp,1),%xmm0
movups %xmm0,(%r14,%rbp,1)
lea    (%r12,%rax,1),%rbx
add    $0x100,%rbx
cmp    %rbx,%r11
jae    12f0 <main+0x170>
add    %r14,%rax
add    $0x100,%rax
cmp    %rax,%r10
jae    12f0 <main+0x170>
xor    %eax,%eax
xchg   %ax,%ax
movss  -0xc(%rdi,%rax,4),%xmm0
movss  %xmm0,-0xc(%rsi,%rax,4)
movss  -0x8(%rdi,%rax,4),%xmm0
movss  %xmm0,-0x8(%rsi,%rax,4)
movss  -0x4(%rdi,%rax,4),%xmm0
movss  %xmm0,-0x4(%rsi,%rax,4)
movss  (%rdi,%rax,4),%xmm0
movss  %xmm0,(%rsi,%rax,4)
add    $0x4,%rax
cmp    $0x20,%rax
jne    14f0 <main+0x370>
jmp    1391 <main+0x211>
movss  %xmm2,(%rsp)
movsd  %xmm1,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r8d,%xmm0
movsd  %xmm0,0x20(%rsp)
xor    %ebx,%ebx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
imul   $0x3e8,0x10(%rsp),%eax
movsd  0x18(%rsp),%xmm5
divsd  0xa9e(%rip),%xmm5
movss  0xa9e(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mulss  (%r12,%rbx,1),%xmm1
mulss  0x100(%r12,%rbx,1),%xmm1
mulss  0x200(%r12,%rbx,1),%xmm1
mulss  0x300(%r12,%rbx,1),%xmm1
add    $0x400,%rbx
cmp    $0x10000000,%rbx
jne    1580 <main+0x400>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm3
addsd  0x20(%rsp),%xmm3
movss  (%rsp),%xmm4
movaps %xmm4,%xmm2
subss  %xmm1,%xmm2
andps  0xa46(%rip),%xmm2
addsd  %xmm0,%xmm5
ucomiss 0xa2f(%rip),%xmm2
jbe    1626 <main+0x4a6>
xorps  %xmm0,%xmm0
cvtss2sd %xmm4,%xmm0
cvtss2sd %xmm1,%xmm1
lea    0xa37(%rip),%rdi
mov    $0x2,%al
movsd  %xmm3,0x8(%rsp)
movsd  %xmm5,(%rsp)
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
lea    0xa40(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1648 <main+0x4c8>
subsd  %xmm3,%xmm5
lea    0xa2c(%rip),%rdi
movapd %xmm5,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xa3f(%rip),%rdi
call   1030 <puts@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 = [45 x i8] c"gang * FAILED! product=%d, known_product=%d\0A\00"
@.str.1 = [37 x i8] c"gang * execution time is :%.2lf: ms\0A\00"
@.str.2 = [17 x i8] c"gang * SUCCESS!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%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
%17 = alloca float
%18 = alloca float
store i32 0, i32* %1
store float 0x3E112E0BE0000000, float* %13
store i32 1048576, i32* %9
store i32 2, i32* %8
store i32 32, i32* %7
%19 = load i32, i32* %9
%20 = load i32, i32* %8
%21 = mul nsw i32 %19, %20
%22 = load i32, i32* %7
%23 = mul nsw i32 %21, %22
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 4
%26 = trunc i64 %25 to i32
%27 = call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to float*
store float* %28, float** %11
%29 = load i32, i32* %9
%30 = load i32, i32* %8
%31 = mul nsw i32 %29, %30
%32 = load i32, i32* %7
%33 = mul nsw i32 %31, %32
%34 = sext i32 %33 to i64
%35 = mul i64 %34, 4
%36 = trunc i64 %35 to i32
%37 = call i64 @malloc(i32 %36)
%38 = inttoptr i64 %37 to float*
store float* %38, float** %12
store i32 0, i32* %10
%39 = load i32, i32* @acc_device_default
%40 = call i32 @acc_init(i32 %39)
%41 = call i64 @time(i32 0)
%42 = trunc i64 %41 to i32
%43 = call i32 @srand(i32 %42)
store i32 0, i32* %4
br label %44
44: ; preds = %89, %0
%45 = load i32, i32* %4
%46 = load i32, i32* %9
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %92
48: ; preds = %44
store i32 0, i32* %3
br label %49
49: ; preds = %85, %48
%50 = load i32, i32* %3
%51 = load i32, i32* %8
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %88
53: ; preds = %49
store i32 0, i32* %2
br label %54
54: ; preds = %81, %53
%55 = load i32, i32* %2
%56 = load i32, i32* %7
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %84
58: ; preds = %54
%59 = call i64 (...) @rand()
%60 = sitofp i64 %59 to float
%61 = load i64, i64* @RAND_MAX
%62 = sitofp i64 %61 to float
%63 = fdiv float %60, %62
%64 = fpext float %63 to double
%65 = fadd double %64, 1.000000e-01
%66 = fptrunc double %65 to float
%67 = load float*, float** %11
%68 = load i32, i32* %4
%69 = load i32, i32* %8
%70 = mul nsw i32 %68, %69
%71 = load i32, i32* %7
%72 = mul nsw i32 %70, %71
%73 = load i32, i32* %3
%74 = load i32, i32* %7
%75 = mul nsw i32 %73, %74
%76 = add nsw i32 %72, %75
%77 = load i32, i32* %2
%78 = add nsw i32 %76, %77
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds float, float* %67, i64 %79
store float %66, float* %80
br label %81
81: ; preds = %58
%82 = load i32, i32* %2
%83 = add nsw i32 %82, 1
store i32 %83, i32* %2
br label %54
84: ; preds = %54
br label %85
85: ; preds = %84
%86 = load i32, i32* %3
%87 = add nsw i32 %86, 1
store i32 %87, i32* %3
br label %49
88: ; preds = %49
br label %89
89: ; preds = %88
%90 = load i32, i32* %4
%91 = add nsw i32 %90, 1
store i32 %91, i32* %4
br label %44
92: ; preds = %44
store float 1.000000e+00, float* %17
%93 = call i32 @gettimeofday(%struct.timeval* %14, i32* null)
%94 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%95 = load i32, i32* %94
%96 = mul nsw i32 %95, 1000
%97 = sitofp i32 %96 to double
%98 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%99 = load double, double* %98
%100 = fdiv double %99, 1.000000e+03
%101 = fadd double %97, %100
store double %101, double* %15
store i32 0, i32* %4
br label %102
102: ; preds = %165, %92
%103 = load i32, i32* %4
%104 = load i32, i32* %9
%105 = icmp slt i32 %103, %104
br i1 %105, label %106, label %168
106: ; preds = %102
store i32 0, i32* %3
br label %107
107: ; preds = %150, %106
%108 = load i32, i32* %3
%109 = load i32, i32* %8
%110 = icmp slt i32 %108, %109
br i1 %110, label %111, label %153
111: ; preds = %107
store i32 0, i32* %2
br label %112
112: ; preds = %146, %111
%113 = load i32, i32* %2
%114 = load i32, i32* %7
%115 = icmp slt i32 %113, %114
br i1 %115, label %116, label %149
116: ; preds = %112
%117 = load float*, float** %11
%118 = load i32, i32* %4
%119 = load i32, i32* %8
%120 = mul nsw i32 %118, %119
%121 = load i32, i32* %7
%122 = mul nsw i32 %120, %121
%123 = load i32, i32* %3
%124 = load i32, i32* %7
%125 = mul nsw i32 %123, %124
%126 = add nsw i32 %122, %125
%127 = load i32, i32* %2
%128 = add nsw i32 %126, %127
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds float, float* %117, i64 %129
%131 = load float, float* %130
%132 = load float*, float** %12
%133 = load i32, i32* %4
%134 = load i32, i32* %8
%135 = mul nsw i32 %133, %134
%136 = load i32, i32* %7
%137 = mul nsw i32 %135, %136
%138 = load i32, i32* %3
%139 = load i32, i32* %7
%140 = mul nsw i32 %138, %139
%141 = add nsw i32 %137, %140
%142 = load i32, i32* %2
%143 = add nsw i32 %141, %142
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds float, float* %132, i64 %144
store float %131, float* %145
br label %146
146: ; preds = %116
%147 = load i32, i32* %2
%148 = add nsw i32 %147, 1
store i32 %148, i32* %2
br label %112
149: ; preds = %112
br label %150
150: ; preds = %149
%151 = load i32, i32* %3
%152 = add nsw i32 %151, 1
store i32 %152, i32* %3
br label %107
153: ; preds = %107
%154 = load float*, float** %12
%155 = load i32, i32* %4
%156 = load i32, i32* %8
%157 = mul nsw i32 %155, %156
%158 = load i32, i32* %7
%159 = mul nsw i32 %157, %158
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds float, float* %154, i64 %160
%162 = load float, float* %161
%163 = load float, float* %17
%164 = fmul float %163, %162
store float %164, float* %17
br label %165
165: ; preds = %153
%166 = load i32, i32* %4
%167 = add nsw i32 %166, 1
store i32 %167, i32* %4
br label %102
168: ; preds = %102
%169 = call i32 @gettimeofday(%struct.timeval* %14, i32* null)
%170 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%171 = load i32, i32* %170
%172 = mul nsw i32 %171, 1000
%173 = sitofp i32 %172 to double
%174 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%175 = load double, double* %174
%176 = fdiv double %175, 1.000000e+03
%177 = fadd double %173, %176
store double %177, double* %16
store float 1.000000e+00, float* %18
store i32 0, i32* %4
br label %178
178: ; preds = %194, %168
%179 = load i32, i32* %4
%180 = load i32, i32* %9
%181 = icmp slt i32 %179, %180
br i1 %181, label %182, label %197
182: ; preds = %178
%183 = load float*, float** %11
%184 = load i32, i32* %4
%185 = load i32, i32* %8
%186 = mul nsw i32 %184, %185
%187 = load i32, i32* %7
%188 = mul nsw i32 %186, %187
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds float, float* %183, i64 %189
%191 = load float, float* %190
%192 = load float, float* %18
%193 = fmul float %192, %191
store float %193, float* %18
br label %194
194: ; preds = %182
%195 = load i32, i32* %4
%196 = add nsw i32 %195, 1
store i32 %196, i32* %4
br label %178
197: ; preds = %178
%198 = load float, float* %17
%199 = load float, float* %18
%200 = fsub float %198, %199
%201 = call float @llvm.fabs.f32(float %200)
%202 = load float, float* %13
%203 = fcmp ogt float %201, %202
br i1 %203, label %204, label %212
204: ; preds = %197
%205 = load i32, i32* %10
%206 = add nsw i32 %205, 1
store i32 %206, i32* %10
%207 = load float, float* %17
%208 = fpext float %207 to double
%209 = load float, float* %18
%210 = fpext float %209 to double
%211 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), double %208, double %210)
br label %212
212: ; preds = %204, %197
%213 = load double, double* %16
%214 = load double, double* %15
%215 = fsub double %213, %214
%216 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %215)
%217 = load i32, i32* %10
%218 = icmp eq i32 %217, 0
br i1 %218, label %219, label %221
219: ; preds = %212
%220 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %221
221: ; preds = %219, %212
%222 = load i32, i32* %1
ret i32 %222
}

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