user: 请从给定的汇编指令推导出C源代码：

```asm
<dmat_as_ddmatrix>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    0x8(%rdi),%ebx
  mov    0x4(%rdi),%r14d
  mov    0xc(%rdi),%ebp
  mov    0x14(%rdi),%r12d
  mov    %rsi,0x20(%rsp)
  lea    0x40(%rsp),%rsi
  mov    %rdx,0x38(%rsp)
  lea    0x44(%rsp),%rdx
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  mov    0x10(%rdi),%eax
  mov    %ebx,0x18(%rsp)
  mov    %r14d,0x1c(%rsp)
  mov    %eax,0x28(%rsp)
  call   <dmat_ldimget@plt>
  mov    0x40(%rsp),%r8d
  test   %r8d,%r8d
  jle    L2
  mov    0x44(%rsp),%edi
  test   %edi,%edi
  jle    L2
  lea    0x50(%rsp),%rcx
  lea    0x4c(%rsp),%rdx
  mov    %r14d,%edi
  lea    0x48(%rsp),%rsi
  lea    0x54(%rsp),%r8
  call   <Cblacs_gridinfo@plt>
  mov    0x50(%rsp),%r11d
  or     0x54(%rsp),%r11d
  test   %ebx,%ebx
  jle    L13
  mov    0x18(%rsp),%eax
  xor    %r15d,%r15d
  mov    %ebp,%r10d
  movl   $0x0,0x30(%rsp)
  movl   $0x0,0x34(%rsp)
  mov    %eax,0x2c(%rsp)
  imul   %r12d,%eax
  movl   $0x0,0x14(%rsp)
  mov    %eax,(%rsp)
  xchg   %ax,%ax
L126:
  mov    0x2c(%rsp),%eax
  mov    0x28(%rsp),%esi
  cmp    %esi,%eax
  cmovle %eax,%esi
  test   %r10d,%r10d
  jle    L118
  mov    0x14(%rsp),%r14d
  mov    %r10d,%ebp
  xor    %ebx,%ebx
  xor    %r13d,%r13d
  jmp    L80
  nopl   (%rax)
L138:
  lea    0x1(%rbx),%eax
  add    %r12d,%r13d
  sub    %r12d,%ebp
  add    (%rsp),%r14d
  cltd
  idivl  0x4c(%rsp)
  mov    %edx,%ebx
  cmp    %r13d,%r10d
  jle    L118
L80:
  cmp    %r12d,%ebp
  mov    %r12d,%edx
  cmovle %ebp,%edx
  test   %r11d,%r11d
  je     L95
L123:
  cmp    %r15d,0x50(%rsp)
  jne    L138
  cmp    %ebx,0x54(%rsp)
  jne    L138
  mov    0x40(%rsp),%r8d
  mov    0x30(%rsp),%eax
  sub    $0x8,%rsp
  xor    %r9d,%r9d
  mov    0x40(%rsp),%rcx
  mov    %r10d,0x18(%rsp)
  imul   %r8d,%eax
  mov    %r11d,0x14(%rsp)
  add    0x3c(%rsp),%eax
  push   $0x0
  cltq
  mov    0x2c(%rsp),%edi
  lea    (%rcx,%rax,8),%rcx
  mov    %edx,0x18(%rsp)
  mov    %esi,0x14(%rsp)
  call   <Cdgerv2d@plt>
  mov    0x40(%rsp),%eax
  mov    0x18(%rsp),%edx
  add    %edx,%eax
  cltd
  idivl  0x54(%rsp)
  mov    %edx,0x40(%rsp)
  pop    %rax
  pop    %rdx
  mov    0x10(%rsp),%r10d
  mov    0xc(%rsp),%r11d
  mov    0x4(%rsp),%esi
  jmp    L138
  nopl   0x0(%rax,%rax,1)
L95:
  mov    0x20(%rsp),%rdi
  mov    %r10d,0x10(%rsp)
  movslq %r14d,%rax
  mov    %r15d,%r9d
  mov    %r11d,0xc(%rsp)
  sub    $0x8,%rsp
  push   %rbx
  lea    (%rdi,%rax,8),%rcx
  mov    0x28(%rsp),%r8d
  mov    0x2c(%rsp),%edi
  mov    %edx,0x18(%rsp)
  mov    %esi,0x14(%rsp)
  call   <Cdgesd2d@plt>
  pop    %rcx
  pop    %rsi
  mov    0x10(%rsp),%r10d
  mov    0xc(%rsp),%r11d
  mov    0x8(%rsp),%edx
  mov    0x4(%rsp),%esi
  jmp    L123
  nopl   (%rax)
L118:
  cmp    %r15d,0x50(%rsp)
  jne    L47
  mov    0x34(%rsp),%eax
  add    %esi,%eax
  cltd
  idivl  0x40(%rsp)
  mov    %edx,0x34(%rsp)
L47:
  lea    0x1(%r15),%eax
  mov    0x28(%rsp),%ecx
  add    %ecx,0x14(%rsp)
  cltd
  sub    %ecx,0x2c(%rsp)
  mov    0x14(%rsp),%edi
  idivl  0x48(%rsp)
  mov    %edx,%r15d
  cmp    %edi,0x18(%rsp)
  jg     L126
L13:
  xor    %eax,%eax
L36:
  mov    0x58(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L64
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L2:
  mov    $0xffffffff,%eax
  jmp    L36
L64:
  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;
}
```