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

```asm
<kernel_dgema_3_lib4>:
  endbr64
  push   %rbx
  mov    %esi,%ebx
  mov    %rdx,%rsi
  mov    %ecx,%r10d
  test   %ebx,%ebx
  je     L51
  cmp    $0x1,%ebx
  je     L77
  cmp    $0x2,%ebx
  je     L106
  lea    -0x3(%rdi),%r11d
  mov    $0x0,%eax
  test   %r11d,%r11d
  jle    L120
  shl    $0x2,%r9d
  movslq %r9d,%r9
  shl    $0x3,%r9
  shl    $0x2,%r10d
  movslq %r10d,%r10
  shl    $0x3,%r10
  mov    %r8,%rdx
  mov    %rsi,%rax
  mov    $0x0,%ecx
L215:
  movsd  (%rax),%xmm0
  movsd  %xmm0,0x8(%rdx)
  movsd  0x8(%rax),%xmm0
  movsd  %xmm0,0x10(%rdx)
  movsd  0x10(%rax),%xmm0
  movsd  %xmm0,0x18(%rdx)
  movsd  0x20(%rax),%xmm0
  movsd  %xmm0,0x28(%rdx)
  movsd  0x28(%rax),%xmm0
  movsd  %xmm0,0x30(%rdx)
  movsd  0x30(%rax),%xmm0
  movsd  %xmm0,0x38(%rdx)
  movsd  0x40(%rax),%xmm0
  movsd  %xmm0,0x48(%rdx)
  movsd  0x48(%rax),%xmm0
  movsd  %xmm0,0x50(%rdx)
  movsd  0x50(%rax),%xmm0
  movsd  %xmm0,0x58(%rdx)
  add    %r9,%rdx
  movsd  0x18(%rax),%xmm0
  movsd  %xmm0,(%rdx)
  movsd  0x38(%rax),%xmm0
  movsd  %xmm0,0x20(%rdx)
  movsd  0x58(%rax),%xmm0
  movsd  %xmm0,0x40(%rdx)
  add    %r10,%rax
  add    $0x4,%ecx
  cmp    %r11d,%ecx
  jl     L215
  lea    -0x4(%rdi),%eax
  shr    $0x2,%eax
  add    $0x1,%eax
  mov    %eax,%edx
  imul   %rdx,%r9
  add    %r9,%r8
  imul   %rdx,%r10
  add    %r10,%rsi
  shl    $0x2,%eax
L120:
  cmp    %eax,%edi
  jle    L72
  movsd  (%rsi),%xmm0
  movsd  %xmm0,0x8(%r8)
  movsd  0x20(%rsi),%xmm0
  movsd  %xmm0,0x28(%r8)
  movsd  0x40(%rsi),%xmm0
  movsd  %xmm0,0x48(%r8)
  lea    0x1(%rax),%edx
  cmp    %edx,%edi
  je     L72
  movsd  0x8(%rsi),%xmm0
  movsd  %xmm0,0x10(%r8)
  movsd  0x28(%rsi),%xmm0
  movsd  %xmm0,0x30(%r8)
  movsd  0x48(%rsi),%xmm0
  movsd  %xmm0,0x50(%r8)
  add    $0x2,%eax
  cmp    %eax,%edi
  je     L72
  movsd  0x10(%rsi),%xmm0
  movsd  %xmm0,0x18(%r8)
  movsd  0x30(%rsi),%xmm0
  movsd  %xmm0,0x38(%r8)
  movsd  0x50(%rsi),%xmm0
  movsd  %xmm0,0x58(%r8)
  jmp    L72
L51:
  lea    -0x3(%rdi),%r11d
  test   %r11d,%r11d
  jle    L249
  shl    $0x2,%r10d
  movslq %r10d,%r10
  shl    $0x3,%r10
  lea    0x0(,%r9,4),%ecx
  movslq %ecx,%rcx
  shl    $0x3,%rcx
  mov    %r8,%rdx
  mov    %rsi,%rax
L133:
  movsd  (%rax),%xmm0
  movsd  %xmm0,(%rdx)
  movsd  0x8(%rax),%xmm0
  movsd  %xmm0,0x8(%rdx)
  movsd  0x10(%rax),%xmm0
  movsd  %xmm0,0x10(%rdx)
  movsd  0x18(%rax),%xmm0
  movsd  %xmm0,0x18(%rdx)
  movsd  0x20(%rax),%xmm0
  movsd  %xmm0,0x20(%rdx)
  movsd  0x28(%rax),%xmm0
  movsd  %xmm0,0x28(%rdx)
  movsd  0x30(%rax),%xmm0
  movsd  %xmm0,0x30(%rdx)
  movsd  0x38(%rax),%xmm0
  movsd  %xmm0,0x38(%rdx)
  movsd  0x40(%rax),%xmm0
  movsd  %xmm0,0x40(%rdx)
  movsd  0x48(%rax),%xmm0
  movsd  %xmm0,0x48(%rdx)
  movsd  0x50(%rax),%xmm0
  movsd  %xmm0,0x50(%rdx)
  movsd  0x58(%rax),%xmm0
  movsd  %xmm0,0x58(%rdx)
  add    %r10,%rax
  add    %rcx,%rdx
  add    $0x4,%ebx
  cmp    %r11d,%ebx
  jl     L133
  lea    -0x4(%rdi),%ebx
  shr    $0x2,%ebx
  add    $0x1,%ebx
  mov    %ebx,%edx
  mov    %r10,%rax
  imul   %rdx,%rax
  add    %rax,%rsi
  imul   %rdx,%rcx
  add    %rcx,%r8
  shl    $0x2,%ebx
L249:
  cmp    %ebx,%edi
  jle    L72
  sub    $0x1,%edi
  sub    %ebx,%edi
  lea    0x8(%rsi,%rdi,8),%rax
L124:
  movsd  (%rsi),%xmm0
  movsd  %xmm0,(%r8)
  movsd  0x20(%rsi),%xmm0
  movsd  %xmm0,0x20(%r8)
  movsd  0x40(%rsi),%xmm0
  movsd  %xmm0,0x40(%r8)
  add    $0x8,%rsi
  add    $0x8,%r8
  cmp    %rax,%rsi
  jne    L124
L72:
  pop    %rbx
  ret
L77:
  lea    -0x3(%rdi),%ebx
  test   %ebx,%ebx
  jle    L30
  lea    0x0(,%r9,4),%r11d
  movslq %r11d,%r11
  shl    $0x3,%r11
  shl    $0x2,%r10d
  movslq %r10d,%r10
  shl    $0x3,%r10
  mov    %r8,%rdx
  mov    %rsi,%rax
  mov    $0x0,%ecx
L22:
  movsd  (%rax),%xmm0
  movsd  %xmm0,0x18(%rdx)
  movsd  0x20(%rax),%xmm0
  movsd  %xmm0,0x38(%rdx)
  movsd  0x40(%rax),%xmm0
  movsd  %xmm0,0x58(%rdx)
  add    %r11,%rdx
  movsd  0x8(%rax),%xmm0
  movsd  %xmm0,(%rdx)
  movsd  0x10(%rax),%xmm0
  movsd  %xmm0,0x8(%rdx)
  movsd  0x18(%rax),%xmm0
  movsd  %xmm0,0x10(%rdx)
  movsd  0x28(%rax),%xmm0
  movsd  %xmm0,0x20(%rdx)
  movsd  0x30(%rax),%xmm0
  movsd  %xmm0,0x28(%rdx)
  movsd  0x38(%rax),%xmm0
  movsd  %xmm0,0x30(%rdx)
  movsd  0x48(%rax),%xmm0
  movsd  %xmm0,0x40(%rdx)
  movsd  0x50(%rax),%xmm0
  movsd  %xmm0,0x48(%rdx)
  movsd  0x58(%rax),%xmm0
  movsd  %xmm0,0x50(%rdx)
  add    %r10,%rax
  add    $0x4,%ecx
  cmp    %ebx,%ecx
  jl     L22
  lea    -0x4(%rdi),%eax
  shr    $0x2,%eax
  add    $0x1,%eax
  mov    %eax,%edx
  imul   %rdx,%r11
  add    %r11,%r8
  imul   %rdx,%r10
  add    %r10,%rsi
  shl    $0x2,%eax
L27:
  cmp    %eax,%edi
  jle    L72
  movsd  (%rsi),%xmm0
  movsd  %xmm0,0x18(%r8)
  movsd  0x20(%rsi),%xmm0
  movsd  %xmm0,0x38(%r8)
  movsd  0x40(%rsi),%xmm0
  movsd  %xmm0,0x58(%r8)
  lea    0x1(%rax),%edx
  cmp    %edx,%edi
  je     L72
  lea    0x0(,%r9,4),%ecx
  movslq %ecx,%rcx
  lea    (%r8,%rcx,8),%rdx
  movsd  0x8(%rsi),%xmm0
  movsd  %xmm0,(%rdx)
  movsd  0x28(%rsi),%xmm0
  movsd  %xmm0,0x20(%rdx)
  movsd  0x48(%rsi),%xmm0
  movsd  %xmm0,0x40(%rdx)
  add    $0x2,%eax
  cmp    %eax,%edi
  je     L72
  movsd  0x10(%rsi),%xmm0
  movsd  %xmm0,0x8(%rdx)
  movsd  0x30(%rsi),%xmm0
  movsd  %xmm0,0x28(%rdx)
  movsd  0x50(%rsi),%xmm0
  movsd  %xmm0,0x48(%rdx)
  jmp    L72
L30:
  mov    $0x0,%eax
  jmp    L27
L106:
  lea    -0x3(%rdi),%ebx
  test   %ebx,%ebx
  jle    L67
  lea    0x0(,%r9,4),%r11d
  movslq %r11d,%r11
  shl    $0x3,%r11
  shl    $0x2,%r10d
  movslq %r10d,%rcx
  shl    $0x3,%rcx
  mov    %r8,%rdx
  mov    %rsi,%rax
  mov    $0x0,%r10d
L243:
  movsd  (%rax),%xmm0
  movsd  %xmm0,0x10(%rdx)
  movsd  0x8(%rax),%xmm0
  movsd  %xmm0,0x18(%rdx)
  movsd  0x20(%rax),%xmm0
  movsd  %xmm0,0x30(%rdx)
  movsd  0x28(%rax),%xmm0
  movsd  %xmm0,0x38(%rdx)
  movsd  0x40(%rax),%xmm0
  movsd  %xmm0,0x50(%rdx)
  movsd  0x48(%rax),%xmm0
  movsd  %xmm0,0x58(%rdx)
  add    %r11,%rdx
  movsd  0x10(%rax),%xmm0
  movsd  %xmm0,(%rdx)
  movsd  0x18(%rax),%xmm0
  movsd  %xmm0,0x8(%rdx)
  movsd  0x30(%rax),%xmm0
  movsd  %xmm0,0x20(%rdx)
  movsd  0x38(%rax),%xmm0
  movsd  %xmm0,0x28(%rdx)
  movsd  0x50(%rax),%xmm0
  movsd  %xmm0,0x40(%rdx)
  movsd  0x58(%rax),%xmm0
  movsd  %xmm0,0x48(%rdx)
  add    %rcx,%rax
  add    $0x4,%r10d
  cmp    %ebx,%r10d
  jl     L243
  lea    -0x4(%rdi),%eax
  shr    $0x2,%eax
  add    $0x1,%eax
  mov    %eax,%edx
  imul   %rdx,%r11
  add    %r11,%r8
  imul   %rdx,%rcx
  add    %rcx,%rsi
  shl    $0x2,%eax
L260:
  cmp    %eax,%edi
  jle    L72
  movsd  (%rsi),%xmm0
  movsd  %xmm0,0x10(%r8)
  movsd  0x20(%rsi),%xmm0
  movsd  %xmm0,0x30(%r8)
  movsd  0x40(%rsi),%xmm0
  movsd  %xmm0,0x50(%r8)
  lea    0x1(%rax),%edx
  cmp    %edx,%edi
  je     L72
  movsd  0x8(%rsi),%xmm0
  movsd  %xmm0,0x18(%r8)
  movsd  0x28(%rsi),%xmm0
  movsd  %xmm0,0x38(%r8)
  movsd  0x48(%rsi),%xmm0
  movsd  %xmm0,0x58(%r8)
  add    $0x2,%eax
  cmp    %eax,%edi
  je     L72
  lea    0x0(,%r9,4),%ecx
  movslq %ecx,%rcx
  lea    (%r8,%rcx,8),%rax
  movsd  0x18(%rsi),%xmm0
  movsd  %xmm0,(%rax)
  movsd  0x38(%rsi),%xmm0
  movsd  %xmm0,0x20(%rax)
  movsd  0x58(%rsi),%xmm0
  movsd  %xmm0,0x40(%rax)
  jmp    L72
L67:
  mov    $0x0,%eax
  jmp    L260
```

assistant: ```c
void kernel_dgema_3_lib4(int kmax, int kna, double *A, int sda, double *C, int sdc) {
  const int bs = 4;
  int k;
  if (kna == 0) {
    k = 0;
    for (; k < kmax - 3; k += 4) {
      C[0 + bs * 0] = A[0 + bs * 0];
      C[1 + bs * 0] = A[1 + bs * 0];
      C[2 + bs * 0] = A[2 + bs * 0];
      C[3 + bs * 0] = A[3 + bs * 0];
      C[0 + bs * 1] = A[0 + bs * 1];
      C[1 + bs * 1] = A[1 + bs * 1];
      C[2 + bs * 1] = A[2 + bs * 1];
      C[3 + bs * 1] = A[3 + bs * 1];
      C[0 + bs * 2] = A[0 + bs * 2];
      C[1 + bs * 2] = A[1 + bs * 2];
      C[2 + bs * 2] = A[2 + bs * 2];
      C[3 + bs * 2] = A[3 + bs * 2];
      A += bs * sda;
      C += bs * sdc;
    }
    for (; k < kmax; k++) {
      C[0 + bs * 0] = A[0 + bs * 0];
      C[0 + bs * 1] = A[0 + bs * 1];
      C[0 + bs * 2] = A[0 + bs * 2];
      A += 1;
      C += 1;
    }
    return;
  } else if (kna == 1) {
    k = 0;
    for (; k < kmax - 3; k += 4) {
      C[3 + bs * 0] = A[0 + bs * 0];
      C[3 + bs * 1] = A[0 + bs * 1];
      C[3 + bs * 2] = A[0 + bs * 2];
      C += bs * sdc;
      C[0 + bs * 0] = A[1 + bs * 0];
      C[1 + bs * 0] = A[2 + bs * 0];
      C[2 + bs * 0] = A[3 + bs * 0];
      C[0 + bs * 1] = A[1 + bs * 1];
      C[1 + bs * 1] = A[2 + bs * 1];
      C[2 + bs * 1] = A[3 + bs * 1];
      C[0 + bs * 2] = A[1 + bs * 2];
      C[1 + bs * 2] = A[2 + bs * 2];
      C[2 + bs * 2] = A[3 + bs * 2];
      A += bs * sda;
    }
    if (k >= kmax) {
      return;
    }
    C[3 + bs * 0] = A[0 + bs * 0];
    C[3 + bs * 1] = A[0 + bs * 1];
    C[3 + bs * 2] = A[0 + bs * 2];
    k++;
    if (k == kmax) {
      return;
    }
    C += bs * sdc;
    C[0 + bs * 0] = A[1 + bs * 0];
    C[0 + bs * 1] = A[1 + bs * 1];
    C[0 + bs * 2] = A[1 + bs * 2];
    k++;
    if (k == kmax) {
      return;
    }
    C[1 + bs * 0] = A[2 + bs * 0];
    C[1 + bs * 1] = A[2 + bs * 1];
    C[1 + bs * 2] = A[2 + bs * 2];
    return;
  } else if (kna == 2) {
    k = 0;
    for (; k < kmax - 3; k += 4) {
      C[2 + bs * 0] = A[0 + bs * 0];
      C[3 + bs * 0] = A[1 + bs * 0];
      C[2 + bs * 1] = A[0 + bs * 1];
      C[3 + bs * 1] = A[1 + bs * 1];
      C[2 + bs * 2] = A[0 + bs * 2];
      C[3 + bs * 2] = A[1 + bs * 2];
      C += bs * sdc;
      C[0 + bs * 0] = A[2 + bs * 0];
      C[1 + bs * 0] = A[3 + bs * 0];
      C[0 + bs * 1] = A[2 + bs * 1];
      C[1 + bs * 1] = A[3 + bs * 1];
      C[0 + bs * 2] = A[2 + bs * 2];
      C[1 + bs * 2] = A[3 + bs * 2];
      A += bs * sda;
    }
    if (k >= kmax) {
      return;
    }
    C[2 + bs * 0] = A[0 + bs * 0];
    C[2 + bs * 1] = A[0 + bs * 1];
    C[2 + bs * 2] = A[0 + bs * 2];
    k++;
    if (k == kmax) {
      return;
    }
    C[3 + bs * 0] = A[1 + bs * 0];
    C[3 + bs * 1] = A[1 + bs * 1];
    C[3 + bs * 2] = A[1 + bs * 2];
    k++;
    if (k == kmax) {
      return;
    }
    C += bs * sdc;
    C[0 + bs * 0] = A[3 + bs * 0];
    C[0 + bs * 1] = A[3 + bs * 1];
    C[0 + bs * 2] = A[3 + bs * 2];
    return;
  } else {
    k = 0;
    for (; k < kmax - 3; k += 4) {
      C[1 + bs * 0] = A[0 + bs * 0];
      C[2 + bs * 0] = A[1 + bs * 0];
      C[3 + bs * 0] = A[2 + bs * 0];
      C[1 + bs * 1] = A[0 + bs * 1];
      C[2 + bs * 1] = A[1 + bs * 1];
      C[3 + bs * 1] = A[2 + bs * 1];
      C[1 + bs * 2] = A[0 + bs * 2];
      C[2 + bs * 2] = A[1 + bs * 2];
      C[3 + bs * 2] = A[2 + bs * 2];
      C += bs * sdc;
      C[0 + bs * 0] = A[3 + bs * 0];
      C[0 + bs * 1] = A[3 + bs * 1];
      C[0 + bs * 2] = A[3 + bs * 2];
      A += bs * sda;
    }
    if (k >= kmax) {
      return;
    }
    C[1 + bs * 0] = A[0 + bs * 0];
    C[1 + bs * 1] = A[0 + bs * 1];
    C[1 + bs * 2] = A[0 + bs * 2];
    k++;
    if (k == kmax) {
      return;
    }
    C[2 + bs * 0] = A[1 + bs * 0];
    C[2 + bs * 1] = A[1 + bs * 1];
    C[2 + bs * 2] = A[1 + bs * 2];
    k++;
    if (k == kmax) {
      return;
    }
    C[3 + bs * 0] = A[2 + bs * 0];
    C[3 + bs * 1] = A[2 + bs * 1];
    C[3 + bs * 2] = A[2 + bs * 2];
    return;
  }
}
```