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

```asm
<getmap>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  movq   $0x0,0x10(%rsp)
  movq   $0x0,0x18(%rsp)
  cmp    $0xffffffff,%edi
  je     L78
  test   %esi,%esi
  lea    D41(%rip),%rdx
  lea    D32(%rip),%rax
  cmovne %rax,%rdx
  mov    %edi,%esi
  lea    D54(%rip),%rdi
  mov    $0x0,%eax
  call   <string@plt>
  mov    %rax,%rbp
L77:
  lea    D109(%rip),%rsi
  mov    %rbp,%rdi
  call   <fopen@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L65
L73:
  lea    D62(%rip),%r14
  lea    D125(%rip),%r15
  lea    D20(%rip),%r13
  lea    D43(%rip),%r12
  jmp    L0
L78:
  test   %esi,%esi
  lea    D41(%rip),%rsi
  lea    D32(%rip),%rax
  cmovne %rax,%rsi
  lea    D90(%rip),%rdi
  mov    $0x0,%eax
  call   <string@plt>
  mov    %rax,%rbp
  jmp    L77
L65:
  mov    %rbp,%rdx
  lea    D15(%rip),%rsi
  mov    $0x0,%edi
  call   <die@plt>
  jmp    L73
L24:
  cmpq   $0x0,0x18(%rsp)
  mov    %r12,%rdx
  cmovne %r13,%rdx
  lea    0x18(%rsp),%rdi
  mov    0x4(%rsp),%r9d
  mov    0xc(%rsp),%r8d
  mov    0x8(%rsp),%ecx
  lea    D46(%rip),%rsi
  call   <append@plt>
L0:
  lea    0x20(%rsp),%rsi
  lea    0x10(%rsp),%rdi
  mov    %rbx,%rdx
  call   <getline@plt>
  test   %rax,%rax
  js     L56
  lea    0xc(%rsp),%rcx
  lea    0x8(%rsp),%rdx
  lea    0x4(%rsp),%r8
  mov    %r14,%rsi
  mov    0x10(%rsp),%rdi
  call   <sscanf@plt>
  cmp    $0x3,%eax
  je     L24
  mov    %rbp,%rdx
  mov    %r15,%rsi
  mov    $0x0,%edi
  call   <die@plt>
  jmp    L24
L56:
  cmpq   $0x0,0x18(%rsp)
  je     L38
L84:
  mov    %rbx,%rdi
  call   <fclose@plt>
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  mov    0x18(%rsp),%rax
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L87
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L38:
  mov    %rbp,%rdx
  lea    D125(%rip),%rsi
  mov    $0x0,%edi
  call   <die@plt>
  jmp    L84
L87:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D41
datatype: string
name: disassemble_data
arguments: data_label: D32
datatype: string
name: disassemble_data
arguments: data_label: D54
datatype: string
name: disassemble_data
arguments: data_label: D109
datatype: string
name: disassemble_data
arguments: data_label: D62
datatype: string
name: disassemble_data
arguments: data_label: D125
datatype: string
name: disassemble_data
arguments: data_label: D20
datatype: string
name: disassemble_data
arguments: data_label: D43
datatype: string
name: disassemble_data
arguments: data_label: D90
datatype: string
name: disassemble_data
arguments: data_label: D15
datatype: string
name: disassemble_data
arguments: data_label: D46
datatype: string

tool: D41: gid_map

tool: D32: uid_map

tool: D54: /proc/%d/%s

tool: D109: r

tool: D62:  %u %u %u

tool: D125: Invalid map data in %s

tool: D20: ,

tool: 

tool: D90: /proc/self/%s

tool: D15: Cannot read %s

tool: D46: %s%u:%u:%u

assistant: ```c
char *getmap(pid_t pid, int type) {
  char *line = NULL, *result = NULL, *path;
  size_t size;
  unsigned count, first, lower;
  FILE *file;
  if (pid == -1)
    path = string("/proc/self/%s", ((type) == 0 ? "gid_map" : "uid_map"));
  else
    path = string("/proc/%d/%s", pid, ((type) == 0 ? "gid_map" : "uid_map"));
  if (!(file = fopen(path, "r")))
    die(0, "Cannot read %s", path);
  while (getline(&line, &size, file) >= 0) {
    if (sscanf(line, " %u %u %u", &first, &lower, &count) != 3)
      die(0, "Invalid map data in %s", path);
    append(&result, "%s%u:%u:%u", result ? "," : "", first, lower, count);
  }
  if (!result)
    die(0, "Invalid map data in %s", path);
  fclose(file);
  free(line);
  free(path);
  return result;
}
```