// File: /workspace/github_c_makefile_star2_O2/sheneman[P]clearcut/clearcut.c
// Function: NJ_check
static inline
int 
NJ_check(NJ_ARGS *nj_args,
	 DMAT *dmat,
	 long int a,
	 long int b,
	 float min,
	 int additivity) {


  long int i, size;
  float *ptr, *val, *r2;
  

  /* some aliases for speed and readability reasons */
  val  = dmat->val;
  r2   = dmat->r2;
  size = dmat->size;


  /* now determine if joining a, b will result in broken distances */
  if(additivity) {
    if(!NJ_check_additivity(dmat, a, b)) {
      return(0);
    }
  }

  /* scan the horizontal of row b, punt if anything < min */
  ptr = &(val[NJ_MAP(b, b+1, size)]);  
  for(i=b+1;i<size;i++) {
    if( NJ_FLT_LT( (*ptr - (r2[b] + r2[i])), min) ) {
      return(0);
    }
    ptr++;
  }

  /* scan the vertical component of row a, punt if anything < min */
  if(nj_args->norandom) {  /* if we are doing random joins, we checked this */
    ptr = val + a;
    for(i=0;i<a;i++) {
      if( NJ_FLT_LT( (*ptr - (r2[i] + r2[a])), min) ) {
	return(0);
      }
      ptr += size-i-1;
    }
  }

  /* scan the vertical component of row b, punt if anything < min */
  ptr = val + b;
  for(i=0;i<b;i++) {
    if( NJ_FLT_LT( (*ptr - (r2[i] + r2[b])), min) && i!=a) {
      return(0);
    }
    ptr += size-i-1;
  }

  return(1);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r9
movq 0x8(%rsi), %r10
movq 0x18(%rsi), %rbx
movq 0x30(%rsi), %r11
movq %rcx, %r15
notq %r15
movabsq $0x2, %r14
testl %r8d, %r8d
je 0x36fd
leaq -0x1(%r10), %rax
cmpq %rcx, %rax
jne 0x3706
xorl %r8d, %r8d
testq %r9, %r9
jne 0x370a
cmpq $0x1, %rcx
sete %r8b
incq %r8
jmp 0x370a
leaq (%r10,%r10), %rsi
jmp 0x37db
leaq 0x1(%rcx), %r8
leaq (%r10,%r10), %rsi
movq %r9, %rax
notq %rax
leaq (%rax,%r10,2), %rax
imulq %r9, %rax
cqto
idivq %r14
leaq (%rbx,%rax,4), %rax
movss (%rax,%rcx,4), %xmm1
movss (%r11,%r9,4), %xmm3
movss (%r11,%rcx,4), %xmm2
cmpq %rcx, %r8
jle 0x3756
leaq (%rax,%r8,4), %r12
leaq (%rsi,%r15), %rax
imulq %rcx, %rax
cqto
idivq %r14
leaq (%rbx,%rax,4), %rax
leaq (%rax,%r8,4), %rax
jmp 0x3774
movq %r8, %rax
notq %rax
addq %rsi, %rax
imulq %r8, %rax
cqto
idivq %r14
leaq (%rbx,%rax,4), %rax
leaq (%rax,%r9,4), %r12
leaq (%rax,%rcx,4), %rax
movaps %xmm3, %xmm4
unpcklps %xmm2, %xmm4            # xmm4 = xmm4[0],xmm2[0],xmm4[1],xmm2[1]
unpcklps %xmm3, %xmm2            # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
subps %xmm2, %xmm4
movss (%rax), %xmm2
shufps $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
addps %xmm4, %xmm1
mulps 0x389e(%rip), %xmm1     # 0x7030
movss (%r12), %xmm3
unpcklps %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1]
subps %xmm1, %xmm3
movaps %xmm3, %xmm4
shufps $0x55, %xmm3, %xmm4     # xmm4 = xmm4[1,1],xmm3[1,1]
addss %xmm3, %xmm4
mulss 0x385f(%rip), %xmm4     # 0x7010
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
addss %xmm4, %xmm1
subss %xmm1, %xmm2
andps 0x385c(%rip), %xmm2     # 0x7020
movss 0x383c(%rip), %xmm1     # 0x7008
ucomiss %xmm2, %xmm1
ja 0x37db
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x1(%rcx), %r8
addq %r15, %rsi
imulq %rcx, %rsi
movq %rsi, %rax
cqto
idivq %r14
leaq (%rbx,%rax,4), %rax
movaps 0x3827(%rip), %xmm1     # 0x7020
movss 0x3807(%rip), %xmm2     # 0x7008
cmpq %r10, %r8
jge 0x3832
movss (%r11,%rcx,4), %xmm4
addss (%r11,%r8,4), %xmm4
movss (%rax,%r8,4), %xmm3
subss %xmm4, %xmm3
ucomiss %xmm3, %xmm0
jbe 0x382d
subss %xmm0, %xmm3
andps %xmm1, %xmm3
ucomiss %xmm3, %xmm2
jbe 0x37d1
incq %r8
jmp 0x3801
cmpl $0x0, 0x38(%rdi)
je 0x3888
leaq (%rbx,%r9,4), %rax
xorl %edx, %edx
testq %r9, %r9
movl $0x0, %esi
cmovgq %r9, %rsi
leaq -0x1(%r10), %rdi
cmpq %rdx, %rsi
je 0x3888
movss (%r11,%rdx,4), %xmm4
addss (%r11,%r9,4), %xmm4
movss (%rax), %xmm3
subss %xmm4, %xmm3
ucomiss %xmm3, %xmm0
jbe 0x387c
subss %xmm0, %xmm3
andps %xmm1, %xmm3
ucomiss %xmm3, %xmm2
jbe 0x37d1
leaq (%rax,%rdi,4), %rax
incq %rdx
decq %rdi
jmp 0x384e
leaq (%rbx,%rcx,4), %rdx
xorl %esi, %esi
testq %rcx, %rcx
movl $0x0, %edi
cmovgq %rcx, %rdi
decq %r10
movl $0x1, %eax
cmpq %rsi, %rdi
je 0x37d3
cmpq %rsi, %r9
je 0x38d9
movss (%r11,%rsi,4), %xmm4
addss (%r11,%rcx,4), %xmm4
movss (%rdx), %xmm3
subss %xmm4, %xmm3
ucomiss %xmm3, %xmm0
jbe 0x38d9
subss %xmm0, %xmm3
andps %xmm1, %xmm3
ucomiss %xmm3, %xmm2
jbe 0x37d1
leaq (%rdx,%r10,4), %rdx
incq %rsi
decq %r10
jmp 0x38a2