#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 */

/* Variables and functions */
double **alloc_square_array(int);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
double **do3x3smooth(double **, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ setup_arr(double **, int);
int /*<<< orphan*/ stderr;
double sum(double **, int);
int main(void) {
  int nArr = 2300;
  int ri;
  double r, **arr, **arr2, **arr3;
  arr = alloc_square_array(nArr);
  setup_arr(arr, nArr);
  arr2 = do3x3smooth(arr, nArr);
  arr3 = do3x3smooth(arr2, nArr - 2);
  r = sum(arr3, nArr - 4);
  if (0)
    fprintf(stderr, "r = %g\n", r);
  r /= 10000.0;
  ri = (int)r;
  if (0)
    fprintf(stderr, "ri = %d\n", ri);
  if (ri == 696565111) {
    fprintf(stderr, "Test succeeded.\n");
  } else {
    fprintf(stderr, "Test FAILED !\n");
    assert(0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x8fc,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <alloc_square_array@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <setup_arr@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <do3x3smooth@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    $0x2,%esi
call   1040 <do3x3smooth@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    $0x4,%esi
call   1080 <sum@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe2e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x2984bd77,-0xc(%rbp)
jne    120c <main+0xac>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
lea    0xe08(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    122a <main+0xca>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
lea    0xdfd(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
xor    %edi,%edi
call   1060 <assert@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x8fc,%edi
call   1030 <alloc_square_array@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x8fc,%esi
call   1050 <setup_arr@plt>
mov    %rbx,%rdi
mov    $0x8fc,%esi
call   1040 <do3x3smooth@plt>
mov    %rax,%rdi
mov    $0x8fa,%esi
call   1040 <do3x3smooth@plt>
mov    %rax,%rdi
mov    $0x8f8,%esi
call   1080 <sum@plt>
divsd  0xe56(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    0x2e2b(%rip),%rcx
mov    (%rcx),%edi
cmp    $0x2984bd77,%eax
jne    11ce <main+0x6e>
lea    0xe43(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    11e3 <main+0x83>
lea    0xe44(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %edi,%edi
call   1060 <assert@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [17 x i8] c"Test succeeded.\0A\00"
@.str.1 = [15 x i8] c"Test FAILED !\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double**
%6 = alloca double**
%7 = alloca double**
store i32 0, i32* %1
store i32 2300, i32* %2
%8 = load i32, i32* %2
%9 = call double** @alloc_square_array(i32 %8)
store double** %9, double*** %5
%10 = load double**, double*** %5
%11 = load i32, i32* %2
%12 = call i32 @setup_arr(double** %10, i32 %11)
%13 = load double**, double*** %5
%14 = load i32, i32* %2
%15 = call double** @do3x3smooth(double** %13, i32 %14)
store double** %15, double*** %6
%16 = load double**, double*** %6
%17 = load i32, i32* %2
%18 = sub nsw i32 %17, 2
%19 = call double** @do3x3smooth(double** %16, i32 %18)
store double** %19, double*** %7
%20 = load double**, double*** %7
%21 = load i32, i32* %2
%22 = sub nsw i32 %21, 4
%23 = call double @sum(double** %20, i32 %22)
store double %23, double* %4
%24 = load double, double* %4
%25 = fdiv double %24, 1.000000e+04
store double %25, double* %4
%26 = load double, double* %4
%27 = fptosi double %26 to i32
store i32 %27, i32* %3
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, 696565111
br i1 %29, label %30, label %33
30: ; preds = %0
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %37
33: ; preds = %0
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 @assert(i32 0)
br label %37
37: ; preds = %33, %30
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [17 x i8] c"Test succeeded.\0A\00"
@.str.1 = [15 x i8] c"Test FAILED !\0A\00"
define i32 @main() {
%1 = tail call double** @alloc_square_array(i32 2300)
%2 = tail call i32 @setup_arr(double** %1, i32 2300)
%3 = tail call double** @do3x3smooth(double** %1, i32 2300)
%4 = tail call double** @do3x3smooth(double** %3, i32 2298)
%5 = tail call double @sum(double** %4, i32 2296)
%6 = fdiv double %5, 1.000000e+04
%7 = fptosi double %6 to i32
%8 = icmp eq i32 %7, 696565111
%9 = load i32, i32* @stderr
br i1 %8, label %10, label %12
10: ; preds = %0
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %15
12: ; preds = %0
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @assert(i32 0)
br label %15
15: ; preds = %12, %10
ret i32 0
}