user: Converte this assembly snippet into its equivalent C code:

```asm
<kernel_dgemv_n_8_lib4>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    0x20(%rsp),%ebp
  test   %edi,%edi
  jle    L6
  shl    $0x2,%edx
  mov    %edi,%r10d
  movslq %edx,%rdx
  lea    (%rsi,%rdx,8),%r11
  cmp    $0x3,%edi
  jle    L51
  lea    -0x4(%rdi),%edx
  pxor   %xmm11,%xmm11
  mov    %rsi,%rax
  shr    $0x2,%edx
  movapd %xmm11,%xmm4
  movapd %xmm11,%xmm5
  lea    0x1(%rdx),%r12d
  movapd %xmm11,%xmm6
  mov    %r11,%rdx
  mov    %r12,%rbx
  movapd %xmm11,%xmm7
  movapd %xmm11,%xmm8
  mov    %r12,%rdi
  shl    $0x5,%rbx
  movapd %xmm11,%xmm9
  movapd %xmm11,%xmm10
  add    %rcx,%rbx
  nop
L70:
  movsd  (%rcx),%xmm2
  movsd  (%rax),%xmm12
  add    $0x20,%rcx
  sub    $0xffffffffffffff80,%rax
  movsd  -0x18(%rcx),%xmm1
  movsd  -0x68(%rax),%xmm13
  sub    $0xffffffffffffff80,%rdx
  mulsd  %xmm2,%xmm12
  movsd  -0x10(%rcx),%xmm0
  movsd  -0x8(%rcx),%xmm3
  mulsd  %xmm2,%xmm13
  addsd  %xmm12,%xmm10
  movsd  -0x78(%rax),%xmm12
  addsd  %xmm7,%xmm13
  movsd  -0x78(%rdx),%xmm7
  mulsd  %xmm2,%xmm12
  mulsd  %xmm2,%xmm7
  addsd  %xmm12,%xmm9
  movsd  -0x70(%rax),%xmm12
  addsd  %xmm5,%xmm7
  movsd  -0x48(%rax),%xmm5
  mulsd  %xmm2,%xmm12
  mulsd  %xmm1,%xmm5
  addsd  %xmm8,%xmm12
  movsd  -0x80(%rdx),%xmm8
  addsd  %xmm13,%xmm5
  movsd  -0x40(%rax),%xmm13
  mulsd  %xmm2,%xmm8
  mulsd  %xmm0,%xmm13
  addsd  %xmm6,%xmm8
  movsd  -0x70(%rdx),%xmm6
  mulsd  %xmm2,%xmm6
  mulsd  -0x68(%rdx),%xmm2
  addsd  %xmm4,%xmm6
  movsd  -0x60(%rax),%xmm4
  addsd  %xmm11,%xmm2
  movsd  -0x58(%rax),%xmm11
  mulsd  %xmm1,%xmm4
  mulsd  %xmm1,%xmm11
  addsd  %xmm4,%xmm10
  movsd  -0x50(%rax),%xmm4
  addsd  %xmm9,%xmm11
  movsd  -0x58(%rdx),%xmm9
  mulsd  %xmm1,%xmm4
  mulsd  %xmm1,%xmm9
  addsd  %xmm10,%xmm13
  movsd  -0x20(%rax),%xmm10
  mulsd  %xmm3,%xmm10
  addsd  %xmm4,%xmm12
  movsd  -0x60(%rdx),%xmm4
  addsd  %xmm7,%xmm9
  movsd  -0x30(%rax),%xmm7
  mulsd  %xmm1,%xmm4
  mulsd  %xmm0,%xmm7
  addsd  %xmm13,%xmm10
  addsd  %xmm8,%xmm4
  movsd  -0x50(%rdx),%xmm8
  addsd  %xmm12,%xmm7
  mulsd  %xmm1,%xmm8
  mulsd  -0x48(%rdx),%xmm1
  addsd  %xmm6,%xmm8
  movsd  -0x28(%rax),%xmm6
  addsd  %xmm2,%xmm1
  movsd  -0x38(%rax),%xmm2
  mulsd  %xmm0,%xmm6
  mulsd  %xmm0,%xmm2
  addsd  %xmm5,%xmm6
  movsd  -0x40(%rdx),%xmm5
  addsd  %xmm2,%xmm11
  movsd  -0x30(%rdx),%xmm2
  mulsd  %xmm0,%xmm5
  mulsd  %xmm0,%xmm2
  addsd  %xmm4,%xmm5
  movsd  -0x38(%rdx),%xmm4
  addsd  %xmm8,%xmm2
  movsd  -0x10(%rax),%xmm8
  mulsd  %xmm0,%xmm4
  mulsd  %xmm3,%xmm8
  mulsd  -0x28(%rdx),%xmm0
  addsd  %xmm9,%xmm4
  movsd  -0x18(%rax),%xmm9
  addsd  %xmm7,%xmm8
  movsd  -0x8(%rax),%xmm7
  mulsd  %xmm3,%xmm9
  addsd  %xmm1,%xmm0
  mulsd  %xmm3,%xmm7
  addsd  %xmm11,%xmm9
  addsd  %xmm6,%xmm7
  movsd  -0x20(%rdx),%xmm6
  mulsd  %xmm3,%xmm6
  addsd  %xmm5,%xmm6
  movsd  -0x18(%rdx),%xmm5
  mulsd  %xmm3,%xmm5
  addsd  %xmm4,%xmm5
  movsd  -0x10(%rdx),%xmm4
  mulsd  %xmm3,%xmm4
  mulsd  -0x8(%rdx),%xmm3
  addsd  %xmm2,%xmm4
  addsd  %xmm0,%xmm3
  movapd %xmm3,%xmm11
  cmp    %rbx,%rcx
  jne    L70
  mov    %r12,%rax
  lea    0x0(,%rdi,4),%edx
  shl    $0x7,%rax
  add    %rax,%rsi
  add    %rax,%r11
  cmp    %edx,%r10d
  jle    L19
L54:
  xor    %eax,%eax
L73:
  movsd  (%rbx,%rax,1),%xmm0
  movsd  (%rsi,%rax,4),%xmm1
  add    $0x1,%edx
  mulsd  %xmm0,%xmm1
  addsd  %xmm1,%xmm10
  movsd  0x8(%rsi,%rax,4),%xmm1
  mulsd  %xmm0,%xmm1
  addsd  %xmm1,%xmm9
  movsd  0x10(%rsi,%rax,4),%xmm1
  mulsd  %xmm0,%xmm1
  addsd  %xmm1,%xmm8
  movsd  0x18(%rsi,%rax,4),%xmm1
  mulsd  %xmm0,%xmm1
  addsd  %xmm1,%xmm7
  movsd  (%r11,%rax,4),%xmm1
  mulsd  %xmm0,%xmm1
  addsd  %xmm1,%xmm6
  movsd  0x8(%r11,%rax,4),%xmm1
  mulsd  %xmm0,%xmm1
  addsd  %xmm1,%xmm5
  movsd  0x10(%r11,%rax,4),%xmm1
  mulsd  %xmm0,%xmm1
  mulsd  0x18(%r11,%rax,4),%xmm0
  add    $0x8,%rax
  addsd  %xmm1,%xmm4
  addsd  %xmm0,%xmm11
  cmp    %edx,%r10d
  jg     L73
L19:
  test   %ebp,%ebp
  je     L16
  movsd  (%r8),%xmm0
  cmp    $0x1,%ebp
  je     L36
  subsd  %xmm10,%xmm0
  movsd  %xmm0,(%r9)
  movsd  0x8(%r8),%xmm0
  subsd  %xmm9,%xmm0
  movsd  %xmm0,0x8(%r9)
  movsd  0x10(%r8),%xmm0
  subsd  %xmm8,%xmm0
  movsd  %xmm0,0x10(%r9)
  movsd  0x18(%r8),%xmm0
  subsd  %xmm7,%xmm0
  movsd  %xmm0,0x18(%r9)
  movsd  0x20(%r8),%xmm0
  subsd  %xmm6,%xmm0
  movsd  %xmm0,0x20(%r9)
  movsd  0x28(%r8),%xmm0
  subsd  %xmm5,%xmm0
  movsd  %xmm0,0x28(%r9)
  movsd  0x30(%r8),%xmm0
  subsd  %xmm4,%xmm0
  movsd  %xmm0,0x30(%r9)
  movsd  0x38(%r8),%xmm0
  subsd  %xmm11,%xmm0
  movsd  %xmm0,0x38(%r9)
L6:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L16:
  pop    %rbx
  movsd  %xmm10,(%r9)
  pop    %rbp
  movsd  %xmm9,0x8(%r9)
  pop    %r12
  movsd  %xmm8,0x10(%r9)
  movsd  %xmm7,0x18(%r9)
  movsd  %xmm6,0x20(%r9)
  movsd  %xmm5,0x28(%r9)
  movsd  %xmm4,0x30(%r9)
  movsd  %xmm11,0x38(%r9)
  ret
  nopl   0x0(%rax)
L36:
  addsd  %xmm10,%xmm0
  pop    %rbx
  pop    %rbp
  pop    %r12
  movsd  %xmm0,(%r9)
  addsd  0x8(%r8),%xmm9
  movsd  %xmm9,0x8(%r9)
  addsd  0x10(%r8),%xmm8
  movsd  %xmm8,0x10(%r9)
  addsd  0x18(%r8),%xmm7
  movsd  %xmm7,0x18(%r9)
  addsd  0x20(%r8),%xmm6
  movsd  %xmm6,0x20(%r9)
  addsd  0x28(%r8),%xmm5
  movsd  %xmm5,0x28(%r9)
  addsd  0x30(%r8),%xmm4
  movsd  %xmm4,0x30(%r9)
  addsd  0x38(%r8),%xmm11
  movsd  %xmm11,0x38(%r9)
  ret
  nopl   0x0(%rax,%rax,1)
L51:
  pxor   %xmm11,%xmm11
  mov    %rcx,%rbx
  xor    %edx,%edx
  movapd %xmm11,%xmm4
  movapd %xmm11,%xmm5
  movapd %xmm11,%xmm6
  movapd %xmm11,%xmm7
  movapd %xmm11,%xmm8
  movapd %xmm11,%xmm9
  movapd %xmm11,%xmm10
  jmp    L54
```

assistant: ```c
void kernel_dgemv_n_8_lib4(int kmax, double *A0, int sda, double *x, double *y, double *z, int alg) {
  if (kmax <= 0)
    return;
  double *A1 = A0 + 4 * sda;
  const int lda = 4;
  int k;
  double x_0, x_1, x_2, x_3, y_0 = 0, y_1 = 0, y_2 = 0, y_3 = 0, y_4 = 0, y_5 = 0, y_6 = 0, y_7 = 0;
  k = 0;
  for (; k < kmax - 3; k += 4) {
    x_0 = x[0];
    x_1 = x[1];
    x_2 = x[2];
    x_3 = x[3];
    y_0 += A0[0 + lda * 0] * x_0;
    y_1 += A0[1 + lda * 0] * x_0;
    y_2 += A0[2 + lda * 0] * x_0;
    y_3 += A0[3 + lda * 0] * x_0;
    y_4 += A1[0 + lda * 0] * x_0;
    y_5 += A1[1 + lda * 0] * x_0;
    y_6 += A1[2 + lda * 0] * x_0;
    y_7 += A1[3 + lda * 0] * x_0;
    y_0 += A0[0 + lda * 1] * x_1;
    y_1 += A0[1 + lda * 1] * x_1;
    y_2 += A0[2 + lda * 1] * x_1;
    y_3 += A0[3 + lda * 1] * x_1;
    y_4 += A1[0 + lda * 1] * x_1;
    y_5 += A1[1 + lda * 1] * x_1;
    y_6 += A1[2 + lda * 1] * x_1;
    y_7 += A1[3 + lda * 1] * x_1;
    y_0 += A0[0 + lda * 2] * x_2;
    y_1 += A0[1 + lda * 2] * x_2;
    y_2 += A0[2 + lda * 2] * x_2;
    y_3 += A0[3 + lda * 2] * x_2;
    y_4 += A1[0 + lda * 2] * x_2;
    y_5 += A1[1 + lda * 2] * x_2;
    y_6 += A1[2 + lda * 2] * x_2;
    y_7 += A1[3 + lda * 2] * x_2;
    y_0 += A0[0 + lda * 3] * x_3;
    y_1 += A0[1 + lda * 3] * x_3;
    y_2 += A0[2 + lda * 3] * x_3;
    y_3 += A0[3 + lda * 3] * x_3;
    y_4 += A1[0 + lda * 3] * x_3;
    y_5 += A1[1 + lda * 3] * x_3;
    y_6 += A1[2 + lda * 3] * x_3;
    y_7 += A1[3 + lda * 3] * x_3;
    A0 += 4 * lda;
    A1 += 4 * lda;
    x += 4;
  }
  for (; k < kmax; k++) {
    x_0 = x[0];
    y_0 += A0[0 + lda * 0] * x_0;
    y_1 += A0[1 + lda * 0] * x_0;
    y_2 += A0[2 + lda * 0] * x_0;
    y_3 += A0[3 + lda * 0] * x_0;
    y_4 += A1[0 + lda * 0] * x_0;
    y_5 += A1[1 + lda * 0] * x_0;
    y_6 += A1[2 + lda * 0] * x_0;
    y_7 += A1[3 + lda * 0] * x_0;
    A0 += 1 * lda;
    A1 += 1 * lda;
    x += 1;
  }
  if (alg == 0) {
    z[0] = y_0;
    z[1] = y_1;
    z[2] = y_2;
    z[3] = y_3;
    z[4] = y_4;
    z[5] = y_5;
    z[6] = y_6;
    z[7] = y_7;
  } else if (alg == 1) {
    z[0] = y[0] + y_0;
    z[1] = y[1] + y_1;
    z[2] = y[2] + y_2;
    z[3] = y[3] + y_3;
    z[4] = y[4] + y_4;
    z[5] = y[5] + y_5;
    z[6] = y[6] + y_6;
    z[7] = y[7] + y_7;
  } else {
    z[0] = y[0] - y_0;
    z[1] = y[1] - y_1;
    z[2] = y[2] - y_2;
    z[3] = y[3] - y_3;
    z[4] = y[4] - y_4;
    z[5] = y[5] - y_5;
    z[6] = y[6] - y_6;
    z[7] = y[7] - y_7;
  }
}
```