user: Please show me the C implementation that matches the assembly code listed below:

```asm
<kernel_dgemv_n_4_vs_lib4>:
  endbr64
  push   %rbp
  push   %rbx
  mov    %esi,%ebx
  mov    0x18(%rsp),%ebp
  test   %esi,%esi
  jle    L79
  mov    %edi,%r10d
  mov    %rdx,%rsi
  mov    %rcx,%r11
  cmp    $0x3,%ebx
  jle    L118
  lea    -0x4(%rbx),%edi
  pxor   %xmm5,%xmm5
  pxor   %xmm4,%xmm4
  mov    %rdx,%rax
  shr    $0x2,%edi
  mov    %rcx,%rdx
  movapd %xmm5,%xmm3
  xor    %ecx,%ecx
  add    $0x1,%edi
  nopl   0x0(%rax,%rax,1)
L102:
  movupd (%rax),%xmm9
  movupd (%rdx),%xmm8
  add    $0x1,%ecx
  sub    $0xffffffffffffff80,%rax
  movupd -0x60(%rax),%xmm2
  movlpd -0x78(%rax),%xmm2
  add    $0x20,%rdx
  movhpd -0x60(%rax),%xmm9
  movupd -0x40(%rax),%xmm6
  movupd -0x10(%rdx),%xmm7
  mulpd  %xmm8,%xmm9
  movupd -0x20(%rax),%xmm1
  movlpd -0x38(%rax),%xmm1
  mulpd  %xmm8,%xmm2
  movhpd -0x20(%rax),%xmm6
  mulpd  %xmm7,%xmm6
  mulpd  %xmm7,%xmm1
  movapd %xmm9,%xmm0
  unpcklpd %xmm2,%xmm0
  unpckhpd %xmm2,%xmm9
  addpd  %xmm4,%xmm0
  movapd %xmm6,%xmm2
  unpcklpd %xmm1,%xmm2
  unpckhpd %xmm1,%xmm6
  movupd -0x50(%rax),%xmm1
  movlpd -0x68(%rax),%xmm1
  addpd  %xmm9,%xmm0
  mulpd  %xmm8,%xmm1
  addpd  %xmm2,%xmm0
  movapd %xmm0,%xmm4
  movupd -0x70(%rax),%xmm0
  addpd  %xmm6,%xmm4
  movupd -0x30(%rax),%xmm6
  movhpd -0x50(%rax),%xmm0
  mulpd  %xmm8,%xmm0
  movhpd -0x10(%rax),%xmm6
  mulpd  %xmm7,%xmm6
  movapd %xmm0,%xmm2
  unpckhpd %xmm0,%xmm0
  addsd  %xmm3,%xmm2
  movapd %xmm2,%xmm3
  movapd %xmm1,%xmm2
  unpckhpd %xmm1,%xmm1
  addsd  %xmm0,%xmm3
  movupd -0x10(%rax),%xmm0
  movlpd -0x28(%rax),%xmm0
  addsd  %xmm5,%xmm2
  mulpd  %xmm7,%xmm0
  addsd  %xmm2,%xmm1
  addsd  %xmm6,%xmm3
  unpckhpd %xmm6,%xmm6
  addsd  %xmm6,%xmm3
  addsd  %xmm0,%xmm1
  unpckhpd %xmm0,%xmm0
  movapd %xmm1,%xmm5
  addsd  %xmm0,%xmm5
  cmp    %ecx,%edi
  ja     L102
  mov    %edi,%eax
  shl    $0x2,%edi
  mov    %rax,%rdx
  shl    $0x5,%rax
  shl    $0x7,%rdx
  add    %rax,%r11
  add    %rdx,%rsi
  cmp    %edi,%ebx
  jle    L111
L30:
  mov    %ebx,%edx
  mov    $0x1,%eax
  sub    %edi,%edx
  cmp    %ebx,%edi
  cmovl  %edx,%eax
  cmp    $0x1,%edx
  je     L144
  cmp    %ebx,%edi
  jge    L144
  movupd (%rsi),%xmm1
  movupd 0x20(%rsi),%xmm10
  mov    %eax,%edx
  movupd 0x10(%rsi),%xmm0
  movlpd 0x8(%rsi),%xmm0
  shr    %edx
  movhpd 0x10(%rsi),%xmm1
  movupd (%r11),%xmm7
  movhpd 0x30(%rsi),%xmm10
  movupd 0x30(%rsi),%xmm6
  movapd %xmm1,%xmm2
  movlpd 0x28(%rsi),%xmm6
  movapd %xmm0,%xmm8
  unpckhpd %xmm10,%xmm1
  mulpd  %xmm7,%xmm1
  unpcklpd %xmm10,%xmm2
  mulpd  %xmm7,%xmm2
  unpcklpd %xmm6,%xmm8
  unpckhpd %xmm6,%xmm0
  mulpd  %xmm7,%xmm8
  mulpd  %xmm7,%xmm0
  movapd %xmm2,%xmm9
  unpcklpd %xmm8,%xmm9
  unpckhpd %xmm8,%xmm2
  addpd  %xmm9,%xmm4
  addpd  %xmm2,%xmm4
  movapd %xmm1,%xmm2
  unpckhpd %xmm1,%xmm1
  addsd  %xmm3,%xmm2
  movapd %xmm1,%xmm3
  movapd %xmm0,%xmm1
  addsd  %xmm5,%xmm1
  unpckhpd %xmm0,%xmm0
  movapd %xmm0,%xmm5
  addsd  %xmm2,%xmm3
  addsd  %xmm1,%xmm5
  cmp    $0x1,%edx
  je     L86
  movupd 0x40(%rsi),%xmm1
  movupd 0x60(%rsi),%xmm10
  movupd 0x50(%rsi),%xmm0
  movlpd 0x48(%rsi),%xmm0
  movhpd 0x50(%rsi),%xmm1
  movupd 0x10(%r11),%xmm7
  movhpd 0x70(%rsi),%xmm10
  movupd 0x70(%rsi),%xmm6
  movapd %xmm1,%xmm2
  movlpd 0x68(%rsi),%xmm6
  movapd %xmm0,%xmm8
  unpckhpd %xmm10,%xmm1
  mulpd  %xmm7,%xmm1
  unpcklpd %xmm10,%xmm2
  mulpd  %xmm7,%xmm2
  unpcklpd %xmm6,%xmm8
  unpckhpd %xmm6,%xmm0
  mulpd  %xmm7,%xmm8
  mulpd  %xmm7,%xmm0
  movapd %xmm2,%xmm9
  unpcklpd %xmm8,%xmm9
  unpckhpd %xmm8,%xmm2
  addpd  %xmm9,%xmm4
  addpd  %xmm2,%xmm4
  movapd %xmm1,%xmm2
  unpckhpd %xmm1,%xmm1
  addsd  %xmm3,%xmm2
  movapd %xmm1,%xmm3
  movapd %xmm0,%xmm1
  addsd  %xmm5,%xmm1
  unpckhpd %xmm0,%xmm0
  movapd %xmm0,%xmm5
  addsd  %xmm2,%xmm3
  addsd  %xmm1,%xmm5
L86:
  mov    %eax,%edx
  and    $0xfffffffe,%edx
  mov    %edx,%ecx
  mov    %rcx,%rdi
  lea    (%r11,%rcx,8),%r11
  shl    $0x5,%rdi
  add    %rdi,%rsi
  cmp    %eax,%edx
  je     L111
L144:
  movsd  (%r11),%xmm0
  movupd (%rsi),%xmm7
  movapd %xmm0,%xmm1
  unpcklpd %xmm1,%xmm1
  mulpd  %xmm7,%xmm1
  addpd  %xmm1,%xmm4
  movsd  0x10(%rsi),%xmm1
  mulsd  %xmm0,%xmm1
  mulsd  0x18(%rsi),%xmm0
  addsd  %xmm1,%xmm3
  addsd  %xmm0,%xmm5
L111:
  test   %ebp,%ebp
  je     L127
  movupd (%r8),%xmm2
  movsd  0x10(%r8),%xmm1
  movsd  0x18(%r8),%xmm0
  cmp    $0x1,%ebp
  je     L3
  subpd  %xmm4,%xmm2
  subsd  %xmm3,%xmm1
  subsd  %xmm5,%xmm0
  movapd %xmm2,%xmm4
  movapd %xmm1,%xmm3
  movapd %xmm0,%xmm5
L127:
  movapd %xmm4,%xmm7
  unpckhpd %xmm7,%xmm7
  cmp    $0x3,%r10d
  jg     L13
L0:
  movsd  %xmm4,(%r9)
  cmp    $0x1,%r10d
  jle    L79
  movsd  %xmm7,0x8(%r9)
  cmp    $0x3,%r10d
  je     L126
L79:
  pop    %rbx
  pop    %rbp
  ret
  nopl   (%rax)
L13:
  pop    %rbx
  movups %xmm4,(%r9)
  pop    %rbp
  movsd  %xmm3,0x10(%r9)
  movsd  %xmm5,0x18(%r9)
  ret
  nopl   0x0(%rax,%rax,1)
L126:
  movsd  %xmm3,0x10(%r9)
  jmp    L79
L3:
  addpd  %xmm2,%xmm4
  addsd  %xmm1,%xmm3
  addsd  %xmm0,%xmm5
  movapd %xmm4,%xmm7
  unpckhpd %xmm7,%xmm7
  cmp    $0x3,%r10d
  jle    L0
  jmp    L13
  nopl   0x0(%rax)
L118:
  pxor   %xmm5,%xmm5
  pxor   %xmm4,%xmm4
  xor    %edi,%edi
  movapd %xmm5,%xmm3
  jmp    L30
```

assistant: ```c
void kernel_dgemv_n_4_vs_lib4(int km, int kmax, double *A, double *x, double *y, double *z, int alg) {
  if (kmax <= 0)
    return;
  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;
  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 += A[0 + lda * 0] * x_0;
    y_1 += A[1 + lda * 0] * x_0;
    y_2 += A[2 + lda * 0] * x_0;
    y_3 += A[3 + lda * 0] * x_0;
    y_0 += A[0 + lda * 1] * x_1;
    y_1 += A[1 + lda * 1] * x_1;
    y_2 += A[2 + lda * 1] * x_1;
    y_3 += A[3 + lda * 1] * x_1;
    y_0 += A[0 + lda * 2] * x_2;
    y_1 += A[1 + lda * 2] * x_2;
    y_2 += A[2 + lda * 2] * x_2;
    y_3 += A[3 + lda * 2] * x_2;
    y_0 += A[0 + lda * 3] * x_3;
    y_1 += A[1 + lda * 3] * x_3;
    y_2 += A[2 + lda * 3] * x_3;
    y_3 += A[3 + lda * 3] * x_3;
    A += 4 * lda;
    x += 4;
  }
  for (; k < kmax; k++) {
    x_0 = x[0];
    y_0 += A[0 + lda * 0] * x_0;
    y_1 += A[1 + lda * 0] * x_0;
    y_2 += A[2 + lda * 0] * x_0;
    y_3 += A[3 + lda * 0] * x_0;
    A += 1 * lda;
    x += 1;
  }
  if (alg == 0) {
    goto store;
  } else if (alg == 1) {
    y_0 += y[0];
    y_1 += y[1];
    y_2 += y[2];
    y_3 += y[3];
    goto store;
  } else {
    y_0 = y[0] - y_0;
    y_1 = y[1] - y_1;
    y_2 = y[2] - y_2;
    y_3 = y[3] - y_3;
    goto store;
  }
store:
  if (km >= 4) {
    z[0] = y_0;
    z[1] = y_1;
    z[2] = y_2;
    z[3] = y_3;
  } else {
    z[0] = y_0;
    if (km >= 2) {
      z[1] = y_1;
      if (km > 2) {
        z[2] = y_2;
      }
    }
  }
}
```