// File: /workspace/github_c_makefile_star2_O0/jwang11[P]intel_avx_perf/matrix_int16.c
// Function: calc_avx512
void calc_avx512(void) {
  #define VLEN (512/8/sizeof(int16_t))
  const int col_aligned = col - col % VLEN;
  int16_t dst_arr[VLEN];

  __m512i op0, op1, tmp_vec;
  volatile __m512i  tgt;

  for (int i = 0; i < row; i++) {
    int sum = 0;

    tgt = _mm512_setzero_si512();
    for (int j = 0; j < col_aligned; j += VLEN) {
      op0 = _mm512_load_si512(&mutiplier[j]);
      op1 = _mm512_load_si512(&mat[i][j]);
      tmp_vec = _mm512_mullo_epi16(op0, op1);
      tgt = _mm512_add_epi16(tmp_vec, tgt);
    }

    _mm512_store_epi64(dst_arr, tgt);
    for (int k = 0; k < VLEN; k++)
      sum += dst_arr[k];

    for (int l = col_aligned; l < col; l++)
      sum += mat[i][l] * mutiplier[l];

    result[i] = sum;
  }
  #undef VLEN
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
andq $-0x40, %rsp
subq $0x3c0, %rsp            # imm = 0x3C0
movl $0x1000, 0x1bc(%rsp) # imm = 0x1000
movl $0x0, 0x3c(%rsp)
cmpl $0x40, 0x3c(%rsp)
jge 0x1789
movl $0x0, 0x38(%rsp)
vpxor %xmm0, %xmm0, %xmm0
vmovdqa64 %zmm0, 0x1c0(%rsp)
vmovdqa64 0x1c0(%rsp), %zmm0
vmovdqa64 %zmm0, 0x40(%rsp)
movl $0x0, 0x34(%rsp)
cmpl $0x1000, 0x34(%rsp)     # imm = 0x1000
jge 0x16a1
movslq 0x34(%rsp), %rcx
leaq 0x82aad(%rip), %rax     # 0x84060
shlq %rcx
addq %rcx, %rax
movq %rax, 0x238(%rsp)
movq 0x238(%rsp), %rax
vmovdqa64 (%rax), %zmm0
vmovdqa64 %zmm0, 0x100(%rsp)
movslq 0x3c(%rsp), %rcx
leaq 0x2a7d(%rip), %rax      # 0x4060
shlq $0xd, %rcx
addq %rcx, %rax
movslq 0x34(%rsp), %rcx
shlq %rcx
addq %rcx, %rax
movq %rax, 0x230(%rsp)
movq 0x230(%rsp), %rax
vmovdqa64 (%rax), %zmm0
vmovdqa64 %zmm0, 0xc0(%rsp)
vmovdqa64 0x100(%rsp), %zmm1
vmovdqa64 0xc0(%rsp), %zmm0
vmovdqa64 %zmm1, 0x280(%rsp)
vmovdqa64 %zmm0, 0x240(%rsp)
vmovdqa64 0x280(%rsp), %zmm0
vmovdqa64 0x240(%rsp), %zmm1
vpmullw %zmm1, %zmm0, %zmm0
vmovdqa64 %zmm0, 0x80(%rsp)
vmovdqa64 0x80(%rsp), %zmm1
vmovdqa64 0x40(%rsp), %zmm0
vmovdqa64 %zmm1, 0x300(%rsp)
vmovdqa64 %zmm0, 0x2c0(%rsp)
vmovdqa64 0x300(%rsp), %zmm0
vmovdqa64 0x2c0(%rsp), %zmm1
vpaddw %zmm1, %zmm0, %zmm0
vmovdqa64 %zmm0, 0x40(%rsp)
movslq 0x34(%rsp), %rax
addq $0x20, %rax
movl %eax, 0x34(%rsp)
jmp 0x1599
leaq 0x170(%rsp), %rax
vmovdqa64 0x40(%rsp), %zmm0
movq %rax, 0x3a8(%rsp)
vmovdqa64 %zmm0, 0x340(%rsp)
vmovdqa64 0x340(%rsp), %zmm0
movq 0x3a8(%rsp), %rax
vmovdqa64 %zmm0, (%rax)
movl $0x0, 0x30(%rsp)
movslq 0x30(%rsp), %rax
cmpq $0x20, %rax
jae 0x170c
movslq 0x30(%rsp), %rax
movswl 0x170(%rsp,%rax,2), %eax
addl 0x38(%rsp), %eax
movl %eax, 0x38(%rsp)
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x16df
movl $0x1000, 0x2c(%rsp)     # imm = 0x1000
cmpl $0x1000, 0x2c(%rsp)     # imm = 0x1000
jge 0x1762
movslq 0x3c(%rsp), %rcx
leaq 0x2936(%rip), %rax      # 0x4060
shlq $0xd, %rcx
addq %rcx, %rax
movslq 0x2c(%rsp), %rcx
movswl (%rax,%rcx,2), %eax
movslq 0x2c(%rsp), %rdx
leaq 0x8291a(%rip), %rcx     # 0x84060
movswl (%rcx,%rdx,2), %ecx
imull %ecx, %eax
addl 0x38(%rsp), %eax
movl %eax, 0x38(%rsp)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x1714
movl 0x38(%rsp), %eax
movw %ax, %dx
movslq 0x3c(%rsp), %rcx
leaq 0x848eb(%rip), %rax     # 0x86060
movw %dx, (%rax,%rcx,2)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x1562
movq %rbp, %rsp
popq %rbp
vzeroupper
retq
nopw %cs:(%rax,%rax)