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


x86 assembly (clang, -O0):
<Branch_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <Sum_S@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <Sum_S@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe7b(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
add    $0x20,%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
cvtsi2sd %eax,%xmm0
mulsd  0xe93(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define float @Branch_length(i32 %0, i32 %1, float** %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca float**
%8 = alloca i32
%9 = alloca float
store i32 %0, i32* %5
store i32 %1, i32* %6
store float** %2, float*** %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = load float**, float*** %7
%13 = call i32 @Distance(i32 %10, i32 %11, float** %12)
%14 = load i32, i32* %5
%15 = load float**, float*** %7
%16 = call i32 @Sum_S(i32 %14, float** %15)
%17 = load i32, i32* %6
%18 = load float**, float*** %7
%19 = call i32 @Sum_S(i32 %17, float** %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 = sitofp i32 %24 to double
%26 = fmul double 5.000000e-01, %25
%27 = fptrunc double %26 to float
store float %27, float* %9
%28 = load float, float* %9
ret float %28
}

LLVM IR (-O2):
define float @Branch_length(i32 %0, i32 %1, float** %2, i32 %3) {
%5 = tail call i32 @Distance(i32 %0, i32 %1, float** %2)
%6 = tail call i32 @Sum_S(i32 %0, float** %2)
%7 = tail call i32 @Sum_S(i32 %1, float** %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 = sitofp i32 %11 to double
%13 = fmul double %12, 5.000000e-01
%14 = fptrunc double %13 to float
ret float %14
}