user: 请将以下的汇编代码转换成C语言代码:

```asm
<write_as_matrix>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %rcx,-0x50(%rbp)
  mov    %r8,-0x58(%rbp)
  mov    %r9,-0x60(%rbp)
  movl   $0x2f,-0x18(%rbp)
  mov    -0x48(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x50(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x10(%rbp)
  movl   $0x0,-0x24(%rbp)
  movl   $0x0,-0x20(%rbp)
  movl   $0x0,-0x1c(%rbp)
  mov    0x18(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  je     L77
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  lea    D6(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x8(%rbp)
  jmp    L41
L77:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  lea    D2(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x8(%rbp)
L41:
  cmpq   $0x0,-0x8(%rbp)
  jne    L128
  mov    0x50(%rbp),%rax
  movl   $0x1,(%rax)
  jmp    L25
L128:
  mov    0x48(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  je     L206
  movl   $0x0,-0x24(%rbp)
  jmp    L183
L129:
  cmpl   $0x0,-0x24(%rbp)
  je     L37
  mov    0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fputs@plt>
L37:
  mov    0x20(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x60(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rcx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <put_name@plt>
  addl   $0x1,-0x24(%rbp)
L183:
  mov    -0x24(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L129
  mov    0x30(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fputs@plt>
L206:
  movl   $0x0,-0x24(%rbp)
  jmp    L52
L124:
  mov    0x40(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  je     L138
  mov    0x20(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x58(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rcx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <put_name@plt>
  mov    0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fputs@plt>
L138:
  movl   $0x0,-0x20(%rbp)
  mov    -0x24(%rbp),%eax
  mov    %eax,-0x1c(%rbp)
  jmp    L149
L194:
  cmpl   $0x0,-0x20(%rbp)
  je     L117
  mov    0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fputs@plt>
L117:
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0xc(%rbp)
  mov    0x10(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  je     L155
  cmpl   $0x0,-0xc(%rbp)
  jne    L121
  mov    0x38(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fputs@plt>
  mov    0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fputs@plt>
  mov    0x38(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fputs@plt>
  jmp    L39
L121:
  cmpl   $0x2,-0xc(%rbp)
  jg     L171
  mov    $0x31,%edx
  jmp    L196
L171:
  mov    $0x32,%edx
L196:
  mov    -0x8(%rbp),%rax
  mov    %rax,%rsi
  mov    %edx,%edi
  call   <fputc@plt>
  mov    0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fputs@plt>
  cmpl   $0x1,-0xc(%rbp)
  jg     L159
  mov    $0x31,%edx
  jmp    L224
L159:
  mov    $0x32,%edx
L224:
  mov    -0x8(%rbp),%rax
  mov    %rax,%rsi
  mov    %edx,%edi
  call   <fputc@plt>
  jmp    L39
L155:
  cmpl   $0x0,-0xc(%rbp)
  jne    L57
  mov    0x38(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fputs@plt>
  jmp    L39
L57:
  mov    -0x18(%rbp),%eax
  add    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  movsbl %al,%eax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <fputc@plt>
L39:
  addl   $0x1,-0x20(%rbp)
  mov    -0x14(%rbp),%eax
  add    %eax,-0x1c(%rbp)
L149:
  mov    -0x20(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L194
  mov    0x30(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fputs@plt>
  addl   $0x1,-0x24(%rbp)
L52:
  mov    -0x24(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L124
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    0x50(%rbp),%rax
  movl   $0x0,(%rax)
  nop
L25:
  leave
  ret
```

tool_calls: name: parse_data
arguments: data_tag: D6
type_guessed: string
name: parse_data
arguments: data_tag: D2
type_guessed: string

tool: D6: a

tool: D2: w

assistant: ```c
void write_as_matrix(char **file, char *x, int *N, int *M, char **rnames, char **cnames, int *asalleles, int *append, int *quote, char **sep, char **eol, char **na, int *row_names, int *col_names, int *iferror) {
  int zerom = (int)'0' - 1;
  int nrow = *N;
  int ncol = *M;
  FILE *outfile;
  int i = 0, j = 0, ij = 0;
  if (*append)
    outfile = fopen(*file, "a");
  else
    outfile = fopen(*file, "w");
  if (!outfile) {
    *iferror = 1;
    return;
  }
  if (*col_names) {
    for (i = 0; i < ncol; i++) {
      if (i)
        fputs(*sep, outfile);
      put_name(outfile, cnames[i], *quote);
    }
    fputs(*eol, outfile);
  }
  for (i = 0; i < nrow; i++) {
    if (*row_names) {
      put_name(outfile, rnames[i], *quote);
      fputs(*sep, outfile);
    }
    for (j = 0, ij = i; j < ncol; j++, ij += nrow) {
      if (j)
        fputs(*sep, outfile);
      int g = (int)x[ij];
      if (*asalleles) {
        if (!g) {
          fputs(*na, outfile);
          fputs(*sep, outfile);
          fputs(*na, outfile);
        } else {
          fputc(g < 3 ? '1' : '2', outfile);
          fputs(*sep, outfile);
          fputc(g < 2 ? '1' : '2', outfile);
        }
      } else {
        if (!g)
          fputs(*na, outfile);
        else {
          g += zerom;
          fputc((char)g, outfile);
        }
      }
    }
    fputs(*eol, outfile);
  }
  fclose(outfile);
  *iferror = 0;
  return;
}
```