// File: /workspace/github_c_makefile_star2_O0/zpole[P]IICV/vl/mathop_sse2.c
// Function: vl_weighted_mean_sse2_d
VL_EXPORT void
VL_XCAT(_vl_weighted_mean_sse2_, SFX)
(vl_size dimension, T * MU, T const * X, T const W)
{
  T const * X_end = X + dimension ;
  T const * X_vec_end = X_end - VSIZE + 1 ;

  vl_bool dataAligned = VALIGNED(X) & VALIGNED(MU);
  VTYPE w = VLD1 (&W) ;

  if (dataAligned) {
    while (X < X_vec_end) {
      VTYPE a = *(VTYPE*)X ;
      VTYPE mu = *(VTYPE*)MU ;

      VTYPE aw = VMUL(a, w) ;
      VTYPE meanStore = VADD(aw, mu);

      *(VTYPE *)MU = meanStore;

      X += VSIZE ;
      MU += VSIZE ;
    }
  } else {
    while (X < X_vec_end) {
      VTYPE a  = VLDU(X) ;
      VTYPE mu = VLDU(MU) ;

      VTYPE aw = VMUL(a, w) ;
      VTYPE meanStore = VADD(aw, mu);

      VST2U(MU,meanStore);

      X += VSIZE ;
      MU += VSIZE ;
    }
  }

  while (X < X_end) {
    T a = *X++ ;
    *MU += a * W ;
    MU++;
  }
}

// Assembly:
subq $0x128, %rsp            # imm = 0x128
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movsd %xmm0, 0x40(%rsp)
movq 0x48(%rsp), %rax
movq 0x58(%rsp), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
addq $-0x8, %rax
movq %rax, 0x30(%rsp)
movl 0x48(%rsp), %eax
movl 0x50(%rsp), %ecx
orl %ecx, %eax
testb $0xf, %al
sete %al
movzbl %al, %eax
movl %eax, 0x2c(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0x108(%rsp), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x100(%rsp)
movsd 0x100(%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd %xmm0, 0xf0(%rsp)
movapd 0xf0(%rsp), %xmm0
movapd %xmm0, 0x10(%rsp)
cmpl $0x0, 0x2c(%rsp)
je 0x41bc4
jmp 0x41af7
movq 0x48(%rsp), %rax
cmpq 0x30(%rsp), %rax
jae 0x41bbf
movq 0x48(%rsp), %rax
movapd (%rax), %xmm0
movapd %xmm0, (%rsp)
movq 0x50(%rsp), %rax
movapd (%rax), %xmm0
movapd %xmm0, -0x10(%rsp)
movapd (%rsp), %xmm1
movapd 0x10(%rsp), %xmm0
movapd %xmm1, 0x90(%rsp)
movapd %xmm0, 0x80(%rsp)
movapd 0x90(%rsp), %xmm0
mulpd 0x80(%rsp), %xmm0
movapd %xmm0, -0x20(%rsp)
movapd -0x20(%rsp), %xmm1
movapd -0x10(%rsp), %xmm0
movapd %xmm1, 0xd0(%rsp)
movapd %xmm0, 0xc0(%rsp)
movapd 0xd0(%rsp), %xmm0
addpd 0xc0(%rsp), %xmm0
movapd %xmm0, -0x30(%rsp)
movapd -0x30(%rsp), %xmm0
movq 0x50(%rsp), %rax
movapd %xmm0, (%rax)
movq 0x48(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x50(%rsp)
jmp 0x41af7
jmp 0x41cc8
jmp 0x41bc6
movq 0x48(%rsp), %rax
cmpq 0x30(%rsp), %rax
jae 0x41cc6
movq 0x48(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rax
movupd (%rax), %xmm0
movapd %xmm0, -0x40(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movupd (%rax), %xmm0
movapd %xmm0, -0x50(%rsp)
movapd -0x40(%rsp), %xmm1
movapd 0x10(%rsp), %xmm0
movapd %xmm1, 0x70(%rsp)
movapd %xmm0, 0x60(%rsp)
movapd 0x70(%rsp), %xmm0
mulpd 0x60(%rsp), %xmm0
movapd %xmm0, -0x60(%rsp)
movapd -0x60(%rsp), %xmm1
movapd -0x50(%rsp), %xmm0
movapd %xmm1, 0xb0(%rsp)
movapd %xmm0, 0xa0(%rsp)
movapd 0xb0(%rsp), %xmm0
addpd 0xa0(%rsp), %xmm0
movapd %xmm0, -0x70(%rsp)
movq 0x50(%rsp), %rax
movapd -0x70(%rsp), %xmm0
movq %rax, 0x120(%rsp)
movapd %xmm0, 0x110(%rsp)
movapd 0x110(%rsp), %xmm0
movq 0x120(%rsp), %rax
movupd %xmm0, (%rax)
movq 0x48(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x50(%rsp)
jmp 0x41bc6
jmp 0x41cc8
jmp 0x41cca
movq 0x48(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x41d22
movq 0x48(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x48(%rsp)
movsd (%rax), %xmm0
movsd %xmm0, -0x78(%rsp)
movsd -0x78(%rsp), %xmm0
movsd 0x40(%rsp), %xmm2
movq 0x50(%rsp), %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movq 0x50(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x50(%rsp)
jmp 0x41cca
addq $0x128, %rsp            # imm = 0x128
retq
nopw (%rax,%rax)