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

  __m512i op0, op1;
  volatile __m512i tgt;

  __m512i v4_int16 = _mm512_load_si512(&op4_int16);

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

    tgt = _mm512_setzero_si512();
    for (int j = 0; j < col_aligned; j += 64) {
      op0 = _mm512_load_si512(&mutiplier[j]);
      op1 = _mm512_load_si512(&mat[i][j]);
      __m512i vresult1 = _mm512_maddubs_epi16(op0, op1);
      __m512i vresult2 = _mm512_madd_epi16(vresult1, v4_int16);
      tgt = _mm512_add_epi32(vresult2, tgt);
    }

    int *presult = (int *)&tgt;
    for (int k = 0; k < VLEN; k++)
      sum += presult[k];

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
andq $-0x40, %rsp
subq $0x440, %rsp            # imm = 0x440
movl $0x1000, 0x224(%rsp) # imm = 0x1000
leaq 0x43c7f(%rip), %rax     # 0x45060
movq %rax, 0x238(%rsp)
movq 0x238(%rsp), %rax
vmovdqa64 (%rax), %zmm0
vmovdqa64 %zmm0, 0x100(%rsp)
movl $0x0, 0xfc(%rsp)
cmpl $0x40, 0xfc(%rsp)
jge 0x1670
movl $0x0, 0xf8(%rsp)
vpxor %xmm0, %xmm0, %xmm0
vmovdqa64 %zmm0, 0x240(%rsp)
vmovdqa64 0x240(%rsp), %zmm0
vmovdqa64 %zmm0, 0x140(%rsp)
movl $0x0, 0xf4(%rsp)
cmpl $0x1000, 0xf4(%rsp) # imm = 0x1000
jge 0x159a
movslq 0xf4(%rsp), %rcx
leaq 0x42bf6(%rip), %rax     # 0x44060
addq %rcx, %rax
movq %rax, 0x230(%rsp)
movq 0x230(%rsp), %rax
vmovdqa64 (%rax), %zmm0
vmovdqa64 %zmm0, 0x1c0(%rsp)
movslq 0xfc(%rsp), %rcx
leaq 0x2bc6(%rip), %rax      # 0x4060
shlq $0xc, %rcx
addq %rcx, %rax
movslq 0xf4(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x228(%rsp)
movq 0x228(%rsp), %rax
vmovdqa64 (%rax), %zmm0
vmovdqa64 %zmm0, 0x180(%rsp)
vmovdqa64 0x1c0(%rsp), %zmm1
vmovdqa64 0x180(%rsp), %zmm0
vmovdqa64 %zmm1, 0x2c0(%rsp)
vmovdqa64 %zmm0, 0x280(%rsp)
vmovdqa64 0x2c0(%rsp), %zmm0
vmovdqa64 0x280(%rsp), %zmm1
vpmaddubsw %zmm1, %zmm0, %zmm0
vmovdqa64 %zmm0, 0x80(%rsp)
vmovdqa64 0x80(%rsp), %zmm1
vmovdqa64 0x100(%rsp), %zmm0
vmovdqa64 %zmm1, 0x340(%rsp)
vmovdqa64 %zmm0, 0x300(%rsp)
vmovdqa64 0x340(%rsp), %zmm0
vmovdqa64 0x300(%rsp), %zmm1
vpmaddwd %zmm1, %zmm0, %zmm0
vmovdqa64 %zmm0, 0x40(%rsp)
vmovdqa64 0x40(%rsp), %zmm1
vmovdqa64 0x140(%rsp), %zmm0
vmovdqa64 %zmm1, 0x3c0(%rsp)
vmovdqa64 %zmm0, 0x380(%rsp)
vmovdqa64 0x3c0(%rsp), %zmm0
vmovdqa64 0x380(%rsp), %zmm1
vpaddd %zmm1, %zmm0, %zmm0
vmovdqa64 %zmm0, 0x140(%rsp)
movl 0xf4(%rsp), %eax
addl $0x40, %eax
movl %eax, 0xf4(%rsp)
jmp 0x144a
leaq 0x140(%rsp), %rax
movq %rax, 0x38(%rsp)
movl $0x0, 0x34(%rsp)
movslq 0x34(%rsp), %rax
cmpq $0x10, %rax
jae 0x15e2
movq 0x38(%rsp), %rax
movslq 0x34(%rsp), %rcx
movl (%rax,%rcx,4), %eax
addl 0xf8(%rsp), %eax
movl %eax, 0xf8(%rsp)
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x15af
movl $0x1000, 0x30(%rsp)     # imm = 0x1000
cmpl $0x1000, 0x30(%rsp)     # imm = 0x1000
jge 0x1641
movslq 0xfc(%rsp), %rcx
leaq 0x2a5d(%rip), %rax      # 0x4060
shlq $0xc, %rcx
addq %rcx, %rax
movslq 0x30(%rsp), %rcx
movsbl (%rax,%rcx), %eax
movslq 0x30(%rsp), %rdx
leaq 0x42a41(%rip), %rcx     # 0x44060
movsbl (%rcx,%rdx), %ecx
imull %ecx, %eax
addl 0xf8(%rsp), %eax
movl %eax, 0xf8(%rsp)
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x15ea
movl 0xf8(%rsp), %edx
movslq 0xfc(%rsp), %rcx
leaq 0x43a49(%rip), %rax     # 0x450a0
movl %edx, (%rax,%rcx,4)
movl 0xfc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xfc(%rsp)
jmp 0x140a
movq %rbp, %rsp
popq %rbp
vzeroupper
retq
nopl (%rax,%rax)