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

```asm
<dmat_as_ddmatrix>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x78,%rsp
  mov    0x8(%rdi),%r14d
  mov    0x4(%rdi),%r15d
  mov    %rdx,0x48(%rsp)
  lea    0x50(%rsp),%rsi
  lea    0x54(%rsp),%rdx
  mov    0x14(%rdi),%ebx
  mov    0xc(%rdi),%r13d
  mov    %fs:0x28,%rax
  mov    %rax,0x68(%rsp)
  xor    %eax,%eax
  mov    0x10(%rdi),%eax
  mov    %r14d,0x8(%rsp)
  mov    %r15d,0x10(%rsp)
  mov    %eax,0x24(%rsp)
  call   <dmat_ldimget@plt>
  mov    0x50(%rsp),%r11d
  test   %r11d,%r11d
  jle    L189
  mov    0x54(%rsp),%r10d
  test   %r10d,%r10d
  jle    L189
  lea    0x60(%rsp),%rcx
  lea    0x5c(%rsp),%rdx
  mov    %r15d,%edi
  lea    0x58(%rsp),%rsi
  lea    0x64(%rsp),%r8
  call   <Cblacs_gridinfo@plt>
  mov    0x60(%rsp),%ecx
  mov    0x64(%rsp),%eax
  or     %ecx,%eax
  mov    %eax,0x44(%rsp)
  test   %r14d,%r14d
  jle    L17
  movslq 0x24(%rsp),%rax
  mov    0x8(%rsp),%esi
  mov    %rbp,0x30(%rsp)
  xor    %r12d,%r12d
  movl   $0x0,0x2c(%rsp)
  shl    $0x3,%rax
  mov    %esi,0x28(%rsp)
  mov    %rax,0x38(%rsp)
  mov    %esi,%eax
  imul   %ebx,%eax
  movl   $0x0,0x40(%rsp)
  movl   $0x0,0x20(%rsp)
  cltq
  shl    $0x3,%rax
  mov    %rax,0x18(%rsp)
  xchg   %ax,%ax
L80:
  mov    0x28(%rsp),%eax
  mov    0x24(%rsp),%r15d
  cmp    %r15d,%eax
  cmovle %eax,%r15d
  test   %r13d,%r13d
  jle    L61
  mov    0x44(%rsp),%r9d
  mov    %r13d,%r14d
  test   %r9d,%r9d
  je     L123
  xor    %r10d,%r10d
  xor    %ebp,%ebp
  nopl   0x0(%rax,%rax,1)
L176:
  cmp    %ebx,%r14d
  mov    %ebx,%r11d
  cmovle %r14d,%r11d
  cmp    0x60(%rsp),%r12d
  je     L143
  add    %ebx,%ebp
  cmp    %ebp,%r13d
  jle    L38
L116:
  add    %ebx,%ebp
  cmp    %r13d,%ebp
  jl     L116
L38:
  mov    0x60(%rsp),%ecx
L61:
  cmp    %ecx,%r12d
  je     L236
  lea    0x1(%r12),%eax
  mov    0x24(%rsp),%edi
  add    %edi,0x20(%rsp)
  cltd
  sub    %edi,0x28(%rsp)
  mov    0x20(%rsp),%esi
  idivl  0x58(%rsp)
  mov    0x38(%rsp),%rdi
  add    %rdi,0x30(%rsp)
  mov    %edx,%r12d
  cmp    %esi,0x8(%rsp)
  jg     L80
L17:
  xor    %eax,%eax
L169:
  mov    0x68(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L129
  add    $0x78,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L143:
  cmp    %r10d,0x64(%rsp)
  je     L223
L199:
  lea    0x1(%r10),%eax
  add    %ebx,%ebp
  cltd
  idivl  0x5c(%rsp)
  mov    %edx,%r10d
  cmp    %ebp,%r13d
  jle    L38
  sub    %ebx,%r14d
  jmp    L176
  xchg   %ax,%ax
L223:
  mov    0x50(%rsp),%r8d
  mov    0x2c(%rsp),%eax
  sub    $0x8,%rsp
  mov    %r11d,%edx
  mov    0x50(%rsp),%rcx
  mov    %r10d,0x14(%rsp)
  xor    %r9d,%r9d
  mov    %r15d,%esi
  imul   %r8d,%eax
  add    0x48(%rsp),%eax
  push   $0x0
  cltq
  mov    0x20(%rsp),%edi
  lea    (%rcx,%rax,8),%rcx
  mov    %r11d,0x14(%rsp)
  call   <Cdgerv2d@plt>
  mov    0x3c(%rsp),%eax
  mov    0x14(%rsp),%r11d
  add    %r11d,%eax
  cltd
  idivl  0x64(%rsp)
  mov    %edx,0x3c(%rsp)
  pop    %rdi
  pop    %r8
  mov    0xc(%rsp),%r10d
  jmp    L199
  nopl   (%rax)
L236:
  mov    0x40(%rsp),%eax
  mov    0x24(%rsp),%esi
  add    %esi,0x20(%rsp)
  mov    0x20(%rsp),%edi
  add    %r15d,%eax
  sub    %esi,0x28(%rsp)
  mov    0x38(%rsp),%rsi
  cltd
  add    %rsi,0x30(%rsp)
  idivl  0x50(%rsp)
  lea    0x1(%r12),%eax
  mov    %edx,0x40(%rsp)
  cltd
  idivl  0x58(%rsp)
  mov    %edx,%r12d
  cmp    %edi,0x8(%rsp)
  jg     L80
  jmp    L17
  cs nopw 0x0(%rax,%rax,1)
L123:
  mov    0x30(%rsp),%r11
  xor    %r10d,%r10d
  mov    %r15d,0xc(%rsp)
  xor    %ebp,%ebp
  mov    %r13d,0x14(%rsp)
  mov    %r10d,%r15d
  mov    %r11,%r13
  jmp    L131
  nopl   0x0(%rax)
L21:
  lea    0x1(%rbp),%eax
  add    %ebx,%r15d
  sub    %ebx,%r14d
  add    0x18(%rsp),%r13
  cltd
  idivl  0x5c(%rsp)
  mov    %edx,%ebp
  cmp    %r15d,0x14(%rsp)
  jle    L25
L131:
  cmp    %ebx,%r14d
  mov    %ebx,%edx
  mov    %r13,%rcx
  mov    %r12d,%r9d
  cmovle %r14d,%edx
  sub    $0x8,%rsp
  push   %rbp
  mov    0x18(%rsp),%r8d
  mov    0x1c(%rsp),%esi
  mov    0x20(%rsp),%edi
  mov    %edx,0x14(%rsp)
  call   <Cdgesd2d@plt>
  pop    %rcx
  pop    %rsi
  cmp    %r12d,0x60(%rsp)
  mov    0x4(%rsp),%edx
  jne    L21
  cmp    %ebp,0x64(%rsp)
  jne    L21
  mov    0x50(%rsp),%r8d
  mov    0x2c(%rsp),%eax
  sub    $0x8,%rsp
  xor    %r9d,%r9d
  mov    0x50(%rsp),%rcx
  imul   %r8d,%eax
  add    0x48(%rsp),%eax
  push   $0x0
  cltq
  mov    0x1c(%rsp),%esi
  mov    0x20(%rsp),%edi
  lea    (%rcx,%rax,8),%rcx
  mov    %edx,0x14(%rsp)
  call   <Cdgerv2d@plt>
  mov    0x3c(%rsp),%eax
  mov    0x14(%rsp),%edx
  add    %edx,%eax
  cltd
  idivl  0x64(%rsp)
  mov    %edx,0x3c(%rsp)
  pop    %rax
  pop    %rdx
  jmp    L21
  nopl   (%rax)
L25:
  mov    0xc(%rsp),%r15d
  mov    0x14(%rsp),%r13d
  jmp    L38
L189:
  mov    $0xffffffff,%eax
  jmp    L169
L129:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int dmat_as_ddmatrix(int *desc, double *A_global, double *A_local) {
  const int M = desc[2], N = desc[3];
  const int Mb = desc[4], Nb = desc[5];
  int nrows, ncols;
  int row, col;
  int recvr = 0, recvc = 0;
  int ictxt = desc[1];
  int nprow, npcol;
  int myprow, mypcol;
  int rdest = 0, cdest = 0;
  int nr, nc;
  dmat_ldimget(desc, &nrows, &ncols);
  if (nrows < 1 || ncols < 1)
    return -1;
  Cblacs_gridinfo(ictxt, &nprow, &npcol, &myprow, &mypcol);
  const int owner = (myprow == 0 && mypcol == 0);
  for (row = 0; row < M; row += Mb, rdest = (rdest + 1) % nprow) {
    cdest = 0;
    nr = Mb;
    if (M - row < Mb)
      nr = M - row;
    for (col = 0; col < N; col += Nb, cdest = (cdest + 1) % npcol) {
      nc = Nb;
      if (N - col < Nb)
        nc = N - col;
      if (owner) {
        Cdgesd2d(ictxt, nr, nc, A_global + (row + M * col), M, rdest, cdest);
      }
      if (myprow == rdest && mypcol == cdest) {
        Cdgerv2d(ictxt, nr, nc, A_local + (recvr + nrows * recvc), nrows, 0, 0);
        recvc = (recvc + nc) % ncols;
      }
    }
    if (myprow == rdest)
      recvr = (recvr + nr) % nrows;
  }
  return 0;
}
```