#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 */
typedef int int64_t;

/* Variables and functions */
double atan2(double, double);
int /*<<< orphan*/ printf(char *, int, ...);
double sqrt(int);
void compare_NSquared_correlator_results_data_has_upper_triangle_only(
    int *num_err, int64_t *err_2, int actual_num_frequencies,
    int actual_num_elements, int *data_set_GPU, int *data_set_CPU,
    double *ratio_GPU_div_CPU, double *phase_difference, int verbosity) {
  int address = 0;
  int local_Address = 0;
  *num_err = 0;
  *err_2 = 0;
  int max_error = 0;
  int amplitude_squared_error;
  double amplitude_squared_CPU;
  double amplitude_squared_GPU;
  double phase_angle_CPU;
  double phase_angle_GPU;
  for (int freq = 0; freq < actual_num_frequencies; freq++) {
    for (int element_y = 0; element_y < actual_num_elements; element_y++) {
      for (int element_x = element_y; element_x < actual_num_elements;
           element_x++) {
        int data_Real_GPU = data_set_GPU[address];
        int data_Real_CPU = data_set_CPU[address++];
        int difference_real = data_Real_GPU - data_Real_CPU;
        int data_Imag_GPU = data_set_GPU[address];
        int data_Imag_CPU = data_set_CPU[address++];
        int difference_imag = data_Imag_GPU - data_Imag_CPU;
        amplitude_squared_CPU =
            data_Real_CPU * data_Real_CPU + data_Imag_CPU * data_Imag_CPU;
        amplitude_squared_GPU =
            data_Real_GPU * data_Real_GPU + data_Imag_GPU * data_Imag_GPU;
        phase_angle_CPU = atan2((double)data_Imag_CPU, (double)data_Real_CPU);
        phase_angle_GPU = atan2((double)data_Imag_GPU, (double)data_Real_GPU);
        if (amplitude_squared_CPU != 0) {
          ratio_GPU_div_CPU[local_Address] =
              amplitude_squared_GPU / amplitude_squared_CPU;
        } else {
          ratio_GPU_div_CPU[local_Address] = -1;
        }
        phase_difference[local_Address++] = phase_angle_GPU - phase_angle_CPU;
        if (difference_real != 0 || difference_imag != 0) {
          (*num_err)++;
          if (verbosity) {
            printf("freq: %6d element_x: %6d element_y: %6d Real CPU/GPU %8d "
                   "%8d Imaginary CPU/GPU %8d %8d ERR: %7d\n",
                   freq, element_x, element_y, data_Real_CPU, data_Real_GPU,
                   data_Imag_CPU, data_Imag_GPU, *num_err);
          }
          amplitude_squared_error = difference_imag * difference_imag +
                                    difference_real * difference_real;
          *err_2 += amplitude_squared_error;
          if (amplitude_squared_error > max_error)
            max_error = amplitude_squared_error;
        } else {
          if (verbosity) {
            printf("freq: %6d element_x: %6d element_y: %6d Real CPU/GPU %8d "
                   "%8d Imaginary CPU/GPU %8d %8d\n",
                   freq, element_x, element_y, data_Real_CPU, data_Real_GPU,
                   data_Imag_CPU, data_Imag_GPU);
          }
        }
      }
    }
  }
  printf("\nTotal number of errors: %d, Sum of Squared Differences: %lld \n",
         *num_err, (long long int)*err_2);
  printf("sqrt(sum of squared differences/numberElements): %f \n",
         sqrt((*err_2) * 1.0 / local_Address));
  printf("Maximum amplitude squared error: %d\n", max_error);
  return;
}


x86 assembly (clang, -O0):
<compare_NSquared_correlator_results_data_has_upper_triangle_only>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13f2 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x2c2>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    13df <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x2af>
mov    -0x60(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    13cc <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x29c>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x68(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%eax
sub    -0x6c(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x74(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x78(%rbp)
mov    -0x74(%rbp),%eax
sub    -0x78(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x6c(%rbp),%eax
imul   -0x6c(%rbp),%eax
mov    -0x78(%rbp),%ecx
imul   -0x78(%rbp),%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x68(%rbp),%eax
imul   -0x68(%rbp),%eax
mov    -0x74(%rbp),%ecx
imul   -0x74(%rbp),%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
cvtsi2sdl -0x78(%rbp),%xmm0
cvtsi2sdl -0x6c(%rbp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x50(%rbp)
cvtsi2sdl -0x74(%rbp),%xmm0
cvtsi2sdl -0x68(%rbp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1292 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x162>
jp     1292 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x162>
jmp    12ae <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x17e>
movsd  -0x48(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
mov    0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    12c3 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x193>
mov    0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  0xd4a(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
mov    0x18(%rbp),%rax
mov    -0x30(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x30(%rbp)
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
cmpl   $0x0,-0x70(%rbp)
jne    12f8 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x1c8>
cmpl   $0x0,-0x7c(%rbp)
je     137c <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x24c>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
cmpl   $0x0,0x20(%rbp)
je     1347 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x217>
mov    -0x5c(%rbp),%esi
mov    -0x64(%rbp),%edx
mov    -0x60(%rbp),%ecx
mov    -0x6c(%rbp),%r8d
mov    -0x68(%rbp),%r9d
mov    -0x78(%rbp),%r11d
mov    -0x74(%rbp),%r10d
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
lea    0xcdd(%rip),%rdi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x7c(%rbp),%eax
imul   -0x7c(%rbp),%eax
mov    -0x70(%rbp),%ecx
imul   -0x70(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jle    1377 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x247>
mov    -0x38(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    13b9 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x289>
cmpl   $0x0,0x20(%rbp)
je     13b4 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x284>
mov    -0x5c(%rbp),%esi
mov    -0x64(%rbp),%edx
mov    -0x60(%rbp),%ecx
mov    -0x6c(%rbp),%r8d
mov    -0x68(%rbp),%r9d
mov    -0x78(%rbp),%r10d
mov    -0x74(%rbp),%eax
lea    0xccc(%rip),%rdi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13b9 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x289>
jmp    13be <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x28e>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11b1 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x81>
jmp    13d1 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x2a1>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    119f <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x6f>
jmp    13e4 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x2b4>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    118c <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x5c>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
movslq (%rax),%rdx
lea    0xcc3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
movsd  0xbe3(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
cvttsd2si %xmm0,%esi
lea    0xccb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xcf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_NSquared_correlator_results_data_has_upper_triangle_only>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rsi,%rbp
mov    0xf0(%rsp),%eax
mov    %eax,0x1c(%rsp)
mov    0xe8(%rsp),%rax
mov    %rax,0x70(%rsp)
mov    0xe0(%rsp),%rax
mov    %rax,0x68(%rsp)
mov    %rdi,0x30(%rsp)
movl   $0x0,(%rdi)
movl   $0x0,(%rsi)
mov    %edx,0x24(%rsp)
test   %edx,%edx
jle    142f <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x2ff>
add    $0x4,%r8
mov    %r8,0x58(%rsp)
add    $0x4,%r9
mov    %r9,0x60(%rsp)
mov    %ecx,%eax
mov    %rax,0x50(%rsp)
xor    %esi,%esi
xor    %ebx,%ebx
xor    %r14d,%r14d
movl   $0x0,0x4(%rsp)
mov    %rbp,0x38(%rsp)
mov    %ecx,0x28(%rsp)
jmp    11e3 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0xb3>
nopl   0x0(%rax)
add    %ebp,%edx
mov    %edx,%ebx
mov    0x38(%rsp),%rbp
mov    0x8(%rsp),%r14d
mov    0x4(%rsp),%eax
add    $0x1,%eax
mov    %eax,0x4(%rsp)
cmp    0x24(%rsp),%eax
je     1429 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x2f9>
test   %ecx,%ecx
jle    11ce <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x9e>
mov    %r14d,0x8(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
mov    0x50(%rsp),%rax
mov    %rax,0x40(%rsp)
jmp    1224 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0xf4>
nop
mov    0x78(%rsp),%rdx
lea    (%rdx,%rbp,1),%ebx
mov    0x10(%rsp),%rax
add    $0x1,%rax
addq   $0xffffffffffffffff,0x40(%rsp)
mov    0x28(%rsp),%ecx
mov    %rax,0x10(%rsp)
cmp    %ecx,%eax
je     11c0 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x90>
mov    %ebx,%ecx
movslq %esi,%rax
mov    %rcx,0x78(%rsp)
movslq %ecx,%rcx
mov    0x68(%rsp),%rdx
lea    (%rdx,%rcx,8),%rdx
mov    %rdx,0x98(%rsp)
mov    0x70(%rsp),%rdx
lea    (%rdx,%rcx,8),%rcx
mov    %rcx,0x90(%rsp)
mov    0x58(%rsp),%rcx
lea    (%rcx,%rax,4),%rcx
mov    %rcx,0x88(%rsp)
mov    0x60(%rsp),%rcx
lea    (%rcx,%rax,4),%rax
mov    %rax,0x80(%rsp)
xor    %ebp,%ebp
jmp    12b6 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x186>
nopl   0x0(%rax)
imul   %ebx,%ebx
imul   %r15d,%r15d
add    %ebx,%r15d
mov    0x38(%rsp),%rax
add    %r15d,(%rax)
mov    0x8(%rsp),%eax
cmp    %eax,%r15d
cmovg  %r15d,%eax
mov    %eax,0x8(%rsp)
mov    0xc(%rsp),%esi
add    $0x1,%rbp
add    $0x2,%esi
cmp    %ebp,0x40(%rsp)
je     1200 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0xd0>
mov    %esi,0xc(%rsp)
mov    0x88(%rsp),%rax
mov    -0x4(%rax,%rbp,8),%r12d
mov    (%rax,%rbp,8),%r14d
mov    0x80(%rsp),%rax
mov    -0x4(%rax,%rbp,8),%edx
mov    (%rax,%rbp,8),%eax
mov    %r12d,%r15d
sub    %edx,%r15d
mov    %r14d,%ecx
sub    %eax,%ecx
mov    %ecx,0x2c(%rsp)
mov    %edx,%ebx
imul   %edx,%ebx
mov    %eax,%r13d
imul   %eax,%r13d
mov    %rax,0x48(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %edx,0x20(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,0xa0(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r12d,%xmm1
call   1030 <atan2@plt>
movsd  0xcc9(%rip),%xmm1
add    %ebx,%r13d
je     135f <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x22f>
xorps  %xmm2,%xmm2
cvtsi2sd %r13d,%xmm2
mov    %r12d,%eax
imul   %r12d,%eax
mov    %r14d,%ecx
imul   %r14d,%ecx
add    %eax,%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
divsd  %xmm2,%xmm1
mov    0x10(%rsp),%rax
lea    (%rax,%rbp,1),%rdx
mov    0x98(%rsp),%rax
movsd  %xmm1,(%rax,%rbp,8)
subsd  0xa0(%rsp),%xmm0
mov    0x90(%rsp),%rax
movsd  %xmm0,(%rax,%rbp,8)
mov    %r15d,%eax
mov    0x2c(%rsp),%ebx
or     %ebx,%eax
je     13f0 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x2c0>
mov    0x30(%rsp),%rax
mov    (%rax),%r11d
add    $0x1,%r11d
mov    %r11d,(%rax)
cmpl   $0x0,0x1c(%rsp)
je     1280 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x150>
sub    $0x8,%rsp
lea    0xc4d(%rip),%rdi
mov    0xc(%rsp),%esi
mov    0x18(%rsp),%rcx
mov    0x28(%rsp),%r8d
mov    %r12d,%r9d
xor    %eax,%eax
push   %r11
push   %r14
push   0x60(%rsp)
call   1040 <printf@plt>
add    $0x20,%rsp
jmp    1280 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x150>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpl   $0x0,0x1c(%rsp)
je     12a1 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x171>
lea    0xc67(%rip),%rdi
mov    0x4(%rsp),%esi
mov    0x10(%rsp),%rcx
mov    0x20(%rsp),%r8d
mov    %r12d,%r9d
xor    %eax,%eax
push   %r14
push   0x50(%rsp)
call   1040 <printf@plt>
add    $0x10,%rsp
jmp    12a1 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x171>
movslq 0x0(%rbp),%rdx
jmp    1436 <compare_NSquared_correlator_results_data_has_upper_triangle_only+0x306>
xor    %edx,%edx
xor    %r14d,%r14d
xor    %ebx,%ebx
mov    0x30(%rsp),%rax
mov    (%rax),%esi
lea    0xc7d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x0(%rbp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
cvttsd2si %xmm0,%esi
lea    0xc8f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcb7(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [97 x i8] c"freq: %6d element_x: %6d element_y: %6d Real CPU/GPU %8d %8d Imaginary CPU/GPU %8d %8d ERR: %7d\0A\00"
@.str.1 = [88 x i8] c"freq: %6d element_x: %6d element_y: %6d Real CPU/GPU %8d %8d Imaginary CPU/GPU %8d %8d\0A\00"
@.str.2 = [64 x i8] c"\0ATotal number of errors: %d, Sum of Squared Differences: %lld \0A\00"
@.str.3 = [54 x i8] c"sqrt(sum of squared differences/numberElements): %f \0A\00"
@.str.4 = [37 x i8] c"Maximum amplitude squared error: %d\0A\00"
define void @compare_NSquared_correlator_results_data_has_upper_triangle_only(i32* %0, i32* %1, i32 %2, i32 %3, i32* %4, i32* %5, double* %6, double* %7, i32 %8) {
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca double*
%17 = alloca double*
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
%34 = alloca i32
%35 = alloca i32
store i32* %0, i32** %10
store i32* %1, i32** %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32* %4, i32** %14
store i32* %5, i32** %15
store double* %6, double** %16
store double* %7, double** %17
store i32 %8, i32* %18
store i32 0, i32* %19
store i32 0, i32* %20
%36 = load i32*, i32** %10
store i32 0, i32* %36
%37 = load i32*, i32** %11
store i32 0, i32* %37
store i32 0, i32* %21
store i32 0, i32* %27
br label %38
38: ; preds = %194, %9
%39 = load i32, i32* %27
%40 = load i32, i32* %12
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %197
42: ; preds = %38
store i32 0, i32* %28
br label %43
43: ; preds = %190, %42
%44 = load i32, i32* %28
%45 = load i32, i32* %13
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %193
47: ; preds = %43
%48 = load i32, i32* %28
store i32 %48, i32* %29
br label %49
49: ; preds = %186, %47
%50 = load i32, i32* %29
%51 = load i32, i32* %13
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %189
53: ; preds = %49
%54 = load i32*, i32** %14
%55 = load i32, i32* %19
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %54, i64 %56
%58 = load i32, i32* %57
store i32 %58, i32* %30
%59 = load i32*, i32** %15
%60 = load i32, i32* %19
%61 = add nsw i32 %60, 1
store i32 %61, i32* %19
%62 = sext i32 %60 to i64
%63 = getelementptr inbounds i32, i32* %59, i64 %62
%64 = load i32, i32* %63
store i32 %64, i32* %31
%65 = load i32, i32* %30
%66 = load i32, i32* %31
%67 = sub nsw i32 %65, %66
store i32 %67, i32* %32
%68 = load i32*, i32** %14
%69 = load i32, i32* %19
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %68, i64 %70
%72 = load i32, i32* %71
store i32 %72, i32* %33
%73 = load i32*, i32** %15
%74 = load i32, i32* %19
%75 = add nsw i32 %74, 1
store i32 %75, i32* %19
%76 = sext i32 %74 to i64
%77 = getelementptr inbounds i32, i32* %73, i64 %76
%78 = load i32, i32* %77
store i32 %78, i32* %34
%79 = load i32, i32* %33
%80 = load i32, i32* %34
%81 = sub nsw i32 %79, %80
store i32 %81, i32* %35
%82 = load i32, i32* %31
%83 = load i32, i32* %31
%84 = mul nsw i32 %82, %83
%85 = load i32, i32* %34
%86 = load i32, i32* %34
%87 = mul nsw i32 %85, %86
%88 = add nsw i32 %84, %87
%89 = sitofp i32 %88 to double
store double %89, double* %23
%90 = load i32, i32* %30
%91 = load i32, i32* %30
%92 = mul nsw i32 %90, %91
%93 = load i32, i32* %33
%94 = load i32, i32* %33
%95 = mul nsw i32 %93, %94
%96 = add nsw i32 %92, %95
%97 = sitofp i32 %96 to double
store double %97, double* %24
%98 = load i32, i32* %34
%99 = sitofp i32 %98 to double
%100 = load i32, i32* %31
%101 = sitofp i32 %100 to double
%102 = call double @atan2(double %99, double %101)
store double %102, double* %25
%103 = load i32, i32* %33
%104 = sitofp i32 %103 to double
%105 = load i32, i32* %30
%106 = sitofp i32 %105 to double
%107 = call double @atan2(double %104, double %106)
store double %107, double* %26
%108 = load double, double* %23
%109 = fcmp une double %108, 0.000000e+00
br i1 %109, label %110, label %118
110: ; preds = %53
%111 = load double, double* %24
%112 = load double, double* %23
%113 = fdiv double %111, %112
%114 = load double*, double** %16
%115 = load i32, i32* %20
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds double, double* %114, i64 %116
store double %113, double* %117
br label %123
118: ; preds = %53
%119 = load double*, double** %16
%120 = load i32, i32* %20
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds double, double* %119, i64 %121
store double -1.000000e+00, double* %122
br label %123
123: ; preds = %118, %110
%124 = load double, double* %26
%125 = load double, double* %25
%126 = fsub double %124, %125
%127 = load double*, double** %17
%128 = load i32, i32* %20
%129 = add nsw i32 %128, 1
store i32 %129, i32* %20
%130 = sext i32 %128 to i64
%131 = getelementptr inbounds double, double* %127, i64 %130
store double %126, double* %131
%132 = load i32, i32* %32
%133 = icmp ne i32 %132, 0
br i1 %133, label %137, label %134
134: ; preds = %123
%135 = load i32, i32* %35
%136 = icmp ne i32 %135, 0
br i1 %136, label %137, label %172
137: ; preds = %134, %123
%138 = load i32*, i32** %10
%139 = load i32, i32* %138
%140 = add nsw i32 %139, 1
store i32 %140, i32* %138
%141 = load i32, i32* %18
%142 = icmp ne i32 %141, 0
br i1 %142, label %143, label %154
143: ; preds = %137
%144 = load i32, i32* %27
%145 = load i32, i32* %29
%146 = load i32, i32* %28
%147 = load i32, i32* %31
%148 = load i32, i32* %30
%149 = load i32, i32* %34
%150 = load i32, i32* %33
%151 = load i32*, i32** %10
%152 = load i32, i32* %151
%153 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0), i32 %144, i32 %145, i32 %146, i32 %147, i32 %148, i32 %149, i32 %150, i32 %152)
br label %154
154: ; preds = %143, %137
%155 = load i32, i32* %35
%156 = load i32, i32* %35
%157 = mul nsw i32 %155, %156
%158 = load i32, i32* %32
%159 = load i32, i32* %32
%160 = mul nsw i32 %158, %159
%161 = add nsw i32 %157, %160
store i32 %161, i32* %22
%162 = load i32, i32* %22
%163 = load i32*, i32** %11
%164 = load i32, i32* %163
%165 = add nsw i32 %164, %162
store i32 %165, i32* %163
%166 = load i32, i32* %22
%167 = load i32, i32* %21
%168 = icmp sgt i32 %166, %167
br i1 %168, label %169, label %171
169: ; preds = %154
%170 = load i32, i32* %22
store i32 %170, i32* %21
br label %171
171: ; preds = %169, %154
br label %185
172: ; preds = %134
%173 = load i32, i32* %18
%174 = icmp ne i32 %173, 0
br i1 %174, label %175, label %184
175: ; preds = %172
%176 = load i32, i32* %27
%177 = load i32, i32* %29
%178 = load i32, i32* %28
%179 = load i32, i32* %31
%180 = load i32, i32* %30
%181 = load i32, i32* %34
%182 = load i32, i32* %33
%183 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.1, i64 0, i64 0), i32 %176, i32 %177, i32 %178, i32 %179, i32 %180, i32 %181, i32 %182)
br label %184
184: ; preds = %175, %172
br label %185
185: ; preds = %184, %171
br label %186
186: ; preds = %185
%187 = load i32, i32* %29
%188 = add nsw i32 %187, 1
store i32 %188, i32* %29
br label %49
189: ; preds = %49
br label %190
190: ; preds = %189
%191 = load i32, i32* %28
%192 = add nsw i32 %191, 1
store i32 %192, i32* %28
br label %43
193: ; preds = %43
br label %194
194: ; preds = %193
%195 = load i32, i32* %27
%196 = add nsw i32 %195, 1
store i32 %196, i32* %27
br label %38
197: ; preds = %38
%198 = load i32*, i32** %10
%199 = load i32, i32* %198
%200 = load i32*, i32** %11
%201 = load i32, i32* %200
%202 = sext i32 %201 to i64
%203 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i32 %199, i64 %202)
%204 = load i32*, i32** %11
%205 = load i32, i32* %204
%206 = sitofp i32 %205 to double
%207 = fmul double %206, 1.000000e+00
%208 = load i32, i32* %20
%209 = sitofp i32 %208 to double
%210 = fdiv double %207, %209
%211 = fptosi double %210 to i32
%212 = call double @sqrt(i32 %211)
%213 = fptosi double %212 to i32
%214 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 %213)
%215 = load i32, i32* %21
%216 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %215)
ret void
}

LLVM IR (-O2):
@.str = [97 x i8] c"freq: %6d element_x: %6d element_y: %6d Real CPU/GPU %8d %8d Imaginary CPU/GPU %8d %8d ERR: %7d\0A\00"
@.str.1 = [88 x i8] c"freq: %6d element_x: %6d element_y: %6d Real CPU/GPU %8d %8d Imaginary CPU/GPU %8d %8d\0A\00"
@.str.2 = [64 x i8] c"\0ATotal number of errors: %d, Sum of Squared Differences: %lld \0A\00"
@.str.3 = [54 x i8] c"sqrt(sum of squared differences/numberElements): %f \0A\00"
@.str.4 = [37 x i8] c"Maximum amplitude squared error: %d\0A\00"
define void @compare_NSquared_correlator_results_data_has_upper_triangle_only(i32* nocapture %0, i32* nocapture %1, i32 %2, i32 %3, i32* nocapture %4, i32* nocapture %5, double* nocapture writeonly %6, double* nocapture writeonly %7, i32 %8) {
store i32 0, i32* %0
store i32 0, i32* %1
%10 = icmp sgt i32 %2, 0
br i1 %10, label %11, label %22
11: ; preds = %9
%12 = icmp sgt i32 %3, 0
%13 = icmp eq i32 %8, 0
br label %14
14: ; preds = %11, %47
%15 = phi i32 [ 0, %11 ], [ %50, %47 ]
%16 = phi i32 [ 0, %11 ], [ %49, %47 ]
%17 = phi i32 [ 0, %11 ], [ %48, %47 ]
%18 = phi i32 [ 0, %11 ], [ %51, %47 ]
br i1 %12, label %37, label %47
19: ; preds = %47
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
br label %22
22: ; preds = %19, %9
%23 = phi i64 [ 0, %9 ], [ %21, %19 ]
%24 = phi i32 [ 0, %9 ], [ %48, %19 ]
%25 = phi i32 [ 0, %9 ], [ %49, %19 ]
%26 = load i32, i32* %0
%27 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i32 %26, i64 %23)
%28 = load i32, i32* %1
%29 = sitofp i32 %28 to double
%30 = sitofp i32 %25 to double
%31 = fdiv double %29, %30
%32 = fptosi double %31 to i32
%33 = tail call double @sqrt(i32 %32)
%34 = fptosi double %33 to i32
%35 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %24)
ret void
37: ; preds = %14, %53
%38 = phi i32 [ %55, %53 ], [ %15, %14 ]
%39 = phi i32 [ %54, %53 ], [ %16, %14 ]
%40 = phi i32 [ %118, %53 ], [ %17, %14 ]
%41 = phi i32 [ %56, %53 ], [ 0, %14 ]
%42 = sext i32 %38 to i64
%43 = sext i32 %39 to i64
br label %58
44: ; preds = %53
%45 = trunc i64 %96 to i32
%46 = trunc i64 %71 to i32
br label %47
47: ; preds = %44, %14
%48 = phi i32 [ %17, %14 ], [ %118, %44 ]
%49 = phi i32 [ %16, %14 ], [ %45, %44 ]
%50 = phi i32 [ %15, %14 ], [ %46, %44 ]
%51 = add nuw nsw i32 %18, 1
%52 = icmp eq i32 %51, %2
br i1 %52, label %19, label %14
53: ; preds = %117
%54 = trunc i64 %96 to i32
%55 = trunc i64 %71 to i32
%56 = add nuw nsw i32 %41, 1
%57 = icmp eq i32 %56, %3
br i1 %57, label %44, label %37
58: ; preds = %37, %117
%59 = phi i64 [ %43, %37 ], [ %96, %117 ]
%60 = phi i64 [ %42, %37 ], [ %71, %117 ]
%61 = phi i32 [ %40, %37 ], [ %118, %117 ]
%62 = phi i32 [ %41, %37 ], [ %119, %117 ]
%63 = getelementptr inbounds i32, i32* %4, i64 %60
%64 = load i32, i32* %63
%65 = add nsw i64 %60, 1
%66 = getelementptr inbounds i32, i32* %5, i64 %60
%67 = load i32, i32* %66
%68 = sub nsw i32 %64, %67
%69 = getelementptr inbounds i32, i32* %4, i64 %65
%70 = load i32, i32* %69
%71 = add nsw i64 %60, 2
%72 = getelementptr inbounds i32, i32* %5, i64 %65
%73 = load i32, i32* %72
%74 = sub nsw i32 %70, %73
%75 = mul nsw i32 %67, %67
%76 = mul nsw i32 %73, %73
%77 = add nuw nsw i32 %76, %75
%78 = sitofp i32 %73 to double
%79 = sitofp i32 %67 to double
%80 = tail call double @atan2(double %78, double %79)
%81 = sitofp i32 %70 to double
%82 = sitofp i32 %64 to double
%83 = tail call double @atan2(double %81, double %82)
%84 = icmp eq i32 %77, 0
br i1 %84, label %92, label %85
85: ; preds = %58
%86 = sitofp i32 %77 to double
%87 = mul nsw i32 %64, %64
%88 = mul nsw i32 %70, %70
%89 = add nuw nsw i32 %88, %87
%90 = sitofp i32 %89 to double
%91 = fdiv double %90, %86
br label %92
92: ; preds = %58, %85
%93 = phi double [ %91, %85 ], [ -1.000000e+00, %58 ]
%94 = getelementptr inbounds double, double* %6, i64 %59
store double %93, double* %94
%95 = fsub double %83, %80
%96 = add nsw i64 %59, 1
%97 = getelementptr inbounds double, double* %7, i64 %59
store double %95, double* %97
%98 = icmp ne i32 %68, 0
%99 = icmp ne i32 %74, 0
%100 = select i1 %98, i1 true, i1 %99
br i1 %100, label %101, label %114
101: ; preds = %92
%102 = load i32, i32* %0
%103 = add nsw i32 %102, 1
store i32 %103, i32* %0
br i1 %13, label %106, label %104
104: ; preds = %101
%105 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %62, i32 %41, i32 %67, i32 %64, i32 %73, i32 %70, i32 %103)
br label %106
106: ; preds = %104, %101
%107 = mul nsw i32 %74, %74
%108 = mul nsw i32 %68, %68
%109 = add nuw nsw i32 %107, %108
%110 = load i32, i32* %1
%111 = add nsw i32 %110, %109
store i32 %111, i32* %1
%112 = icmp sgt i32 %109, %61
%113 = select i1 %112, i32 %109, i32 %61
br label %117
114: ; preds = %92
br i1 %13, label %117, label %115
115: ; preds = %114
%116 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %62, i32 %41, i32 %67, i32 %64, i32 %73, i32 %70)
br label %117
117: ; preds = %106, %114, %115
%118 = phi i32 [ %61, %115 ], [ %61, %114 ], [ %113, %106 ]
%119 = add nuw i32 %62, 1
%120 = icmp eq i32 %119, %3
br i1 %120, label %53, label %58
}