// File: /workspace/github_c_makefile_star2_O0/zpole[P]IICV/vl/mathop_sse2.c
// Function: vl_distance_chi2_sse2_d
VL_EXPORT T
VL_XCAT(_vl_distance_chi2_sse2_, SFX)
(vl_size dimension, T const * X, T const * Y)
{
  T const * X_end = X + dimension ;
  T const * X_vec_end = X + dimension - VSIZE ;
  T acc ;
  VTYPE vacc = VSTZ() ;
  vl_bool dataAligned = VALIGNED(X) & VALIGNED(Y) ;

  if (dataAligned) {
    while (X < X_vec_end) {
      VTYPE a = *(VTYPE*)X ;
      VTYPE b = *(VTYPE*)Y ;
      VTYPE delta = VSUB(a, b) ;
      VTYPE denom = VADD(a, b) ;
      VTYPE numer = VMUL(delta, delta) ;
      VTYPE ratio = VDIV(numer, denom) ;
      ratio = VAND(ratio, VNEQ(denom, VSTZ())) ;
      vacc = VADD(vacc, ratio) ;
      X += VSIZE ;
      Y += VSIZE ;
    }
  } else {
    while (X < X_vec_end) {
      VTYPE a = VLDU(X) ;
      VTYPE b = VLDU(Y) ;
      VTYPE delta = VSUB(a, b) ;
      VTYPE denom = VADD(a, b) ;
      VTYPE numer = VMUL(delta, delta) ;
      VTYPE ratio = VDIV(numer, denom) ;
      ratio = VAND(ratio, VNEQ(denom, VSTZ())) ;
      vacc = VADD(vacc, ratio) ;
      X += VSIZE ;
      Y += VSIZE ;
    }
  }

  acc = VL_XCAT(_vl_vhsum_sse2_, SFX)(vacc) ;

  while (X < X_end) {
    T a = *X++ ;
    T b = *Y++ ;
    T delta = a - b ;
    T denom = a + b ;
    T numer = delta * delta ;
    if (denom) {
      T ratio = numer / denom ;
      acc += ratio ;
    }
  }
  return acc ;
}

// Assembly:
subq $0x348, %rsp            # imm = 0x348
movq %rdi, 0x138(%rsp)
movq %rsi, 0x130(%rsp)
movq %rdx, 0x128(%rsp)
movq 0x130(%rsp), %rax
movq 0x138(%rsp), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, 0x120(%rsp)
movq 0x130(%rsp), %rax
movq 0x138(%rsp), %rcx
leaq -0x10(%rax,%rcx,8), %rax
movq %rax, 0x118(%rsp)
xorps %xmm0, %xmm0
movapd %xmm0, 0x160(%rsp)
movapd 0x160(%rsp), %xmm0
movapd %xmm0, 0x100(%rsp)
movq 0x130(%rsp), %rax
andq $0xf, %rax
cmpq $0x0, %rax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movq 0x128(%rsp), %rcx
andq $0xf, %rcx
cmpq $0x0, %rcx
setne %cl
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %ecx
andl %ecx, %eax
movl %eax, 0xfc(%rsp)
cmpl $0x0, 0xfc(%rsp)
je 0x4032a
jmp 0x400f5
movq 0x130(%rsp), %rax
cmpq 0x118(%rsp), %rax
jae 0x40325
movq 0x130(%rsp), %rax
movapd (%rax), %xmm0
movapd %xmm0, 0xe0(%rsp)
movq 0x128(%rsp), %rax
movapd (%rax), %xmm0
movapd %xmm0, 0xd0(%rsp)
movapd 0xe0(%rsp), %xmm1
movapd 0xd0(%rsp), %xmm0
movapd %xmm1, 0x270(%rsp)
movapd %xmm0, 0x260(%rsp)
movapd 0x270(%rsp), %xmm0
movapd 0x260(%rsp), %xmm1
subpd %xmm1, %xmm0
movapd %xmm0, 0xc0(%rsp)
movapd 0xe0(%rsp), %xmm1
movapd 0xd0(%rsp), %xmm0
movapd %xmm1, 0x220(%rsp)
movapd %xmm0, 0x210(%rsp)
movapd 0x220(%rsp), %xmm0
movapd 0x210(%rsp), %xmm1
addpd %xmm1, %xmm0
movapd %xmm0, 0xb0(%rsp)
movapd 0xc0(%rsp), %xmm0
movapd %xmm0, 0x1a0(%rsp)
movapd %xmm0, 0x190(%rsp)
movapd 0x1a0(%rsp), %xmm0
movapd 0x190(%rsp), %xmm1
mulpd %xmm1, %xmm0
movapd %xmm0, 0xa0(%rsp)
movapd 0xa0(%rsp), %xmm1
movapd 0xb0(%rsp), %xmm0
movapd %xmm1, 0x2b0(%rsp)
movapd %xmm0, 0x2a0(%rsp)
movapd 0x2b0(%rsp), %xmm0
movapd 0x2a0(%rsp), %xmm1
divpd %xmm1, %xmm0
movapd %xmm0, 0x90(%rsp)
movapd 0x90(%rsp), %xmm1
movapd 0xb0(%rsp), %xmm2
xorps %xmm0, %xmm0
movapd %xmm0, 0x150(%rsp)
movapd 0x150(%rsp), %xmm0
movapd %xmm2, 0x330(%rsp)
movapd %xmm0, 0x320(%rsp)
movapd 0x330(%rsp), %xmm0
movapd 0x320(%rsp), %xmm2
cmpneqpd %xmm2, %xmm0
movapd %xmm1, 0x2f0(%rsp)
movapd %xmm0, 0x2e0(%rsp)
movapd 0x2f0(%rsp), %xmm0
movapd 0x2e0(%rsp), %xmm1
pand %xmm1, %xmm0
movapd %xmm0, 0x90(%rsp)
movapd 0x100(%rsp), %xmm1
movapd 0x90(%rsp), %xmm0
movapd %xmm1, 0x200(%rsp)
movapd %xmm0, 0x1f0(%rsp)
movapd 0x200(%rsp), %xmm0
addpd 0x1f0(%rsp), %xmm0
movapd %xmm0, 0x100(%rsp)
movq 0x130(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x130(%rsp)
movq 0x128(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x128(%rsp)
jmp 0x400f5
jmp 0x40554
jmp 0x4032c
movq 0x130(%rsp), %rax
cmpq 0x118(%rsp), %rax
jae 0x40552
movq 0x130(%rsp), %rax
movq %rax, 0x238(%rsp)
movq 0x238(%rsp), %rax
movupd (%rax), %xmm0
movapd %xmm0, 0x80(%rsp)
movq 0x128(%rsp), %rax
movq %rax, 0x230(%rsp)
movq 0x230(%rsp), %rax
movupd (%rax), %xmm0
movapd %xmm0, 0x70(%rsp)
movapd 0x80(%rsp), %xmm1
movapd 0x70(%rsp), %xmm0
movapd %xmm1, 0x250(%rsp)
movapd %xmm0, 0x240(%rsp)
movapd 0x250(%rsp), %xmm0
movapd 0x240(%rsp), %xmm1
subpd %xmm1, %xmm0
movapd %xmm0, 0x60(%rsp)
movapd 0x80(%rsp), %xmm1
movapd 0x70(%rsp), %xmm0
movapd %xmm1, 0x1e0(%rsp)
movapd %xmm0, 0x1d0(%rsp)
movapd 0x1e0(%rsp), %xmm0
movapd 0x1d0(%rsp), %xmm1
addpd %xmm1, %xmm0
movapd %xmm0, 0x50(%rsp)
movapd 0x60(%rsp), %xmm0
movapd %xmm0, 0x180(%rsp)
movapd %xmm0, 0x170(%rsp)
movapd 0x180(%rsp), %xmm0
movapd 0x170(%rsp), %xmm1
mulpd %xmm1, %xmm0
movapd %xmm0, 0x40(%rsp)
movapd 0x40(%rsp), %xmm1
movapd 0x50(%rsp), %xmm0
movapd %xmm1, 0x290(%rsp)
movapd %xmm0, 0x280(%rsp)
movapd 0x290(%rsp), %xmm0
movapd 0x280(%rsp), %xmm1
divpd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
movapd 0x30(%rsp), %xmm1
movapd 0x50(%rsp), %xmm2
xorps %xmm0, %xmm0
movapd %xmm0, 0x140(%rsp)
movapd 0x140(%rsp), %xmm0
movapd %xmm2, 0x310(%rsp)
movapd %xmm0, 0x300(%rsp)
movapd 0x310(%rsp), %xmm0
movapd 0x300(%rsp), %xmm2
cmpneqpd %xmm2, %xmm0
movapd %xmm1, 0x2d0(%rsp)
movapd %xmm0, 0x2c0(%rsp)
movapd 0x2d0(%rsp), %xmm0
movapd 0x2c0(%rsp), %xmm1
pand %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
movapd 0x100(%rsp), %xmm1
movapd 0x30(%rsp), %xmm0
movapd %xmm1, 0x1c0(%rsp)
movapd %xmm0, 0x1b0(%rsp)
movapd 0x1c0(%rsp), %xmm0
addpd 0x1b0(%rsp), %xmm0
movapd %xmm0, 0x100(%rsp)
movq 0x130(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x130(%rsp)
movq 0x128(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x128(%rsp)
jmp 0x4032c
jmp 0x40554
movapd 0x100(%rsp), %xmm0
callq 0x3f280
movsd %xmm0, 0x110(%rsp)
movq 0x130(%rsp), %rax
cmpq 0x120(%rsp), %rax
jae 0x40639
movq 0x130(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x130(%rsp)
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x128(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x128(%rsp)
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x28(%rsp), %xmm0
subsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x28(%rsp), %xmm0
addsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x4060c
jp 0x4060c
jmp 0x40634
movsd 0x8(%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm0
addsd 0x110(%rsp), %xmm0
movsd %xmm0, 0x110(%rsp)
jmp 0x4056b
movsd 0x110(%rsp), %xmm0
addq $0x348, %rsp            # imm = 0x348
retq
nopw (%rax,%rax)