// File: /workspace/github_c_makefile_star2_O0/sheneman[P]clearcut/clearcut.c
// Function: NJ_check_additivity
static inline
int
NJ_check_additivity(DMAT *dmat,
		    long int a,
		    long int b) {

  float a2clade, b2clade;
  float clade_dist;
  long int target;


  /* determine target taxon here */
  if(b == dmat->size-1) {
    /* if we can't do a row here, lets do a column */
    if(a==0) {
      if(b==1) {
	target = 2;
      } else {
	target = 1;
      }
    } else {
      target = 0;
    }
  } else {
    target = b+1;
  }


  /* distance between a and the root of clade (a,b) */
  a2clade = 
    ( (dmat->val[NJ_MAP(a, b, dmat->size)]) + 
      (dmat->r2[a] - dmat->r2[b]) ) / 2.0;  
  
  /* distance between b and the root of clade (a,b) */
  b2clade = 
    ( (dmat->val[NJ_MAP(a, b, dmat->size)]) + 
      (dmat->r2[b] - dmat->r2[a]) ) / 2.0;  

  /* distance between the clade (a,b) and the target taxon */
  if(b<target) {

    /* compute the distance from the clade root to the target */
    clade_dist = 
      ( (dmat->val[NJ_MAP(a, target, dmat->size)] - a2clade) +
	(dmat->val[NJ_MAP(b, target, dmat->size)] - b2clade) ) / 2.0;
    
    /* 
     * Check to see that distance from clade root to target + distance from 
     *  b to clade root are equal to the distance from b to the target 
     */
    if(NJ_FLT_EQ(dmat->val[NJ_MAP(b, target, dmat->size)], 
		 (clade_dist + b2clade))) {
      return(1);  /* join is legitimate   */
    } else {
      return(0);  /* join is illigitimate */
    }
    
  } else {

    /* compute the distance from the clade root to the target */
    clade_dist = 
      ( (dmat->val[NJ_MAP(target, a, dmat->size)] - a2clade) +
	(dmat->val[NJ_MAP(target, b, dmat->size)] - b2clade) ) / 2.0;

    /* 
     * Check to see that distance from clade root to target + distance from 
     *  b to clade root are equal to the distance from b to the target 
     */
    if(NJ_FLT_EQ(dmat->val[NJ_MAP(target, b, dmat->size)], 
		 (clade_dist + b2clade))) {
      return(1);  /* join is legitimate   */
    } else {
      return(0);  /* join is illegitimate */
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x5008
cmpq $0x0, -0x18(%rbp)
jne 0x4ffe
cmpq $0x1, -0x20(%rbp)
jne 0x4ff4
movq $0x2, -0x38(%rbp)
jmp 0x4ffc
movq $0x1, -0x38(%rbp)
jmp 0x5006
movq $0x0, -0x38(%rbp)
jmp 0x5014
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x4b70
movq %rax, %rcx
movq -0x48(%rbp), %rax
movss (%rax,%rcx,4), %xmm0
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x18(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x20(%rbp), %rcx
subss (%rax,%rcx,4), %xmm1
addss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x5f9d(%rip), %xmm1     # 0xb010
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x4b70
movq %rax, %rcx
movq -0x40(%rbp), %rax
movss (%rax,%rcx,4), %xmm0
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x20(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x18(%rbp), %rcx
subss (%rax,%rcx,4), %xmm1
addss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x5f31(%rip), %xmm1     # 0xb010
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x28(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x38(%rbp), %rax
jge 0x51de
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x4b70
movq %rax, %rcx
movq -0x68(%rbp), %rax
movss (%rax,%rcx,4), %xmm0
subss -0x24(%rbp), %xmm0
movss %xmm0, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x4b70
movss -0x5c(%rbp), %xmm0
movq %rax, %rcx
movq -0x58(%rbp), %rax
movss (%rax,%rcx,4), %xmm1
subss -0x28(%rbp), %xmm1
addss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x5e98(%rip), %xmm1     # 0xb010
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x4b70
movq %rax, %rcx
movq -0x50(%rbp), %rax
movss (%rax,%rcx,4), %xmm0
movss -0x2c(%rbp), %xmm1
addss -0x28(%rbp), %xmm1
callq 0x4600
cmpl $0x0, %eax
je 0x51d2
movl $0x1, -0x4(%rbp)
jmp 0x52c0
movl $0x0, -0x4(%rbp)
jmp 0x52c0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x4b70
movq %rax, %rcx
movq -0x88(%rbp), %rax
movss (%rax,%rcx,4), %xmm0
subss -0x24(%rbp), %xmm0
movss %xmm0, -0x7c(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x4b70
movss -0x7c(%rbp), %xmm0
movq %rax, %rcx
movq -0x78(%rbp), %rax
movss (%rax,%rcx,4), %xmm1
subss -0x28(%rbp), %xmm1
addss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x5dae(%rip), %xmm1     # 0xb010
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x4b70
movq %rax, %rcx
movq -0x70(%rbp), %rax
movss (%rax,%rcx,4), %xmm0
movss -0x2c(%rbp), %xmm1
addss -0x28(%rbp), %xmm1
callq 0x4600
cmpl $0x0, %eax
je 0x52b9
movl $0x1, -0x4(%rbp)
jmp 0x52c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)