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

```asm
<kernel_dgemm_diag_left_4_lib4>:
  endbr64
  mov    %rsi,%r10
  mov    %rdx,%rax
  mov    %rcx,%rsi
  test   %edi,%edi
  jle    L121
  cmp    $0xffffffff,%r9d
  je     L88
  movsd  (%r10),%xmm0
  movsd  0x8(%r10),%xmm3
  movsd  0x10(%r10),%xmm2
  movsd  0x18(%r10),%xmm1
  test   %r9d,%r9d
  jne    L13
  cmp    $0x3,%edi
  jle    L92
  lea    -0x4(%rdi),%r9d
  shr    $0x2,%r9d
  lea    0x1(%r9),%esi
  mov    %esi,%esi
  shl    $0x7,%rsi
  lea    (%rdx,%rsi,1),%rcx
  mov    %r8,%rdx
L101:
  movapd %xmm3,%xmm6
  mulsd  0x8(%rax),%xmm6
  movapd %xmm2,%xmm5
  mulsd  0x10(%rax),%xmm5
  movapd %xmm1,%xmm4
  mulsd  0x18(%rax),%xmm4
  movapd %xmm0,%xmm7
  mulsd  (%rax),%xmm7
  movsd  %xmm7,(%rdx)
  movsd  %xmm6,0x8(%rdx)
  movsd  %xmm5,0x10(%rdx)
  movsd  %xmm4,0x18(%rdx)
  movapd %xmm3,%xmm6
  mulsd  0x28(%rax),%xmm6
  movapd %xmm2,%xmm5
  mulsd  0x30(%rax),%xmm5
  movapd %xmm1,%xmm4
  mulsd  0x38(%rax),%xmm4
  movapd %xmm0,%xmm7
  mulsd  0x20(%rax),%xmm7
  movsd  %xmm7,0x20(%rdx)
  movsd  %xmm6,0x28(%rdx)
  movsd  %xmm5,0x30(%rdx)
  movsd  %xmm4,0x38(%rdx)
  movapd %xmm3,%xmm6
  mulsd  0x48(%rax),%xmm6
  movapd %xmm2,%xmm5
  mulsd  0x50(%rax),%xmm5
  movapd %xmm1,%xmm4
  mulsd  0x58(%rax),%xmm4
  movapd %xmm0,%xmm7
  mulsd  0x40(%rax),%xmm7
  movsd  %xmm7,0x40(%rdx)
  movsd  %xmm6,0x48(%rdx)
  movsd  %xmm5,0x50(%rdx)
  movsd  %xmm4,0x58(%rdx)
  movapd %xmm3,%xmm6
  mulsd  0x68(%rax),%xmm6
  movapd %xmm2,%xmm5
  mulsd  0x70(%rax),%xmm5
  movapd %xmm1,%xmm4
  mulsd  0x78(%rax),%xmm4
  movapd %xmm0,%xmm7
  mulsd  0x60(%rax),%xmm7
  movsd  %xmm7,0x60(%rdx)
  movsd  %xmm6,0x68(%rdx)
  movsd  %xmm5,0x70(%rdx)
  movsd  %xmm4,0x78(%rdx)
  sub    $0xffffffffffffff80,%rax
  sub    $0xffffffffffffff80,%rdx
  cmp    %rcx,%rax
  jne    L101
  add    %rsi,%r8
  lea    0x4(,%r9,4),%r9d
  cmp    %r9d,%edi
  jle    L120
L46:
  movapd %xmm3,%xmm6
  mulsd  0x8(%rcx),%xmm6
  movapd %xmm2,%xmm5
  mulsd  0x10(%rcx),%xmm5
  movapd %xmm1,%xmm4
  mulsd  0x18(%rcx),%xmm4
  movapd %xmm0,%xmm7
  mulsd  (%rcx),%xmm7
  movsd  %xmm7,(%r8)
  movsd  %xmm6,0x8(%r8)
  movsd  %xmm5,0x10(%r8)
  movsd  %xmm4,0x18(%r8)
  add    $0x20,%rcx
  add    $0x20,%r8
  add    $0x1,%r9d
  cmp    %r9d,%edi
  jg     L46
  ret
L88:
  movsd  (%r10),%xmm0
  movq   D5(%rip),%xmm4
  xorpd  %xmm4,%xmm0
  movsd  0x8(%r10),%xmm3
  xorpd  %xmm4,%xmm3
  movsd  0x10(%r10),%xmm2
  xorpd  %xmm4,%xmm2
  movsd  0x18(%r10),%xmm1
  xorpd  %xmm4,%xmm1
L13:
  cmp    $0x3,%edi
  jle    L3
  lea    -0x4(%rdi),%r11d
  shr    $0x2,%r11d
  lea    0x1(%r11),%r10d
  mov    %r10d,%r10d
  shl    $0x7,%r10
  lea    (%rax,%r10,1),%r9
  mov    %r8,%rcx
  mov    %rsi,%rdx
L59:
  movapd %xmm3,%xmm6
  mulsd  0x8(%rax),%xmm6
  addsd  0x8(%rdx),%xmm6
  movapd %xmm2,%xmm5
  mulsd  0x10(%rax),%xmm5
  addsd  0x10(%rdx),%xmm5
  movapd %xmm1,%xmm4
  mulsd  0x18(%rax),%xmm4
  addsd  0x18(%rdx),%xmm4
  movapd %xmm0,%xmm7
  mulsd  (%rax),%xmm7
  addsd  (%rdx),%xmm7
  movsd  %xmm7,(%rcx)
  movsd  %xmm6,0x8(%rcx)
  movsd  %xmm5,0x10(%rcx)
  movsd  %xmm4,0x18(%rcx)
  movapd %xmm3,%xmm6
  mulsd  0x28(%rax),%xmm6
  addsd  0x28(%rdx),%xmm6
  movapd %xmm2,%xmm5
  mulsd  0x30(%rax),%xmm5
  addsd  0x30(%rdx),%xmm5
  movapd %xmm1,%xmm4
  mulsd  0x38(%rax),%xmm4
  addsd  0x38(%rdx),%xmm4
  movapd %xmm0,%xmm7
  mulsd  0x20(%rax),%xmm7
  addsd  0x20(%rdx),%xmm7
  movsd  %xmm7,0x20(%rcx)
  movsd  %xmm6,0x28(%rcx)
  movsd  %xmm5,0x30(%rcx)
  movsd  %xmm4,0x38(%rcx)
  movapd %xmm3,%xmm6
  mulsd  0x48(%rax),%xmm6
  addsd  0x48(%rdx),%xmm6
  movapd %xmm2,%xmm5
  mulsd  0x50(%rax),%xmm5
  addsd  0x50(%rdx),%xmm5
  movapd %xmm1,%xmm4
  mulsd  0x58(%rax),%xmm4
  addsd  0x58(%rdx),%xmm4
  movapd %xmm0,%xmm7
  mulsd  0x40(%rax),%xmm7
  addsd  0x40(%rdx),%xmm7
  movsd  %xmm7,0x40(%rcx)
  movsd  %xmm6,0x48(%rcx)
  movsd  %xmm5,0x50(%rcx)
  movsd  %xmm4,0x58(%rcx)
  movapd %xmm3,%xmm6
  mulsd  0x68(%rax),%xmm6
  addsd  0x68(%rdx),%xmm6
  movapd %xmm2,%xmm5
  mulsd  0x70(%rax),%xmm5
  addsd  0x70(%rdx),%xmm5
  movapd %xmm1,%xmm4
  mulsd  0x78(%rax),%xmm4
  addsd  0x78(%rdx),%xmm4
  movapd %xmm0,%xmm7
  mulsd  0x60(%rax),%xmm7
  addsd  0x60(%rdx),%xmm7
  movsd  %xmm7,0x60(%rcx)
  movsd  %xmm6,0x68(%rcx)
  movsd  %xmm5,0x70(%rcx)
  movsd  %xmm4,0x78(%rcx)
  sub    $0xffffffffffffff80,%rax
  sub    $0xffffffffffffff80,%rdx
  sub    $0xffffffffffffff80,%rcx
  cmp    %r9,%rax
  jne    L59
  add    %r10,%rsi
  add    %r10,%r8
  lea    0x4(,%r11,4),%eax
  cmp    %eax,%edi
  jle    L121
L97:
  movapd %xmm3,%xmm6
  mulsd  0x8(%r9),%xmm6
  addsd  0x8(%rsi),%xmm6
  movapd %xmm2,%xmm5
  mulsd  0x10(%r9),%xmm5
  addsd  0x10(%rsi),%xmm5
  movapd %xmm1,%xmm4
  mulsd  0x18(%r9),%xmm4
  addsd  0x18(%rsi),%xmm4
  movapd %xmm0,%xmm7
  mulsd  (%r9),%xmm7
  addsd  (%rsi),%xmm7
  movsd  %xmm7,(%r8)
  movsd  %xmm6,0x8(%r8)
  movsd  %xmm5,0x10(%r8)
  movsd  %xmm4,0x18(%r8)
  add    $0x20,%r9
  add    $0x20,%rsi
  add    $0x20,%r8
  add    $0x1,%eax
  cmp    %eax,%edi
  jg     L97
L121:
  ret
L3:
  mov    %rax,%r9
  mov    $0x0,%eax
  jmp    L97
L120:
  ret
L92:
  mov    %rdx,%rcx
  jmp    L46
```

tool_calls: name: unpack_data
arguments: tag: D5
type_infered: byte[8]

tool: {"D5": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80]}

assistant: ```c
void kernel_dgemm_diag_left_4_lib4(int kmax, double *A, double *B, double *C, double *D, int alg) {
  if (kmax <= 0)
    return;
  const int bs = 4;
  int k;
  double a_0, a_1, a_2, a_3, b_0, b_1, b_2, b_3, c_0, c_1, c_2, c_3;
  if (alg == -1) {
    a_0 = -A[0];
    a_1 = -A[1];
    a_2 = -A[2];
    a_3 = -A[3];
  } else {
    a_0 = A[0];
    a_1 = A[1];
    a_2 = A[2];
    a_3 = A[3];
  }
  if (alg == 0) {
    for (k = 0; k < kmax - 3; k += 4) {
      b_0 = B[0 + bs * 0];
      b_1 = B[1 + bs * 0];
      b_2 = B[2 + bs * 0];
      b_3 = B[3 + bs * 0];
      c_0 = a_0 * b_0;
      c_1 = a_1 * b_1;
      c_2 = a_2 * b_2;
      c_3 = a_3 * b_3;
      D[0 + bs * 0] = c_0;
      D[1 + bs * 0] = c_1;
      D[2 + bs * 0] = c_2;
      D[3 + bs * 0] = c_3;
      b_0 = B[0 + bs * 1];
      b_1 = B[1 + bs * 1];
      b_2 = B[2 + bs * 1];
      b_3 = B[3 + bs * 1];
      c_0 = a_0 * b_0;
      c_1 = a_1 * b_1;
      c_2 = a_2 * b_2;
      c_3 = a_3 * b_3;
      D[0 + bs * 1] = c_0;
      D[1 + bs * 1] = c_1;
      D[2 + bs * 1] = c_2;
      D[3 + bs * 1] = c_3;
      b_0 = B[0 + bs * 2];
      b_1 = B[1 + bs * 2];
      b_2 = B[2 + bs * 2];
      b_3 = B[3 + bs * 2];
      c_0 = a_0 * b_0;
      c_1 = a_1 * b_1;
      c_2 = a_2 * b_2;
      c_3 = a_3 * b_3;
      D[0 + bs * 2] = c_0;
      D[1 + bs * 2] = c_1;
      D[2 + bs * 2] = c_2;
      D[3 + bs * 2] = c_3;
      b_0 = B[0 + bs * 3];
      b_1 = B[1 + bs * 3];
      b_2 = B[2 + bs * 3];
      b_3 = B[3 + bs * 3];
      c_0 = a_0 * b_0;
      c_1 = a_1 * b_1;
      c_2 = a_2 * b_2;
      c_3 = a_3 * b_3;
      D[0 + bs * 3] = c_0;
      D[1 + bs * 3] = c_1;
      D[2 + bs * 3] = c_2;
      D[3 + bs * 3] = c_3;
      B += 16;
      D += 16;
    }
    for (; k < kmax; k++) {
      b_0 = B[0 + bs * 0];
      b_1 = B[1 + bs * 0];
      b_2 = B[2 + bs * 0];
      b_3 = B[3 + bs * 0];
      c_0 = a_0 * b_0;
      c_1 = a_1 * b_1;
      c_2 = a_2 * b_2;
      c_3 = a_3 * b_3;
      D[0 + bs * 0] = c_0;
      D[1 + bs * 0] = c_1;
      D[2 + bs * 0] = c_2;
      D[3 + bs * 0] = c_3;
      B += 4;
      D += 4;
    }
  } else {
    for (k = 0; k < kmax - 3; k += 4) {
      b_0 = B[0 + bs * 0];
      b_1 = B[1 + bs * 0];
      b_2 = B[2 + bs * 0];
      b_3 = B[3 + bs * 0];
      c_0 = C[0 + bs * 0] + a_0 * b_0;
      c_1 = C[1 + bs * 0] + a_1 * b_1;
      c_2 = C[2 + bs * 0] + a_2 * b_2;
      c_3 = C[3 + bs * 0] + a_3 * b_3;
      D[0 + bs * 0] = c_0;
      D[1 + bs * 0] = c_1;
      D[2 + bs * 0] = c_2;
      D[3 + bs * 0] = c_3;
      b_0 = B[0 + bs * 1];
      b_1 = B[1 + bs * 1];
      b_2 = B[2 + bs * 1];
      b_3 = B[3 + bs * 1];
      c_0 = C[0 + bs * 1] + a_0 * b_0;
      c_1 = C[1 + bs * 1] + a_1 * b_1;
      c_2 = C[2 + bs * 1] + a_2 * b_2;
      c_3 = C[3 + bs * 1] + a_3 * b_3;
      D[0 + bs * 1] = c_0;
      D[1 + bs * 1] = c_1;
      D[2 + bs * 1] = c_2;
      D[3 + bs * 1] = c_3;
      b_0 = B[0 + bs * 2];
      b_1 = B[1 + bs * 2];
      b_2 = B[2 + bs * 2];
      b_3 = B[3 + bs * 2];
      c_0 = C[0 + bs * 2] + a_0 * b_0;
      c_1 = C[1 + bs * 2] + a_1 * b_1;
      c_2 = C[2 + bs * 2] + a_2 * b_2;
      c_3 = C[3 + bs * 2] + a_3 * b_3;
      D[0 + bs * 2] = c_0;
      D[1 + bs * 2] = c_1;
      D[2 + bs * 2] = c_2;
      D[3 + bs * 2] = c_3;
      b_0 = B[0 + bs * 3];
      b_1 = B[1 + bs * 3];
      b_2 = B[2 + bs * 3];
      b_3 = B[3 + bs * 3];
      c_0 = C[0 + bs * 3] + a_0 * b_0;
      c_1 = C[1 + bs * 3] + a_1 * b_1;
      c_2 = C[2 + bs * 3] + a_2 * b_2;
      c_3 = C[3 + bs * 3] + a_3 * b_3;
      D[0 + bs * 3] = c_0;
      D[1 + bs * 3] = c_1;
      D[2 + bs * 3] = c_2;
      D[3 + bs * 3] = c_3;
      B += 16;
      C += 16;
      D += 16;
    }
    for (; k < kmax; k++) {
      b_0 = B[0 + bs * 0];
      b_1 = B[1 + bs * 0];
      b_2 = B[2 + bs * 0];
      b_3 = B[3 + bs * 0];
      c_0 = C[0 + bs * 0] + a_0 * b_0;
      c_1 = C[1 + bs * 0] + a_1 * b_1;
      c_2 = C[2 + bs * 0] + a_2 * b_2;
      c_3 = C[3 + bs * 0] + a_3 * b_3;
      D[0 + bs * 0] = c_0;
      D[1 + bs * 0] = c_1;
      D[2 + bs * 0] = c_2;
      D[3 + bs * 0] = c_3;
      B += 4;
      C += 4;
      D += 4;
    }
  }
}
```