#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 Branch_length(int a, int b, double **delta, int r) {
  double length;
  length =
      (Distance(a, b, delta) + (Sum_S(a, delta) - Sum_S(b, delta)) / (r - 2)) /
      2;
  return (length);
}


x86 assembly (clang, -O0):
<Branch_length>:
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    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1040 <Distance@plt>
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <Sum_S@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <Sum_S@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
sub    %ecx,%eax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define double @Branch_length(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* %5
%11 = load i32, i32* %6
%12 = load double**, double*** %7
%13 = call i32 @Distance(i32 %10, i32 %11, double** %12)
%14 = load i32, i32* %5
%15 = load double**, double*** %7
%16 = call i32 @Sum_S(i32 %14, double** %15)
%17 = load i32, i32* %6
%18 = load double**, double*** %7
%19 = call i32 @Sum_S(i32 %17, double** %18)
%20 = sub nsw i32 %16, %19
%21 = load i32, i32* %8
%22 = sub nsw i32 %21, 2
%23 = sdiv i32 %20, %22
%24 = add nsw i32 %13, %23
%25 = sdiv i32 %24, 2
%26 = sitofp i32 %25 to double
store double %26, double* %9
%27 = load double, double* %9
ret double %27
}

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