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

```asm
<printMapAsPgm>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r14
  mov    %esi,%ebp
  mov    %rdx,%r12
  lea    D46(%rip),%r13
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  mov    %r12,%rdi
  call   <strlen@plt>
  lea    0x1(%rbx,%rax,1),%edi
  call   <malloc@plt>
  mov    %rax,%rbx
  mov    %r12,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    %r13,%rsi
  mov    %rbx,%rdi
  call   <strcat@plt>
  lea    D53(%rip),%r12
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <fopen@plt>
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <fopen@plt>
  mov    %rax,%r12
  test   %ebp,%ebp
  je     L25
  mov    (%r14),%rsi
  lea    -0x1(%rbp),%eax
  lea    0x8(%rsi,%rax,8),%r8
  mov    $0xffffffff,%ebx
  mov    %ebp,%edi
  shl    $0x2,%rdi
L39:
  mov    (%rsi),%rax
  lea    (%rdi,%rax,1),%rcx
L48:
  mov    (%rax),%edx
  cmp    %edx,%ebx
  cmovl  %edx,%ebx
  add    $0x4,%rax
  cmp    %rcx,%rax
  jne    L48
  add    $0x8,%rsi
  cmp    %r8,%rsi
  jne    L39
  mov    %r12,%rcx
  mov    $0x3,%edx
  mov    $0x1,%esi
  lea    D79(%rip),%rdi
  call   <fwrite@plt>
  mov    %ebp,%ecx
  mov    %ebp,%edx
  lea    D20(%rip),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    %ebx,%edx
  lea    D28(%rip),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    %ebp,%ebp
  lea    0x0(,%rbp,8),%rax
  mov    %rax,0x8(%rsp)
  lea    0x0(,%rbp,4),%r13
  mov    $0x0,%ebp
  lea    D49(%rip),%r15
L15:
  mov    $0x0,%ebx
L38:
  mov    (%r14),%rax
  mov    (%rax,%rbp,1),%rax
  mov    (%rax,%rbx,1),%edx
  mov    %r15,%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  add    $0x4,%rbx
  cmp    %r13,%rbx
  jne    L38
  mov    %r12,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  add    $0x8,%rbp
  cmp    %rbp,0x8(%rsp)
  jne    L15
L8:
  mov    %r12,%rdi
  call   <fclose@plt>
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L25:
  mov    %rax,%rcx
  mov    $0x3,%edx
  mov    $0x1,%esi
  lea    D79(%rip),%rdi
  call   <fwrite@plt>
  mov    $0x0,%ecx
  mov    $0x0,%edx
  lea    D20(%rip),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    $0xffffffff,%edx
  lea    D28(%rip),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  jmp    L8
```

tool_calls: name: disassemble_data
arguments: label: D46
type_guessed: string
name: disassemble_data
arguments: label: D53
type_guessed: string
name: disassemble_data
arguments: label: D79
type_guessed: string
name: disassemble_data
arguments: label: D20
type_guessed: string
name: disassemble_data
arguments: label: D28
type_guessed: string
name: disassemble_data
arguments: label: D49
type_guessed: string

tool: D46: hmmap.pgm

tool: D53: w

tool: D79: P2


tool: D20: %u %u


tool: D28: %d


tool: D49: %d 

assistant: ```c
void printMapAsPgm(int ***map, const unsigned int MAP_SIZE, char *fn) {
  int i, j, max = -1;
  FILE *f;
  char *filename = (char *)malloc((strlen("hmmap.pgm") + strlen(fn)) * sizeof(char) + 1);
  strcpy(filename, fn);
  strcat(filename, "hmmap.pgm");
  f = fopen(filename, "w");
  f = fopen(filename, "w");
  for (i = 0; i < MAP_SIZE; ++i) {
    for (j = 0; j < MAP_SIZE; ++j) {
      max = max < (*map)[i][j] ? (*map)[i][j] : max;
    }
  }
  fprintf(f, "P2\n");
  fprintf(f, "%u %u\n", MAP_SIZE, MAP_SIZE);
  fprintf(f, "%d\n", max);
  for (i = 0; i < MAP_SIZE; ++i) {
    for (j = 0; j < MAP_SIZE; ++j) {
      fprintf(f, "%d ", (*map)[i][j]);
    }
    fprintf(f, "\n");
  }
  fclose(f);
}
```