#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 */
int Distance(int, int, double **);
int Sum_S(int, double **);
double Agglomerative_criterion(int i, int j, double **delta, int r) {
  double Qij;
  Qij = (r - 2) * Distance(i, j, delta) - Sum_S(i, delta) - Sum_S(j, delta);
  return (Qij);
}


x86 assembly (clang, -O0):
<Agglomerative_criterion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1040 <Distance@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <Sum_S@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <Sum_S@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Agglomerative_criterion>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%ebx
mov    %rdx,%r14
mov    %esi,%r15d
mov    %edi,%r12d
add    $0xfffffffe,%ebx
call   1040 <Distance@plt>
mov    %eax,%ebp
imul   %ebx,%ebp
mov    %r12d,%edi
mov    %r14,%rsi
call   1030 <Sum_S@plt>
mov    %eax,%ebx
mov    %r15d,%edi
mov    %r14,%rsi
call   1030 <Sum_S@plt>
add    %ebx,%eax
sub    %eax,%ebp
cvtsi2sd %ebp,%xmm0
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @Agglomerative_criterion(i32 %0, i32 %1, double** %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double**
%8 = alloca i32
%9 = alloca double
store i32 %0, i32* %5
store i32 %1, i32* %6
store double** %2, double*** %7
store i32 %3, i32* %8
%10 = load i32, i32* %8
%11 = sub nsw i32 %10, 2
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = load double**, double*** %7
%15 = call i32 @Distance(i32 %12, i32 %13, double** %14)
%16 = mul nsw i32 %11, %15
%17 = load i32, i32* %5
%18 = load double**, double*** %7
%19 = call i32 @Sum_S(i32 %17, double** %18)
%20 = sub nsw i32 %16, %19
%21 = load i32, i32* %6
%22 = load double**, double*** %7
%23 = call i32 @Sum_S(i32 %21, double** %22)
%24 = sub nsw i32 %20, %23
%25 = sitofp i32 %24 to double
store double %25, double* %9
%26 = load double, double* %9
ret double %26
}

LLVM IR (-O2):
define double @Agglomerative_criterion(i32 %0, i32 %1, double** %2, i32 %3) {
%5 = add nsw i32 %3, -2
%6 = tail call i32 @Distance(i32 %0, i32 %1, double** %2)
%7 = mul nsw i32 %6, %5
%8 = tail call i32 @Sum_S(i32 %0, double** %2)
%9 = tail call i32 @Sum_S(i32 %1, double** %2)
%10 = add i32 %8, %9
%11 = sub i32 %7, %10
%12 = sitofp i32 %11 to double
ret double %12
}