#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(int *num_err, int64_t *err_2,
                                         int num_frequencies, int 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 < num_frequencies; freq++) {
    for (int element_y = 0; element_y < num_elements; element_y++) {
      for (int element_x = 0; element_x < 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>:
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    13f3 <compare_NSquared_correlator_results+0x2c3>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    13e0 <compare_NSquared_correlator_results+0x2b0>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    13cd <compare_NSquared_correlator_results+0x29d>
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    1293 <compare_NSquared_correlator_results+0x163>
jp     1293 <compare_NSquared_correlator_results+0x163>
jmp    12af <compare_NSquared_correlator_results+0x17f>
movsd  -0x48(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
mov    0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    12c4 <compare_NSquared_correlator_results+0x194>
mov    0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  0xd49(%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    12f9 <compare_NSquared_correlator_results+0x1c9>
cmpl   $0x0,-0x7c(%rbp)
je     137d <compare_NSquared_correlator_results+0x24d>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
cmpl   $0x0,0x20(%rbp)
je     1348 <compare_NSquared_correlator_results+0x218>
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    0xcdc(%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    1378 <compare_NSquared_correlator_results+0x248>
mov    -0x38(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    13ba <compare_NSquared_correlator_results+0x28a>
cmpl   $0x0,0x20(%rbp)
je     13b5 <compare_NSquared_correlator_results+0x285>
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    0xccb(%rip),%rdi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13ba <compare_NSquared_correlator_results+0x28a>
jmp    13bf <compare_NSquared_correlator_results+0x28f>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11b2 <compare_NSquared_correlator_results+0x82>
jmp    13d2 <compare_NSquared_correlator_results+0x2a2>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    119f <compare_NSquared_correlator_results+0x6f>
jmp    13e5 <compare_NSquared_correlator_results+0x2b5>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    118c <compare_NSquared_correlator_results+0x5c>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
movslq (%rax),%rdx
lea    0xcc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
movsd  0xbe2(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
cvttsd2si %xmm0,%esi
lea    0xcca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xcef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_NSquared_correlator_results>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%r14
mov    0xe0(%rsp),%eax
mov    %eax,0x14(%rsp)
mov    0xd8(%rsp),%rax
mov    %rax,0x60(%rsp)
mov    0xd0(%rsp),%rax
mov    %rax,0x58(%rsp)
mov    %rdi,0x28(%rsp)
movl   $0x0,(%rdi)
movl   $0x0,(%rsi)
mov    %edx,0x20(%rsp)
test   %edx,%edx
jle    1410 <compare_NSquared_correlator_results+0x2e0>
mov    %ecx,%eax
mov    %rax,0x38(%rsp)
add    $0x4,%r8
mov    %r8,0x48(%rsp)
add    $0x4,%r9
mov    %r9,0x50(%rsp)
xor    %esi,%esi
xor    %ebx,%ebx
xor    %ebp,%ebp
movl   $0x0,0x4(%rsp)
mov    %r14,0x30(%rsp)
mov    %ecx,0x1c(%rsp)
jmp    11e7 <compare_NSquared_correlator_results+0xb7>
nopl   0x0(%rax,%rax,1)
add    %r15d,%ecx
mov    %ecx,%ebx
mov    0x30(%rsp),%r14
mov    0xc(%rsp),%ebp
mov    0x1c(%rsp),%ecx
mov    0x4(%rsp),%eax
add    $0x1,%eax
mov    %eax,0x4(%rsp)
cmp    0x20(%rsp),%eax
je     140b <compare_NSquared_correlator_results+0x2db>
test   %ecx,%ecx
jle    11d2 <compare_NSquared_correlator_results+0xa2>
mov    %ebp,0xc(%rsp)
movl   $0x0,0x8(%rsp)
jmp    121a <compare_NSquared_correlator_results+0xea>
nopl   0x0(%rax)
mov    0x68(%rsp),%rcx
lea    (%rcx,%r15,1),%ebx
mov    0x8(%rsp),%eax
add    $0x1,%eax
mov    %eax,0x8(%rsp)
cmp    0x38(%rsp),%eax
je     11c0 <compare_NSquared_correlator_results+0x90>
mov    %ebx,%ecx
movslq %esi,%rax
mov    %rcx,0x68(%rsp)
movslq %ecx,%rcx
mov    0x58(%rsp),%rdx
lea    (%rdx,%rcx,8),%rdx
mov    %rdx,0x88(%rsp)
mov    0x60(%rsp),%rdx
lea    (%rdx,%rcx,8),%rcx
mov    %rcx,0x80(%rsp)
mov    0x48(%rsp),%rcx
lea    (%rcx,%rax,4),%rcx
mov    %rcx,0x78(%rsp)
mov    0x50(%rsp),%rcx
lea    (%rcx,%rax,4),%rax
mov    %rax,0x70(%rsp)
xor    %r15d,%r15d
jmp    12a2 <compare_NSquared_correlator_results+0x172>
nopw   0x0(%rax,%rax,1)
imul   %ebx,%ebx
imul   %ebp,%ebp
add    %ebx,%ebp
mov    0x30(%rsp),%rax
add    %ebp,(%rax)
mov    0xc(%rsp),%eax
cmp    %eax,%ebp
cmovg  %ebp,%eax
mov    %eax,0xc(%rsp)
mov    0x10(%rsp),%esi
add    $0x1,%r15
add    $0x2,%esi
cmp    %r15d,0x38(%rsp)
je     1200 <compare_NSquared_correlator_results+0xd0>
mov    %esi,0x10(%rsp)
mov    0x78(%rsp),%rax
mov    -0x4(%rax,%r15,8),%r14d
mov    (%rax,%r15,8),%r12d
mov    0x70(%rsp),%rax
mov    -0x4(%rax,%r15,8),%edx
mov    (%rax,%r15,8),%eax
mov    %r14d,%ebp
sub    %edx,%ebp
mov    %r12d,%ecx
sub    %eax,%ecx
mov    %ecx,0x24(%rsp)
mov    %edx,%ebx
imul   %edx,%ebx
mov    %eax,%r13d
imul   %eax,%r13d
mov    %rax,0x40(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %edx,0x18(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,0x90(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r14d,%xmm1
call   1030 <atan2@plt>
movsd  0xce2(%rip),%xmm1
add    %ebx,%r13d
je     1346 <compare_NSquared_correlator_results+0x216>
xorps  %xmm2,%xmm2
cvtsi2sd %r13d,%xmm2
mov    %r14d,%eax
imul   %r14d,%eax
mov    %r12d,%ecx
imul   %r12d,%ecx
add    %eax,%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
divsd  %xmm2,%xmm1
mov    0x88(%rsp),%rax
movsd  %xmm1,(%rax,%r15,8)
subsd  0x90(%rsp),%xmm0
mov    0x80(%rsp),%rax
movsd  %xmm0,(%rax,%r15,8)
mov    %ebp,%eax
mov    0x24(%rsp),%ebx
or     %ebx,%eax
je     13d0 <compare_NSquared_correlator_results+0x2a0>
mov    0x28(%rsp),%rax
mov    (%rax),%r11d
add    $0x1,%r11d
mov    %r11d,(%rax)
cmpl   $0x0,0x14(%rsp)
je     1270 <compare_NSquared_correlator_results+0x140>
sub    $0x8,%rsp
lea    0xc6e(%rip),%rdi
mov    0xc(%rsp),%esi
mov    %r15d,%edx
mov    0x10(%rsp),%ecx
mov    0x20(%rsp),%r8d
mov    %r14d,%r9d
xor    %eax,%eax
push   %r11
push   %r12
push   0x58(%rsp)
call   1040 <printf@plt>
add    $0x20,%rsp
jmp    1270 <compare_NSquared_correlator_results+0x140>
cs nopw 0x0(%rax,%rax,1)
nop
cmpl   $0x0,0x14(%rsp)
je     128c <compare_NSquared_correlator_results+0x15c>
lea    0xc87(%rip),%rdi
mov    0x4(%rsp),%esi
mov    %r15d,%edx
mov    0x8(%rsp),%ecx
mov    0x18(%rsp),%r8d
mov    %r14d,%r9d
xor    %eax,%eax
push   %r12
push   0x48(%rsp)
call   1040 <printf@plt>
add    $0x10,%rsp
jmp    128c <compare_NSquared_correlator_results+0x15c>
movslq (%r14),%rdx
jmp    1416 <compare_NSquared_correlator_results+0x2e6>
xor    %edx,%edx
xor    %ebp,%ebp
xor    %ebx,%ebx
mov    0x28(%rsp),%rax
mov    (%rax),%esi
lea    0xc9d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl (%r14),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
cvttsd2si %xmm0,%esi
lea    0xcaf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcd7(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
add    $0x98,%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(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 = %193, %9
%39 = load i32, i32* %27
%40 = load i32, i32* %12
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %196
42: ; preds = %38
store i32 0, i32* %28
br label %43
43: ; preds = %189, %42
%44 = load i32, i32* %28
%45 = load i32, i32* %13
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %192
47: ; preds = %43
store i32 0, i32* %29
br label %48
48: ; preds = %185, %47
%49 = load i32, i32* %29
%50 = load i32, i32* %13
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %188
52: ; preds = %48
%53 = load i32*, i32** %14
%54 = load i32, i32* %19
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %53, i64 %55
%57 = load i32, i32* %56
store i32 %57, i32* %30
%58 = load i32*, i32** %15
%59 = load i32, i32* %19
%60 = add nsw i32 %59, 1
store i32 %60, i32* %19
%61 = sext i32 %59 to i64
%62 = getelementptr inbounds i32, i32* %58, i64 %61
%63 = load i32, i32* %62
store i32 %63, i32* %31
%64 = load i32, i32* %30
%65 = load i32, i32* %31
%66 = sub nsw i32 %64, %65
store i32 %66, i32* %32
%67 = load i32*, i32** %14
%68 = load i32, i32* %19
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %67, i64 %69
%71 = load i32, i32* %70
store i32 %71, i32* %33
%72 = load i32*, i32** %15
%73 = load i32, i32* %19
%74 = add nsw i32 %73, 1
store i32 %74, i32* %19
%75 = sext i32 %73 to i64
%76 = getelementptr inbounds i32, i32* %72, i64 %75
%77 = load i32, i32* %76
store i32 %77, i32* %34
%78 = load i32, i32* %33
%79 = load i32, i32* %34
%80 = sub nsw i32 %78, %79
store i32 %80, i32* %35
%81 = load i32, i32* %31
%82 = load i32, i32* %31
%83 = mul nsw i32 %81, %82
%84 = load i32, i32* %34
%85 = load i32, i32* %34
%86 = mul nsw i32 %84, %85
%87 = add nsw i32 %83, %86
%88 = sitofp i32 %87 to double
store double %88, double* %23
%89 = load i32, i32* %30
%90 = load i32, i32* %30
%91 = mul nsw i32 %89, %90
%92 = load i32, i32* %33
%93 = load i32, i32* %33
%94 = mul nsw i32 %92, %93
%95 = add nsw i32 %91, %94
%96 = sitofp i32 %95 to double
store double %96, double* %24
%97 = load i32, i32* %34
%98 = sitofp i32 %97 to double
%99 = load i32, i32* %31
%100 = sitofp i32 %99 to double
%101 = call double @atan2(double %98, double %100)
store double %101, double* %25
%102 = load i32, i32* %33
%103 = sitofp i32 %102 to double
%104 = load i32, i32* %30
%105 = sitofp i32 %104 to double
%106 = call double @atan2(double %103, double %105)
store double %106, double* %26
%107 = load double, double* %23
%108 = fcmp une double %107, 0.000000e+00
br i1 %108, label %109, label %117
109: ; preds = %52
%110 = load double, double* %24
%111 = load double, double* %23
%112 = fdiv double %110, %111
%113 = load double*, double** %16
%114 = load i32, i32* %20
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds double, double* %113, i64 %115
store double %112, double* %116
br label %122
117: ; preds = %52
%118 = load double*, double** %16
%119 = load i32, i32* %20
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds double, double* %118, i64 %120
store double -1.000000e+00, double* %121
br label %122
122: ; preds = %117, %109
%123 = load double, double* %26
%124 = load double, double* %25
%125 = fsub double %123, %124
%126 = load double*, double** %17
%127 = load i32, i32* %20
%128 = add nsw i32 %127, 1
store i32 %128, i32* %20
%129 = sext i32 %127 to i64
%130 = getelementptr inbounds double, double* %126, i64 %129
store double %125, double* %130
%131 = load i32, i32* %32
%132 = icmp ne i32 %131, 0
br i1 %132, label %136, label %133
133: ; preds = %122
%134 = load i32, i32* %35
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %171
136: ; preds = %133, %122
%137 = load i32*, i32** %10
%138 = load i32, i32* %137
%139 = add nsw i32 %138, 1
store i32 %139, i32* %137
%140 = load i32, i32* %18
%141 = icmp ne i32 %140, 0
br i1 %141, label %142, label %153
142: ; preds = %136
%143 = load i32, i32* %27
%144 = load i32, i32* %29
%145 = load i32, i32* %28
%146 = load i32, i32* %31
%147 = load i32, i32* %30
%148 = load i32, i32* %34
%149 = load i32, i32* %33
%150 = load i32*, i32** %10
%151 = load i32, i32* %150
%152 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0), i32 %143, i32 %144, i32 %145, i32 %146, i32 %147, i32 %148, i32 %149, i32 %151)
br label %153
153: ; preds = %142, %136
%154 = load i32, i32* %35
%155 = load i32, i32* %35
%156 = mul nsw i32 %154, %155
%157 = load i32, i32* %32
%158 = load i32, i32* %32
%159 = mul nsw i32 %157, %158
%160 = add nsw i32 %156, %159
store i32 %160, i32* %22
%161 = load i32, i32* %22
%162 = load i32*, i32** %11
%163 = load i32, i32* %162
%164 = add nsw i32 %163, %161
store i32 %164, i32* %162
%165 = load i32, i32* %22
%166 = load i32, i32* %21
%167 = icmp sgt i32 %165, %166
br i1 %167, label %168, label %170
168: ; preds = %153
%169 = load i32, i32* %22
store i32 %169, i32* %21
br label %170
170: ; preds = %168, %153
br label %184
171: ; preds = %133
%172 = load i32, i32* %18
%173 = icmp ne i32 %172, 0
br i1 %173, label %174, label %183
174: ; preds = %171
%175 = load i32, i32* %27
%176 = load i32, i32* %29
%177 = load i32, i32* %28
%178 = load i32, i32* %31
%179 = load i32, i32* %30
%180 = load i32, i32* %34
%181 = load i32, i32* %33
%182 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.1, i64 0, i64 0), i32 %175, i32 %176, i32 %177, i32 %178, i32 %179, i32 %180, i32 %181)
br label %183
183: ; preds = %174, %171
br label %184
184: ; preds = %183, %170
br label %185
185: ; preds = %184
%186 = load i32, i32* %29
%187 = add nsw i32 %186, 1
store i32 %187, i32* %29
br label %48
188: ; preds = %48
br label %189
189: ; preds = %188
%190 = load i32, i32* %28
%191 = add nsw i32 %190, 1
store i32 %191, i32* %28
br label %43
192: ; preds = %43
br label %193
193: ; preds = %192
%194 = load i32, i32* %27
%195 = add nsw i32 %194, 1
store i32 %195, i32* %27
br label %38
196: ; preds = %38
%197 = load i32*, i32** %10
%198 = load i32, i32* %197
%199 = load i32*, i32** %11
%200 = load i32, i32* %199
%201 = sext i32 %200 to i64
%202 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i32 %198, i64 %201)
%203 = load i32*, i32** %11
%204 = load i32, i32* %203
%205 = sitofp i32 %204 to double
%206 = fmul double %205, 1.000000e+00
%207 = load i32, i32* %20
%208 = sitofp i32 %207 to double
%209 = fdiv double %206, %208
%210 = fptosi double %209 to i32
%211 = call double @sqrt(i32 %210)
%212 = fptosi double %211 to i32
%213 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 %212)
%214 = load i32, i32* %21
%215 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %214)
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(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 [ 0, %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 nsw i32 %62, 1
%120 = icmp eq i32 %119, %3
br i1 %120, label %53, label %58
}