user: Translate the below assembly code into C programming language:

```asm
<printMapAsPgm2>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r14
  mov    %esi,%ebp
  mov    %rdx,%rbx
  lea    D77(%rip),%r13
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %eax,%r12d
  mov    %rbx,%rdi
  call   <strlen@plt>
  lea    0x1(%r12,%rax,1),%edi
  call   <malloc@plt>
  mov    %rax,0x8(%rsp)
  mov    %rbx,%rsi
  mov    %rax,%rbx
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    %r13,%rsi
  mov    %rbx,%rdi
  call   <strcat@plt>
  lea    D59(%rip),%rsi
  mov    %rbx,%rdi
  call   <fopen@plt>
  mov    %rax,%r12
  test   %ebp,%ebp
  je     L8
  mov    (%r14),%rsi
  lea    -0x1(%rbp),%eax
  lea    0x8(%rsi,%rax,8),%r8
  mov    $0xffffffff,%ebx
  mov    %ebp,%edi
  shl    $0x2,%rdi
L56:
  mov    (%rsi),%rax
  lea    (%rdi,%rax,1),%rcx
L2:
  mov    (%rax),%edx
  cmp    %edx,%ebx
  cmovl  %edx,%ebx
  add    $0x4,%rax
  cmp    %rcx,%rax
  jne    L2
  add    $0x8,%rsi
  cmp    %r8,%rsi
  jne    L56
  mov    %r12,%rcx
  mov    $0x3,%edx
  mov    $0x1,%esi
  lea    D46(%rip),%rdi
  call   <fwrite@plt>
  mov    %ebp,%ecx
  mov    %ebp,%edx
  lea    D82(%rip),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    %ebx,%edx
  lea    D3(%rip),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    %ebp,%ebp
  lea    0x0(,%rbp,8),%rax
  mov    %rax,(%rsp)
  lea    0x0(,%rbp,4),%r13
  mov    $0x0,%ebp
  lea    D7(%rip),%r15
L10:
  mov    $0x0,%ebx
L35:
  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    L35
  mov    %r12,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  add    $0x8,%rbp
  cmp    %rbp,(%rsp)
  jne    L10
L19:
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L8:
  mov    %rax,%rcx
  mov    $0x3,%edx
  mov    $0x1,%esi
  lea    D46(%rip),%rdi
  call   <fwrite@plt>
  mov    $0x0,%ecx
  mov    $0x0,%edx
  lea    D82(%rip),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  mov    $0xffffffff,%edx
  lea    D3(%rip),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  jmp    L19
```

tool_calls: name: unpack_data
arguments: data_tag: D77
type: string
name: unpack_data
arguments: data_tag: D59
type: string
name: unpack_data
arguments: data_tag: D46
type: string
name: unpack_data
arguments: data_tag: D82
type: string
name: unpack_data
arguments: data_tag: D3
type: string
name: unpack_data
arguments: data_tag: D7
type: string

tool: D77: is.pgm

tool: D59: w

tool: D46: P2


tool: D82: %u %u


tool: D3: %d


tool: D7: %d 

assistant: ```c
void printMapAsPgm2(int ***map, const unsigned int MAP_SIZE, char *fn) {
  int i, j, max = -1;
  FILE *f;
  char *filename = (char *)malloc((strlen("is.pgm") + strlen(fn)) * sizeof(char) + 1);
  strcpy(filename, fn);
  strcat(filename, "is.pgm");
  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);
  free(filename);
}
```