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

```asm
<matmul>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %edi,%r12d
  mov    %rsi,0x10(%rsp)
  mov    %rdx,%r15
  mov    %rdx,0x20(%rsp)
  mov    %rcx,0x18(%rsp)
  mov    %edi,%ebx
  shr    $0x1f,%ebx
  add    %edi,%ebx
  sar    %ebx
  imul   %edi,%edi
  shl    $0x3,%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  mov    %rax,%rdx
  mov    %r15,%rsi
  mov    %r12d,%edi
  call   <transpose@plt>
  cmp    $0x1,%r12d
  jle    L45
  movslq %r12d,%rsi
  shl    $0x3,%rsi
  lea    0x8(%rsi),%rdi
  lea    (%r12,%r12,1),%eax
  cltq
  mov    %rax,0x8(%rsp)
  mov    $0x0,%r14d
  mov    $0x0,%r15d
  mov    %r12d,0x2c(%rsp)
L89:
  lea    0x0(,%r14,8),%r13
  mov    0x18(%rsp),%rax
  lea    (%rax,%r13,1),%rdx
  add    0x10(%rsp),%r13
  mov    $0x0,%r12d
  mov    $0x0,%r11d
L73:
  lea    0x0(%rbp,%r12,8),%rcx
  mov    %r13,%rax
  mov    $0x0,%r8d
L118:
  movsd  (%rax),%xmm0
  mulsd  (%rcx),%xmm0
  movsd  0x8(%rax),%xmm1
  mulsd  0x8(%rcx),%xmm1
  addsd  %xmm1,%xmm0
  addsd  (%rdx),%xmm0
  movsd  %xmm0,(%rdx)
  lea    (%rsi,%rcx,1),%r10
  lea    (%rdi,%rcx,1),%r9
  movsd  (%rax),%xmm0
  mulsd  (%r10),%xmm0
  movsd  0x8(%rax),%xmm1
  mulsd  (%r9),%xmm1
  addsd  %xmm1,%xmm0
  addsd  0x8(%rdx),%xmm0
  movsd  %xmm0,0x8(%rdx)
  movsd  (%rax,%rsi,1),%xmm0
  mulsd  (%rcx),%xmm0
  movsd  (%rax,%rdi,1),%xmm1
  mulsd  0x8(%rcx),%xmm1
  addsd  %xmm1,%xmm0
  addsd  (%rdx,%rsi,1),%xmm0
  movsd  %xmm0,(%rdx,%rsi,1)
  movsd  (%rax,%rsi,1),%xmm0
  mulsd  (%r10),%xmm0
  movsd  (%rax,%rdi,1),%xmm1
  mulsd  (%r9),%xmm1
  addsd  %xmm1,%xmm0
  addsd  (%rdx,%rdi,1),%xmm0
  movsd  %xmm0,(%rdx,%rdi,1)
  add    $0x1,%r8d
  add    $0x10,%rax
  add    $0x10,%rcx
  cmp    %r8d,%ebx
  jg     L118
  add    $0x1,%r11d
  add    0x8(%rsp),%r12
  add    $0x10,%rdx
  cmp    %r11d,%ebx
  jg     L73
  add    $0x1,%r15d
  add    0x8(%rsp),%r14
  cmp    %r15d,%ebx
  jg     L89
  mov    0x2c(%rsp),%r12d
  lea    -0x1(%r12),%r9d
  test   $0x1,%r12b
  je     L128
L182:
  lea    -0x1(%r12),%ebp
  mov    %r9d,%eax
  imul   %r12d,%eax
  cltq
  mov    0x20(%rsp),%rbx
  lea    (%rbx,%rax,8),%rbx
  mov    $0x0,%edi
  mov    $0x0,%r8d
  lea    -0x2(%r12),%r11d
  mov    0x18(%rsp),%r14
  lea    0x8(%r14),%r10
  mov    0x10(%rsp),%r13
  jmp    L153
L45:
  test   $0x1,%r12b
  je     L128
  lea    -0x1(%r12),%r9d
  test   %r9d,%r9d
  jg     L182
L64:
  test   %r12d,%r12d
  jle    L103
  movslq %r12d,%rdi
  shl    $0x3,%rdi
  mov    0x18(%rsp),%rax
  lea    (%rax,%rdi,1),%rcx
  lea    -0x1(%r12),%eax
  mov    0x10(%rsp),%rbx
  lea    0x8(%rbx,%rax,8),%rsi
  mov    0x20(%rsp),%rax
  lea    (%rax,%rdi,1),%r11
  mov    $0x0,%r8d
  mov    %r12d,%r10d
  neg    %r10
  shl    $0x3,%r10
  jmp    L40
L195:
  add    $0x1,%r8d
  add    %r12d,%edi
  cmp    %ebp,%r8d
  je     L64
L153:
  lea    (%r12,%rdi,1),%eax
  cltq
  lea    -0x8(%r13,%rax,8),%rsi
  movslq %edi,%rdx
  lea    (%r14,%rdx,8),%rax
  add    %r11,%rdx
  lea    (%r10,%rdx,8),%rcx
  mov    %rbx,%rdx
L22:
  movsd  (%rsi),%xmm0
  mulsd  (%rdx),%xmm0
  addsd  (%rax),%xmm0
  movsd  %xmm0,(%rax)
  add    $0x8,%rax
  add    $0x8,%rdx
  cmp    %rcx,%rax
  jne    L22
  jmp    L195
L62:
  add    $0x1,%r8d
  add    %rdi,%rcx
  add    %rdi,%rsi
  cmp    %r8d,%r12d
  je     L103
L40:
  lea    (%r10,%rsi,1),%rax
  mov    %r11,%rdx
L212:
  movsd  (%rax),%xmm0
  mulsd  -0x8(%rdx),%xmm0
  addsd  -0x8(%rcx),%xmm0
  movsd  %xmm0,-0x8(%rcx)
  add    $0x8,%rax
  add    %rdi,%rdx
  cmp    %rsi,%rax
  jne    L212
  jmp    L62
L103:
  test   %r9d,%r9d
  jle    L128
  imul   %r12d,%r9d
  mov    0x20(%rsp),%r10
  lea    -0x1(%r12),%r11d
  movslq %r9d,%rdx
  mov    0x10(%rsp),%rdi
  lea    (%rdi,%rdx,8),%rbx
  movslq %r12d,%rsi
  shl    $0x3,%rsi
  mov    %r11d,%eax
  add    %rdx,%rax
  lea    0x8(%rdi,%rax,8),%rdi
  mov    $0x0,%r8d
  mov    0x18(%rsp),%rbp
  jmp    L165
L163:
  add    $0x1,%r8d
  add    $0x8,%r10
  cmp    %r11d,%r8d
  je     L128
L165:
  test   %r12d,%r12d
  jle    L163
  lea    (%r8,%r9,1),%eax
  cltq
  lea    0x0(%rbp,%rax,8),%rcx
  mov    %r10,%rdx
  mov    %rbx,%rax
L12:
  movsd  (%rax),%xmm0
  mulsd  (%rdx),%xmm0
  addsd  (%rcx),%xmm0
  movsd  %xmm0,(%rcx)
  add    $0x8,%rax
  add    %rsi,%rdx
  cmp    %rax,%rdi
  jne    L12
  jmp    L163
L128:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void matmul(int i_matdim, const double *pd_A, const double *pd_B, double *pd_C) {
  int i, j, k;
  int n = 2;
  int N = i_matdim;
  int Ntiles = N / n;
  double *A = pd_A;
  double *B = (double *)malloc(i_matdim * i_matdim * sizeof(double));
  double *C = pd_C;
  transpose(i_matdim, pd_B, B);
  for (i = 0; i < Ntiles; i++)
    for (j = 0; j < Ntiles; j++)
      for (k = 0; k < Ntiles; k++) {
        double *bA = A + i * n * N + k * n;
        double *bB = B + j * n * N + k * n;
        double *bC = C + i * n * N + j * n;
        bC[0] += bA[0] * bB[0] + bA[1] * bB[1];
        bC[1] += bA[0] * bB[N] + bA[1] * bB[N + 1];
        bC[N] += bA[N] * bB[0] + bA[N + 1] * bB[1];
        bC[N + 1] += bA[N] * bB[N] + bA[N + 1] * bB[N + 1];
      }
  if ((i_matdim & 1) == 0)
    return;
  for (i = 0; i < N - 1; i++)
    for (j = 0; j < N - 1; j++) {
      C[i * N + j] += A[i * N + N - 1] * pd_B[(N - 1) * N + j];
    }
  for (i = 0; i < N; i++)
    for (k = 0; k < N; k++)
      C[i * N + N - 1] += A[i * N + k] * pd_B[k * N + N - 1];
  for (i = 0; i < N - 1; i++)
    for (k = 0; k < N; k++)
      C[(N - 1) * N + i] += A[(N - 1) * N + k] * pd_B[k * N + i];
}
```