// File: /workspace/github_c_makefile_star2_O0/zpole[P]IICV/vl/mathop_avx.c
// Function: vl_weighted_mean_avx_d
VL_EXPORT void
VL_XCAT(_vl_weighted_mean_avx_, 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 - VSIZEavx + 1 ;

  vl_bool dataAligned = VALIGNEDavx(X) & VALIGNEDavx(MU);
  VTYPEavx w = VLD1avx (&W) ;

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

      VTYPEavx aw = VMULavx(a, w) ;
      VTYPEavx meanStore = VADDavx(aw, mu);

      *(VTYPEavx *)MU = meanStore;

      X += VSIZEavx ;
      MU += VSIZEavx ;
    }
  } else {
    while (X < X_vec_end) {
      VTYPEavx a  = VLDUavx(X) ;
      VTYPEavx mu = VLDUavx(MU) ;

      VTYPEavx aw = VMULavx(a, w) ;
      VTYPEavx meanStore = VADDavx(aw, mu);

      VST2Uavx(MU,meanStore);

      X += VSIZEavx ;
      MU += VSIZEavx ;
    }
  }

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
andq $-0x20, %rsp
subq $0x320, %rsp            # imm = 0x320
movq %rdi, 0x178(%rsp)
movq %rsi, 0x170(%rsp)
movq %rdx, 0x168(%rsp)
vmovsd %xmm0, 0x160(%rsp)
movq 0x168(%rsp), %rax
movq 0x178(%rsp), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, 0x158(%rsp)
movq 0x158(%rsp), %rax
addq $-0x18, %rax
movq %rax, 0x150(%rsp)
movl 0x168(%rsp), %eax
movl 0x170(%rsp), %ecx
orl %ecx, %eax
testb $0x1f, %al
sete %al
movzbl %al, %eax
movl %eax, 0x14c(%rsp)
leaq 0x160(%rsp), %rax
movq %rax, 0x2d8(%rsp)
movq 0x2d8(%rsp), %rax
vmovsd (%rax), %xmm0
vmovsd %xmm0, 0x2d0(%rsp)
vbroadcastsd 0x2d0(%rsp), %ymm0
vmovapd %ymm0, 0x2a0(%rsp)
vmovapd 0x2a0(%rsp), %ymm0
vmovapd %ymm0, 0x120(%rsp)
cmpl $0x0, 0x14c(%rsp)
je 0x3d53e
jmp 0x3d439
movq 0x168(%rsp), %rax
cmpq 0x150(%rsp), %rax
jae 0x3d539
movq 0x168(%rsp), %rax
vmovapd (%rax), %ymm0
vmovapd %ymm0, 0x100(%rsp)
movq 0x170(%rsp), %rax
vmovapd (%rax), %ymm0
vmovapd %ymm0, 0xe0(%rsp)
vmovapd 0x100(%rsp), %ymm1
vmovapd 0x120(%rsp), %ymm0
vmovapd %ymm1, 0x1e0(%rsp)
vmovapd %ymm0, 0x1c0(%rsp)
vmovapd 0x1e0(%rsp), %ymm0
vmulpd 0x1c0(%rsp), %ymm0, %ymm0
vmovapd %ymm0, 0xc0(%rsp)
vmovapd 0xc0(%rsp), %ymm1
vmovapd 0xe0(%rsp), %ymm0
vmovapd %ymm1, 0x260(%rsp)
vmovapd %ymm0, 0x240(%rsp)
vmovapd 0x260(%rsp), %ymm0
vaddpd 0x240(%rsp), %ymm0, %ymm0
vmovapd %ymm0, 0xa0(%rsp)
vmovapd 0xa0(%rsp), %ymm0
movq 0x170(%rsp), %rax
vmovapd %ymm0, (%rax)
movq 0x168(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x168(%rsp)
movq 0x170(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x170(%rsp)
jmp 0x3d439
jmp 0x3d672
jmp 0x3d540
movq 0x168(%rsp), %rax
cmpq 0x150(%rsp), %rax
jae 0x3d670
movq 0x168(%rsp), %rax
movq %rax, 0x298(%rsp)
movq 0x298(%rsp), %rax
vmovupd (%rax), %ymm0
vmovapd %ymm0, 0x80(%rsp)
movq 0x170(%rsp), %rax
movq %rax, 0x290(%rsp)
movq 0x290(%rsp), %rax
vmovupd (%rax), %ymm0
vmovapd %ymm0, 0x60(%rsp)
vmovapd 0x80(%rsp), %ymm1
vmovapd 0x120(%rsp), %ymm0
vmovapd %ymm1, 0x1a0(%rsp)
vmovapd %ymm0, 0x180(%rsp)
vmovapd 0x1a0(%rsp), %ymm0
vmulpd 0x180(%rsp), %ymm0, %ymm0
vmovapd %ymm0, 0x40(%rsp)
vmovapd 0x40(%rsp), %ymm1
vmovapd 0x60(%rsp), %ymm0
vmovapd %ymm1, 0x220(%rsp)
vmovapd %ymm0, 0x200(%rsp)
vmovapd 0x220(%rsp), %ymm0
vaddpd 0x200(%rsp), %ymm0, %ymm0
vmovapd %ymm0, 0x20(%rsp)
movq 0x170(%rsp), %rax
vmovapd 0x20(%rsp), %ymm0
movq %rax, 0x308(%rsp)
vmovapd %ymm0, 0x2e0(%rsp)
vmovapd 0x2e0(%rsp), %ymm0
movq 0x308(%rsp), %rax
vmovupd %ymm0, (%rax)
movq 0x168(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x168(%rsp)
movq 0x170(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x170(%rsp)
jmp 0x3d540
jmp 0x3d672
jmp 0x3d674
movq 0x168(%rsp), %rax
cmpq 0x158(%rsp), %rax
jae 0x3d6e4
movq 0x168(%rsp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x168(%rsp)
vmovsd (%rax), %xmm0
vmovsd %xmm0, 0x18(%rsp)
vmovsd 0x18(%rsp), %xmm0
vmovsd 0x160(%rsp), %xmm2
movq 0x170(%rsp), %rax
vmovsd (%rax), %xmm1
vmulsd %xmm2, %xmm0, %xmm0
vaddsd %xmm1, %xmm0, %xmm0
vmovsd %xmm0, (%rax)
movq 0x170(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x170(%rsp)
jmp 0x3d674
movq %rbp, %rsp
popq %rbp
vzeroupper
retq
nopl (%rax)