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

```asm
<kernel_dgemm_nn_2x2_vs_lib4>:
  endbr64
  push   %r13
  mov    %edi,%r11d
  mov    %edx,%r10d
  mov    %rcx,%rdi
  push   %r12
  push   %rbp
  push   %rbx
  mov    %esi,%ebx
  mov    0x28(%rsp),%r13d
  mov    0x30(%rsp),%r12
  mov    0x38(%rsp),%rbp
  cmp    $0x3,%edx
  jle    L101
  shl    $0x2,%r9d
  lea    -0x4(%rdx),%eax
  movslq %r9d,%rsi
  mov    %eax,%ecx
  shl    $0x3,%rsi
  shr    $0x2,%ecx
  cmp    $0x3,%eax
  jbe    L134
  pxor   %xmm11,%xmm11
  mov    %rdi,%rdx
  mov    %r8,%rax
  xor    %r9d,%r9d
  movapd %xmm11,%xmm10
  movapd %xmm11,%xmm6
  movapd %xmm11,%xmm7
  cs nopw 0x0(%rax,%rax,1)
L66:
  movupd (%rdx),%xmm4
  movupd (%rax),%xmm3
  add    $0x1,%r9d
  sub    $0xffffffffffffff80,%rdx
  movupd 0x20(%rax),%xmm13
  movupd -0x60(%rdx),%xmm1
  movhpd -0x60(%rdx),%xmm4
  movlpd -0x78(%rdx),%xmm1
  movupd 0x30(%rax),%xmm14
  mulpd  %xmm4,%xmm3
  movupd -0x20(%rdx),%xmm0
  movlpd -0x38(%rdx),%xmm0
  mulpd  %xmm13,%xmm4
  movupd -0x40(%rdx),%xmm2
  movupd 0x10(%rax),%xmm8
  movhpd -0x20(%rdx),%xmm2
  mulpd  %xmm2,%xmm8
  mulpd  %xmm14,%xmm2
  movapd %xmm3,%xmm5
  unpckhpd %xmm3,%xmm3
  addsd  %xmm7,%xmm5
  addsd  %xmm4,%xmm6
  unpckhpd %xmm4,%xmm4
  addsd  %xmm4,%xmm6
  movapd %xmm5,%xmm7
  movapd %xmm13,%xmm4
  movupd (%rax),%xmm5
  mulpd  %xmm1,%xmm4
  addsd  %xmm3,%xmm7
  movupd 0x10(%rax),%xmm3
  add    %rsi,%rax
  mulpd  %xmm1,%xmm5
  mulpd  %xmm0,%xmm3
  addsd  %xmm2,%xmm6
  unpckhpd %xmm2,%xmm2
  mulpd  %xmm14,%xmm0
  addsd  %xmm8,%xmm7
  unpckhpd %xmm8,%xmm8
  movapd %xmm4,%xmm1
  unpckhpd %xmm4,%xmm4
  addsd  %xmm2,%xmm6
  addsd  %xmm5,%xmm10
  addsd  %xmm11,%xmm1
  unpckhpd %xmm5,%xmm5
  addsd  %xmm8,%xmm7
  addsd  %xmm10,%xmm5
  addsd  %xmm4,%xmm1
  addsd  %xmm3,%xmm5
  addsd  %xmm0,%xmm1
  unpckhpd %xmm3,%xmm3
  unpckhpd %xmm0,%xmm0
  addsd  %xmm3,%xmm5
  addsd  %xmm0,%xmm1
  movapd %xmm5,%xmm10
  movapd %xmm1,%xmm11
  cmp    %ecx,%r9d
  jb     L66
  mov    %ecx,%eax
  mov    %rax,%rdx
  imul   %rsi,%rax
  shl    $0x7,%rdx
  add    %rdi,%rdx
  add    %r8,%rax
L70:
  movsd  (%rdx),%xmm1
  movsd  0x20(%rax),%xmm3
  movsd  0x8(%rdx),%xmm0
  movsd  (%rax),%xmm2
  movapd %xmm1,%xmm8
  mulsd  %xmm2,%xmm8
  mulsd  %xmm3,%xmm1
  mulsd  %xmm0,%xmm2
  mulsd  %xmm3,%xmm0
  movsd  0x8(%rax),%xmm3
  addsd  %xmm7,%xmm8
  movapd %xmm1,%xmm4
  movapd %xmm2,%xmm5
  movsd  0x20(%rdx),%xmm2
  addsd  %xmm6,%xmm4
  movsd  0x28(%rax),%xmm6
  movapd %xmm0,%xmm1
  movsd  0x28(%rdx),%xmm0
  addsd  %xmm10,%xmm5
  movapd %xmm2,%xmm7
  addsd  %xmm11,%xmm1
  mulsd  %xmm6,%xmm2
  mulsd  %xmm3,%xmm7
  mulsd  %xmm0,%xmm3
  mulsd  %xmm6,%xmm0
  addsd  %xmm2,%xmm4
  movsd  0x40(%rdx),%xmm2
  addsd  %xmm8,%xmm7
  movsd  0x30(%rax),%xmm8
  addsd  %xmm3,%xmm5
  movsd  0x10(%rax),%xmm3
  movapd %xmm2,%xmm6
  addsd  %xmm0,%xmm1
  movsd  0x48(%rdx),%xmm0
  mulsd  %xmm8,%xmm2
  mulsd  %xmm3,%xmm6
  mulsd  %xmm0,%xmm3
  mulsd  %xmm8,%xmm0
  addsd  %xmm2,%xmm4
  movsd  0x60(%rdx),%xmm2
  addsd  %xmm7,%xmm6
  movsd  0x38(%rax),%xmm7
  addsd  %xmm3,%xmm5
  movsd  0x18(%rax),%xmm3
  movapd %xmm2,%xmm8
  lea    0x1(%rcx),%eax
  mulsd  %xmm7,%xmm2
  imul   %rax,%rsi
  addsd  %xmm1,%xmm0
  mov    %rax,%rcx
  movsd  0x68(%rdx),%xmm1
  mulsd  %xmm3,%xmm8
  mov    %rax,%rdx
  shl    $0x2,%ecx
  shl    $0x7,%rdx
  mulsd  %xmm1,%xmm3
  add    %rdx,%rdi
  add    %rsi,%r8
  mulsd  %xmm7,%xmm1
  addsd  %xmm4,%xmm2
  addsd  %xmm6,%xmm8
  addsd  %xmm5,%xmm3
  addsd  %xmm0,%xmm1
L160:
  cmp    %ecx,%r10d
  jle    L58
  lea    -0x1(%r10),%eax
  sub    %ecx,%eax
  cmp    $0x1,%eax
  jbe    L142
  movupd (%rdi),%xmm0
  movupd 0x20(%rdi),%xmm4
  and    $0xfffffffe,%eax
  movupd 0x30(%rdi),%xmm5
  movlpd 0x28(%rdi),%xmm5
  mov    %eax,%edx
  add    %eax,%ecx
  movhpd 0x30(%rdi),%xmm4
  movhpd 0x10(%rdi),%xmm0
  movupd 0x20(%r8),%xmm7
  mov    %rdx,%rsi
  unpcklpd %xmm4,%xmm0
  movupd 0x10(%rdi),%xmm4
  movlpd 0x8(%rdi),%xmm4
  shl    $0x5,%rsi
  add    %rsi,%rdi
  unpcklpd %xmm5,%xmm4
  movupd (%r8),%xmm5
  mulpd  %xmm0,%xmm5
  mulpd  %xmm7,%xmm0
  movapd %xmm5,%xmm6
  unpckhpd %xmm5,%xmm5
  addsd  %xmm8,%xmm6
  addsd  %xmm0,%xmm2
  unpckhpd %xmm0,%xmm0
  addsd  %xmm6,%xmm5
  addsd  %xmm0,%xmm2
  movapd %xmm7,%xmm0
  mulpd  %xmm4,%xmm0
  movapd %xmm5,%xmm8
  movupd (%r8),%xmm5
  lea    (%r8,%rdx,8),%r8
  mulpd  %xmm4,%xmm5
  addsd  %xmm0,%xmm1
  unpckhpd %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  addsd  %xmm5,%xmm3
  unpckhpd %xmm5,%xmm5
  addsd  %xmm5,%xmm3
L142:
  movsd  (%r8),%xmm5
  movsd  (%rdi),%xmm4
  add    $0x1,%ecx
  movsd  0x8(%rdi),%xmm0
  movsd  0x20(%r8),%xmm6
  movapd %xmm5,%xmm7
  mulsd  %xmm4,%xmm7
  mulsd  %xmm0,%xmm5
  mulsd  %xmm6,%xmm4
  mulsd  %xmm6,%xmm0
  addsd  %xmm7,%xmm8
  addsd  %xmm5,%xmm3
  addsd  %xmm4,%xmm2
  addsd  %xmm0,%xmm1
  cmp    %r10d,%ecx
  jge    L58
  movsd  0x8(%r8),%xmm5
  movsd  0x20(%rdi),%xmm4
  movsd  0x28(%rdi),%xmm6
  movsd  0x28(%r8),%xmm0
  movapd %xmm5,%xmm7
  mulsd  %xmm4,%xmm7
  mulsd  %xmm6,%xmm5
  mulsd  %xmm0,%xmm4
  mulsd  %xmm6,%xmm0
  addsd  %xmm7,%xmm8
  addsd  %xmm5,%xmm3
  addsd  %xmm4,%xmm2
  addsd  %xmm0,%xmm1
L58:
  test   %r13d,%r13d
  je     L97
  mov    0x40(%rsp),%edx
  movsd  (%r12),%xmm6
  movsd  0x8(%r12),%xmm0
  movsd  0x20(%r12),%xmm4
  movsd  0x28(%r12),%xmm5
  test   %edx,%edx
  jne    L31
  movq   %xmm0,%rax
  movapd %xmm4,%xmm0
  movq   %rax,%xmm4
L31:
  cmp    $0x1,%r13d
  je     L88
  subsd  %xmm8,%xmm6
  subsd  %xmm3,%xmm4
  subsd  %xmm2,%xmm0
  subsd  %xmm1,%xmm5
  movapd %xmm6,%xmm8
  movapd %xmm4,%xmm3
  movapd %xmm0,%xmm2
  movapd %xmm5,%xmm1
L97:
  mov    0x48(%rsp),%eax
  movsd  %xmm8,0x0(%rbp)
  test   %eax,%eax
  jne    L151
  cmp    $0x1,%r11d
  jle    L16
  movsd  %xmm3,0x8(%rbp)
  cmp    $0x1,%ebx
  jle    L48
  movsd  %xmm2,0x20(%rbp)
  movsd  %xmm1,0x28(%rbp)
L48:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L151:
  cmp    $0x1,%ebx
  jle    L148
  movsd  %xmm2,0x8(%rbp)
  cmp    $0x1,%r11d
  jle    L48
  movsd  %xmm3,0x20(%rbp)
  movsd  %xmm1,0x28(%rbp)
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L16:
  cmp    $0x1,%ebx
  jle    L48
  movsd  %xmm2,0x20(%rbp)
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L148:
  cmp    $0x1,%r11d
  jle    L48
  movsd  %xmm3,0x20(%rbp)
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L88:
  addsd  %xmm6,%xmm8
  addsd  %xmm4,%xmm3
  addsd  %xmm0,%xmm2
  addsd  %xmm5,%xmm1
  jmp    L97
  xchg   %ax,%ax
L101:
  pxor   %xmm1,%xmm1
  xor    %ecx,%ecx
  movapd %xmm1,%xmm3
  movapd %xmm1,%xmm2
  movapd %xmm1,%xmm8
  jmp    L160
L134:
  pxor   %xmm11,%xmm11
  mov    %r8,%rax
  mov    %rdi,%rdx
  movapd %xmm11,%xmm10
  movapd %xmm11,%xmm6
  movapd %xmm11,%xmm7
  jmp    L70
```

assistant: ```c
void kernel_dgemm_nn_2x2_vs_lib4(int km, int kn, int kmax, double *A, double *B, int sdb, int alg, double *C, double *D, int tc, int td) {
  const int bs = 4;
  int k;
  double a_0, a_1, b_0, b_1, c_00 = 0, c_01 = 0, c_10 = 0, c_11 = 0;
  for (k = 0; k < kmax - 3; k += 4) {
    a_0 = A[0 + bs * 0];
    a_1 = A[1 + bs * 0];
    b_0 = B[0 + bs * 0];
    b_1 = B[0 + bs * 1];
    c_00 += a_0 * b_0;
    c_10 += a_1 * b_0;
    c_01 += a_0 * b_1;
    c_11 += a_1 * b_1;
    a_0 = A[0 + bs * 1];
    a_1 = A[1 + bs * 1];
    b_0 = B[1 + bs * 0];
    b_1 = B[1 + bs * 1];
    c_00 += a_0 * b_0;
    c_10 += a_1 * b_0;
    c_01 += a_0 * b_1;
    c_11 += a_1 * b_1;
    a_0 = A[0 + bs * 2];
    a_1 = A[1 + bs * 2];
    b_0 = B[2 + bs * 0];
    b_1 = B[2 + bs * 1];
    c_00 += a_0 * b_0;
    c_10 += a_1 * b_0;
    c_01 += a_0 * b_1;
    c_11 += a_1 * b_1;
    a_0 = A[0 + bs * 3];
    a_1 = A[1 + bs * 3];
    b_0 = B[3 + bs * 0];
    b_1 = B[3 + bs * 1];
    c_00 += a_0 * b_0;
    c_10 += a_1 * b_0;
    c_01 += a_0 * b_1;
    c_11 += a_1 * b_1;
    A += 16;
    B += 4 * sdb;
  }
  for (; k < kmax; k++) {
    a_0 = A[0 + bs * 0];
    a_1 = A[1 + bs * 0];
    b_0 = B[0 + bs * 0];
    b_1 = B[0 + bs * 1];
    c_00 += a_0 * b_0;
    c_10 += a_1 * b_0;
    c_01 += a_0 * b_1;
    c_11 += a_1 * b_1;
    A += 4;
    B += 1;
  }
  double d_00, d_01, d_10, d_11;
  if (alg == 0) {
    if (td == 0) {
      goto store_n;
    } else {
      goto store_t;
    }
  } else {
    if (tc == 0) {
      d_00 = C[0 + bs * 0];
      d_10 = C[1 + bs * 0];
      d_01 = C[0 + bs * 1];
      d_11 = C[1 + bs * 1];
    } else {
      d_00 = C[0 + bs * 0];
      d_01 = C[1 + bs * 0];
      d_10 = C[0 + bs * 1];
      d_11 = C[1 + bs * 1];
    }
    if (alg == 1) {
      c_00 = d_00 + c_00;
      c_10 = d_10 + c_10;
      c_01 = d_01 + c_01;
      c_11 = d_11 + c_11;
    } else {
      c_00 = d_00 - c_00;
      c_10 = d_10 - c_10;
      c_01 = d_01 - c_01;
      c_11 = d_11 - c_11;
    }
    if (td == 0) {
      goto store_n;
    } else {
      goto store_t;
    }
  }
store_n:
  if (km >= 2) {
    D[0 + bs * 0] = c_00;
    D[1 + bs * 0] = c_10;
    if (kn >= 2) {
      D[0 + bs * 1] = c_01;
      D[1 + bs * 1] = c_11;
    }
  } else {
    D[0 + bs * 0] = c_00;
    if (kn >= 2) {
      D[0 + bs * 1] = c_01;
    }
  }
  return;
store_t:
  if (kn >= 2) {
    D[0 + bs * 0] = c_00;
    D[1 + bs * 0] = c_01;
    if (km >= 2) {
      D[0 + bs * 1] = c_10;
      D[1 + bs * 1] = c_11;
    }
  } else {
    D[0 + bs * 0] = c_00;
    if (km >= 2) {
      D[0 + bs * 1] = c_10;
    }
  }
  return;
}
```