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

```asm
<userdefault>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %edi,%ebx
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  movq   $0x0,0x30(%rsp)
  call   <geteuid@plt>
  test   %rax,%rax
  je     L5
  test   %ebx,%ebx
  jne    L99
  mov    $0x0,%eax
  call   <getgid@plt>
  mov    %eax,%esi
L55:
  lea    D28(%rip),%rdi
  call   <string@plt>
L127:
  mov    0x38(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L85
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L99:
  mov    $0x0,%eax
  call   <getuid@plt>
  mov    %eax,%esi
  jmp    L55
L5:
  mov    %ebx,%esi
  mov    $0xffffffff,%edi
  call   <getmap@plt>
  mov    %rax,0x8(%rsp)
  mov    %ebx,%edi
  call   <readranges@plt>
  mov    %rax,(%rsp)
  mov    $0x0,%ebp
  lea    D27(%rip),%r15
  lea    D35(%rip),%r14
  lea    D3(%rip),%r13
L121:
  lea    0x24(%rsp),%rdx
  lea    0x2c(%rsp),%rsi
  mov    (%rsp),%rdi
  call   <rangeitem@plt>
  mov    %rax,(%rsp)
  test   %rax,%rax
  je     L66
  mov    0x8(%rsp),%rbx
  lea    0x1c(%rsp),%r12
  jmp    L65
L110:
  cmpq   $0x0,0x30(%rsp)
  mov    %r14,%rdx
  cmovne %r15,%rdx
  lea    0x30(%rsp),%rdi
  mov    0x24(%rsp),%r9d
  mov    0x2c(%rsp),%r8d
  mov    %ebp,%ecx
  mov    %r13,%rsi
  call   <append@plt>
  add    0x24(%rsp),%ebp
L65:
  lea    0x28(%rsp),%rdx
  lea    0x20(%rsp),%rsi
  mov    %r12,%rcx
  mov    %rbx,%rdi
  call   <mapitem@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L121
  mov    0x2c(%rsp),%eax
  mov    %eax,%esi
  add    0x24(%rsp),%esi
  mov    0x20(%rsp),%edx
  cmp    %edx,%esi
  jbe    L65
  mov    0x1c(%rsp),%ecx
  lea    (%rdx,%rcx,1),%edi
  cmp    %edi,%eax
  jae    L65
  cmp    %edi,%esi
  jbe    L123
  add    %eax,%ecx
  sub    %edx,%ecx
  mov    %ecx,0x24(%rsp)
L123:
  cmp    %edx,%eax
  jae    L110
  mov    %edx,%ecx
  sub    %eax,%ecx
  add    %ecx,%ebp
  sub    %edx,%eax
  add    %eax,0x24(%rsp)
  mov    %edx,0x2c(%rsp)
  jmp    L110
L66:
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    $0x0,%edi
  call   <free@plt>
  mov    0x30(%rsp),%rax
  jmp    L127
L85:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D28
datatype: string
name: read_data
arguments: label: D27
datatype: string
name: read_data
arguments: label: D35
datatype: string
name: read_data
arguments: label: D3
datatype: string

tool: D28: 0:%u:1

tool: D27: ,

tool: 

tool: D3: %s%u:%u:%u

assistant: ```c
char *userdefault(int type) {
  char *cursor, *map, *range, *result = NULL;
  unsigned count, first, index = 0, length, lower, start;
  if (geteuid() != 0)
    return string("0:%u:1", ((unsigned)((type) == 0 ? getgid() : getuid())));
  map = getmap(-1, type);
  range = readranges(type);
  while ((range = rangeitem(range, &start, &length))) {
    cursor = map;
    while ((cursor = mapitem(cursor, &first, &lower, &count))) {
      if (start + length <= first || first + count <= start)
        continue;
      if (first + count < start + length)
        length = start - first + count;
      if (start < first) {
        index += first - start;
        length -= first - start;
        start = first;
      }
      append(&result, "%s%u:%u:%u", result ? "," : "", index, start, length);
      index += length;
    }
  }
  free(map);
  free(range);
  return result;
}
```