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    %esi,%r10d
  mov    %edx,%r11d
  mov    %rcx,%rax
  push   %r12
  push   %rbp
  push   %rbx
  mov    0x28(%rsp),%r12d
  mov    0x30(%rsp),%rbp
  mov    0x38(%rsp),%rbx
  cmp    $0x3,%edx
  jle    L30
  lea    -0x4(%rdx),%edx
  shl    $0x2,%r9d
  pxor   %xmm0,%xmm0
  shr    $0x2,%edx
  movapd %xmm0,%xmm2
  movapd %xmm0,%xmm3
  movslq %r9d,%rsi
  lea    0x1(%rdx),%r13d
  shl    $0x3,%rsi
  movapd %xmm0,%xmm6
  mov    %r8,%rdx
  mov    %r13,%rcx
  mov    %r13,%r9
  shl    $0x7,%rcx
  add    %rax,%rcx
L142:
  movsd  (%rax),%xmm4
  movsd  0x8(%rax),%xmm1
  sub    $0xffffffffffffff80,%rax
  movsd  (%rdx),%xmm5
  movsd  0x20(%rdx),%xmm8
  movapd %xmm4,%xmm7
  mulsd  %xmm5,%xmm7
  mulsd  %xmm1,%xmm5
  mulsd  %xmm8,%xmm4
  mulsd  %xmm8,%xmm1
  movsd  0x28(%rdx),%xmm8
  addsd  %xmm6,%xmm7
  addsd  %xmm2,%xmm5
  movsd  -0x60(%rax),%xmm2
  addsd  %xmm3,%xmm4
  movsd  0x8(%rdx),%xmm3
  addsd  %xmm0,%xmm1
  movsd  -0x58(%rax),%xmm0
  movapd %xmm2,%xmm6
  mulsd  %xmm8,%xmm2
  mulsd  %xmm3,%xmm6
  mulsd  %xmm0,%xmm3
  mulsd  %xmm8,%xmm0
  movsd  0x30(%rdx),%xmm8
  addsd  %xmm2,%xmm4
  movsd  -0x40(%rax),%xmm2
  addsd  %xmm7,%xmm6
  addsd  %xmm3,%xmm5
  movsd  0x10(%rdx),%xmm3
  movapd %xmm2,%xmm7
  addsd  %xmm0,%xmm1
  movsd  -0x38(%rax),%xmm0
  mulsd  %xmm8,%xmm2
  mulsd  %xmm3,%xmm7
  mulsd  %xmm0,%xmm3
  mulsd  %xmm8,%xmm0
  movsd  0x38(%rdx),%xmm8
  addsd  %xmm2,%xmm4
  movsd  0x18(%rdx),%xmm2
  add    %rsi,%rdx
  addsd  %xmm6,%xmm7
  addsd  %xmm3,%xmm5
  movsd  -0x20(%rax),%xmm3
  addsd  %xmm0,%xmm1
  movsd  -0x18(%rax),%xmm0
  movapd %xmm3,%xmm6
  mulsd  %xmm2,%xmm6
  mulsd  %xmm8,%xmm3
  mulsd  %xmm0,%xmm2
  mulsd  %xmm8,%xmm0
  addsd  %xmm7,%xmm6
  addsd  %xmm4,%xmm3
  addsd  %xmm5,%xmm2
  addsd  %xmm1,%xmm0
  cmp    %rcx,%rax
  jne    L142
  imul   %r13,%rsi
  lea    0x0(,%r9,4),%edx
  add    %rsi,%r8
L125:
  cmp    %edx,%r11d
  jle    L136
  lea    -0x1(%r11),%eax
  sub    %edx,%eax
  lea    0x8(%r8,%rax,8),%rax
L111:
  movsd  (%rcx),%xmm4
  movsd  0x8(%rcx),%xmm1
  add    $0x8,%r8
  add    $0x20,%rcx
  movsd  -0x8(%r8),%xmm5
  movsd  0x18(%r8),%xmm7
  movapd %xmm4,%xmm8
  mulsd  %xmm5,%xmm8
  mulsd  %xmm7,%xmm4
  mulsd  %xmm1,%xmm5
  mulsd  %xmm7,%xmm1
  addsd  %xmm8,%xmm6
  addsd  %xmm4,%xmm3
  addsd  %xmm5,%xmm2
  addsd  %xmm1,%xmm0
  cmp    %rax,%r8
  jne    L111
L136:
  test   %r12d,%r12d
  je     L100
  mov    0x40(%rsp),%edx
  movsd  0x0(%rbp),%xmm7
  movsd  0x8(%rbp),%xmm1
  movsd  0x20(%rbp),%xmm4
  movsd  0x28(%rbp),%xmm5
  test   %edx,%edx
  jne    L69
  movq   %xmm1,%rax
  movapd %xmm4,%xmm1
  movq   %rax,%xmm4
L69:
  cmp    $0x1,%r12d
  je     L146
  subsd  %xmm6,%xmm7
  subsd  %xmm2,%xmm4
  subsd  %xmm3,%xmm1
  subsd  %xmm0,%xmm5
  movapd %xmm7,%xmm6
  movapd %xmm4,%xmm2
  movapd %xmm1,%xmm3
  movapd %xmm5,%xmm0
L100:
  mov    0x48(%rsp),%eax
  movsd  %xmm6,(%rbx)
  test   %eax,%eax
  jne    L92
  cmp    $0x1,%edi
  jle    L104
  movsd  %xmm2,0x8(%rbx)
  cmp    $0x1,%r10d
  jle    L119
  movsd  %xmm3,0x20(%rbx)
  movsd  %xmm0,0x28(%rbx)
L119:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax,%rax,1)
L92:
  cmp    $0x1,%r10d
  jle    L10
  movsd  %xmm3,0x8(%rbx)
  cmp    $0x1,%edi
  jle    L119
  movsd  %xmm2,0x20(%rbx)
  movsd  %xmm0,0x28(%rbx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L10:
  cmp    $0x1,%edi
  jle    L119
  movsd  %xmm2,0x20(%rbx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L104:
  cmp    $0x1,%r10d
  jle    L119
  movsd  %xmm3,0x20(%rbx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L146:
  addsd  %xmm7,%xmm6
  addsd  %xmm4,%xmm2
  addsd  %xmm1,%xmm3
  addsd  %xmm5,%xmm0
  jmp    L100
  nopl   (%rax)
L30:
  pxor   %xmm0,%xmm0
  xor    %edx,%edx
  movapd %xmm0,%xmm2
  movapd %xmm0,%xmm3
  movapd %xmm0,%xmm6
  jmp    L125
```

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;
}
```