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

```asm
<kernel_dgetr_3_lib4>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edx,%r10d
  cmp    $0x1,%edi
  sete   %al
  movzbl %al,%eax
  lea    (%rsi,%rax,1),%r11d
  mov    $0x0,%ebx
  cmp    %edx,%r11d
  jl     L25
  test   %edx,%edx
  jle    L99
  lea    -0x1(%rdx),%esi
  add    $0x1,%rsi
  mov    %rsi,%rax
  shl    $0x5,%rax
  add    %rcx,%rax
  mov    %r8,%rdx
L50:
  movsd  (%rcx),%xmm0
  movsd  %xmm0,(%rdx)
  movsd  0x8(%rcx),%xmm0
  movsd  %xmm0,0x20(%rdx)
  movsd  0x10(%rcx),%xmm0
  movsd  %xmm0,0x40(%rdx)
  add    $0x8,%rdx
  add    $0x20,%rcx
  cmp    %rax,%rcx
  jne    L50
  lea    -0x4(,%r9,4),%edx
  movslq %edx,%rdx
  add    %rsi,%rdx
  lea    (%r8,%rdx,8),%r8
  mov    %r10d,%ebx
L38:
  lea    -0x3(%r11),%edx
  cmp    %edx,%ebx
  jge    L74
  lea    0x0(,%r9,4),%esi
  movslq %esi,%rsi
  shl    $0x3,%rsi
  lea    -0x4(%r11),%ebp
  sub    %ebx,%ebp
  shr    $0x2,%ebp
  lea    0x1(%rbp),%r12d
  mov    %r12d,%r12d
  mov    %r12,%rcx
  shl    $0x7,%rcx
  add    %rax,%rcx
  mov    %r8,%rdx
L89:
  movsd  (%rax),%xmm0
  movsd  %xmm0,(%rdx)
  movsd  0x8(%rax),%xmm0
  movsd  %xmm0,0x20(%rdx)
  movsd  0x10(%rax),%xmm0
  movsd  %xmm0,0x40(%rdx)
  movsd  0x20(%rax),%xmm0
  movsd  %xmm0,0x8(%rdx)
  movsd  0x28(%rax),%xmm0
  movsd  %xmm0,0x28(%rdx)
  movsd  0x30(%rax),%xmm0
  movsd  %xmm0,0x48(%rdx)
  movsd  0x40(%rax),%xmm0
  movsd  %xmm0,0x10(%rdx)
  movsd  0x48(%rax),%xmm0
  movsd  %xmm0,0x30(%rdx)
  movsd  0x50(%rax),%xmm0
  movsd  %xmm0,0x50(%rdx)
  movsd  0x60(%rax),%xmm0
  movsd  %xmm0,0x18(%rdx)
  movsd  0x68(%rax),%xmm0
  movsd  %xmm0,0x38(%rdx)
  movsd  0x70(%rax),%xmm0
  movsd  %xmm0,0x58(%rdx)
  add    %rsi,%rdx
  sub    $0xffffffffffffff80,%rax
  cmp    %rcx,%rax
  jne    L89
  imul   %r12,%rsi
  add    %rsi,%r8
  lea    0x4(%rbx,%rbp,4),%ebx
L25:
  mov    %r8,%rdx
  cmp    %ebx,%r11d
  jle    L67
  lea    -0x1(%r11),%esi
  sub    %ebx,%esi
  add    $0x1,%rsi
  lea    (%r8,%rsi,8),%rdx
  mov    %rcx,%rax
L28:
  movsd  (%rax),%xmm0
  movsd  %xmm0,(%r8)
  movsd  0x8(%rax),%xmm0
  movsd  %xmm0,0x20(%r8)
  movsd  0x10(%rax),%xmm0
  movsd  %xmm0,0x40(%r8)
  add    $0x8,%r8
  add    $0x20,%rax
  cmp    %rdx,%r8
  jne    L28
  shl    $0x5,%rsi
  add    %rsi,%rcx
L67:
  cmp    $0x1,%edi
  je     L126
L33:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L74:
  mov    %rax,%rcx
  jmp    L25
L99:
  mov    %rcx,%rax
  mov    $0x0,%ebx
  jmp    L38
L126:
  mov    $0x4,%eax
  mov    %eax,%esi
  sub    %r10d,%esi
  add    %r11d,%esi
  mov    %esi,%edi
  sar    $0x1f,%edi
  shr    $0x1e,%edi
  add    %edi,%esi
  and    $0x3,%esi
  sub    %edi,%esi
  sub    %esi,%eax
  mov    %eax,%esi
  sar    $0x1f,%esi
  shr    $0x1e,%esi
  add    %esi,%eax
  and    $0x3,%eax
  sub    %esi,%eax
  cmp    $0x1,%eax
  je     L60
  movsd  0x8(%rcx),%xmm0
  movsd  %xmm0,0x20(%rdx)
  movsd  0x10(%rcx),%xmm0
  movsd  %xmm0,0x40(%rdx)
  movsd  0x30(%rcx),%xmm0
  movsd  %xmm0,0x48(%rdx)
  jmp    L33
L60:
  movsd  0x8(%rcx),%xmm0
  movsd  %xmm0,0x20(%rdx)
  movsd  0x10(%rcx),%xmm0
  movsd  %xmm0,0x40(%rdx)
  movsd  0x30(%rcx),%xmm0
  lea    0x5(,%r9,4),%eax
  cltq
  movsd  %xmm0,(%rdx,%rax,8)
  jmp    L33
```

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