user: What is the c source code of the assembly code below:

```asm
<readranges>:
  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,0x8(%rsp)
  test   %edi,%edi
  jne    L121
  call   <getgid@plt>
  lea    D86(%rip),%rdi
  mov    %eax,%esi
  call   <string@plt>
  lea    D77(%rip),%rdi
L81:
  lea    D58(%rip),%rsi
  mov    %rax,0x10(%rsp)
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L60
  lea    D81(%rip),%rdi
  call   <getenv@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L5
L47:
  mov    %rbx,%rdi
  call   <getpwnam@plt>
  test   %rax,%rax
  je     L162
  mov    (%rax),%r12
  xor    %eax,%eax
  call   <getuid@plt>
  cmp    %rax,%r12
  je     L153
L162:
  xor    %eax,%eax
  call   <getuid@plt>
  mov    %rax,%rdi
  call   <getpwuid@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L3
L78:
  mov    0x8(%rbx),%rbx
L153:
  xor    %eax,%eax
  lea    0x20(%rsp),%r13
  lea    0x8(%rsp),%r12
  call   <endpwent@plt>
L157:
  lea    0x18(%rsp),%r15
  mov    %rsp,%r14
  cs nopw 0x0(%rax,%rax,1)
L86:
  mov    %rbp,%rdx
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <getline@plt>
  test   %rax,%rax
  js     L163
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    0x8(%rsp),%rdi
  mov    %rbx,%rsi
  mov    %rax,%rdx
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L86
  mov    %rbx,%rdi
  call   <strlen@plt>
  add    0x8(%rsp),%rax
  mov    %r15,%r8
  mov    %r14,%rcx
  lea    0x4(%rsp),%rdx
  mov    %rax,%rdi
  lea    D76(%rip),%rsi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jle    L86
  mov    %rbx,%rdi
  call   <strlen@plt>
  add    0x8(%rsp),%rax
  add    0x18(%rsp),%rax
  lea    D104(%rip),%rdi
  movsbl 0x1(%rax),%esi
  call   <strchr@plt>
  test   %rax,%rax
  je     L86
  mov    (%rsp),%ecx
  mov    0x4(%rsp),%edx
  lea    0x10(%rsp),%rdi
  lea    D75(%rip),%rsi
  call   <append@plt>
  jmp    L157
  nopl   0x0(%rax,%rax,1)
L163:
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
L60:
  mov    0x10(%rsp),%rax
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L91
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L121:
  xor    %eax,%eax
  call   <getuid@plt>
  lea    D86(%rip),%rdi
  mov    %eax,%esi
  call   <string@plt>
  lea    D109(%rip),%rdi
  jmp    L81
  nopl   0x0(%rax)
L3:
  lea    D72(%rip),%rdx
  xor    %esi,%esi
  mov    $0x1,%edi
  call   <error@plt>
  jmp    L78
L5:
  lea    D101(%rip),%rdi
  call   <getenv@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  jne    L47
  xor    %eax,%eax
  call   <getlogin@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L162
  jmp    L47
L91:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D86
type_infered: string
name: retrieve_data
arguments: data_tag: D77
type_infered: string
name: retrieve_data
arguments: data_tag: D58
type_infered: string
name: retrieve_data
arguments: data_tag: D81
type_infered: string
name: retrieve_data
arguments: data_tag: D76
type_infered: string
name: retrieve_data
arguments: data_tag: D104
type_infered: string
name: retrieve_data
arguments: data_tag: D75
type_infered: string
name: retrieve_data
arguments: data_tag: D109
type_infered: string
name: retrieve_data
arguments: data_tag: D72
type_infered: string
name: retrieve_data
arguments: data_tag: D101
type_infered: string

tool: D86: %u:1

tool: D77: /etc/subgid

tool: D58: r

tool: D81: USER

tool: D76: :%u:%u%zn

tool: D104: :


tool: D75: ,%u:%u

tool: D109: /etc/subuid

tool: D72: Failed to validate your username

tool: D101: LOGNAME

assistant: ```c
char *readranges(int type) {
  char *line = NULL, *range, *user;
  size_t end, size;
  struct passwd *passwd;
  unsigned length, start;
  FILE *file;
  range = string("%u:1", ((unsigned)((type) == 0 ? getgid() : getuid())));
  if (!(file = fopen(((type) == 0 ? "/etc/subgid" : "/etc/subuid"), "r")))
    return range;
  user = getenv("USER");
  user = user ? user : getenv("LOGNAME");
  user = user ? user : getlogin();
  if (!user || !(passwd = getpwnam(user)) || passwd->pw_uid != getuid()) {
    if (!(passwd = getpwuid(getuid())))
      error(1, 0, "Failed to validate your username");
    user = passwd->pw_name;
  }
  endpwent();
  while (getline(&line, &size, file) >= 0) {
    if (strncmp(line, user, strlen(user)))
      continue;
    if (sscanf(line + strlen(user), ":%u:%u%zn", &start, &length, &end) < 2)
      continue;
    if (strchr(":\n", line[end + strlen(user) + 1]))
      append(&range, ",%u:%u", start, length);
  }
  free(line);
  fclose(file);
  return range;
}
```