user: Converte this assembly snippet into its equivalent C code:

```asm
<getprefix>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x310,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    D21(%rip),%rax
  mov    %rax,%rsi
  lea    D68(%rip),%rax
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x2e0(%rbp)
  cmpq   $0x0,-0x2e0(%rbp)
  je     L71
  mov    -0x2e0(%rbp),%rdx
  lea    -0x210(%rbp),%rax
  mov    $0x200,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  mov    %rax,-0x2e8(%rbp)
  jmp    L54
L135:
  lea    -0x300(%rbp),%r8
  lea    -0x304(%rbp),%rdi
  lea    -0x308(%rbp),%rcx
  lea    -0x270(%rbp),%rdx
  lea    -0x210(%rbp),%rax
  lea    -0x240(%rbp),%rsi
  push   %rsi
  lea    -0x2fc(%rbp),%rsi
  push   %rsi
  mov    %r8,%r9
  mov    %rdi,%r8
  lea    D50(%rip),%rsi
  mov    %rax,%rdi
  call   <sscanf@plt>
  add    $0x10,%rsp
  cmp    $0x6,%eax
  jne    L123
  mov    -0x300(%rbp),%eax
  test   %eax,%eax
  jne    L123
  lea    -0x2a0(%rbp),%rax
  mov    $0x21,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x304(%rbp),%eax
  mov    %eax,-0x2f0(%rbp)
  movl   $0x0,-0x2f8(%rbp)
  jmp    L17
L45:
  movl   $0x80,-0x2d0(%rbp)
  movl   $0xc0,-0x2cc(%rbp)
  movl   $0xe0,-0x2c8(%rbp)
  movl   $0xf0,-0x2c4(%rbp)
  movl   $0xf8,-0x2c0(%rbp)
  movl   $0xfc,-0x2bc(%rbp)
  movl   $0xfe,-0x2b8(%rbp)
  movl   $0xff,-0x2b4(%rbp)
  mov    -0x2f8(%rbp),%eax
  add    %eax,%eax
  cltq
  movzbl -0x270(%rbp,%rax,1),%eax
  mov    %al,-0x2a3(%rbp)
  mov    -0x2f8(%rbp),%eax
  add    %eax,%eax
  add    $0x1,%eax
  cltq
  movzbl -0x270(%rbp,%rax,1),%eax
  mov    %al,-0x2a2(%rbp)
  movb   $0x0,-0x2a1(%rbp)
  lea    -0x2a3(%rbp),%rax
  mov    $0x10,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <strtol@plt>
  mov    %rax,-0x2d8(%rbp)
  cmpl   $0x7,-0x2f0(%rbp)
  jg     L68
  mov    -0x2f0(%rbp),%eax
  cltq
  mov    -0x2d0(%rbp,%rax,4),%eax
  jmp    L36
L68:
  mov    $0xff,%eax
L36:
  mov    %eax,-0x2ec(%rbp)
  mov    -0x2d8(%rbp),%rax
  mov    %eax,%edx
  mov    -0x2ec(%rbp),%eax
  and    %edx,%eax
  mov    %eax,%edx
  mov    -0x2f8(%rbp),%eax
  cltq
  mov    %dl,-0x2a0(%rbp,%rax,1)
  subl   $0x8,-0x2f0(%rbp)
  addl   $0x1,-0x2f8(%rbp)
L17:
  cmpl   $0x0,-0x2f0(%rbp)
  jg     L45
  lea    D26(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movl   $0x0,-0x2f4(%rbp)
  jmp    L102
L66:
  mov    -0x2f4(%rbp),%eax
  cltq
  movzbl -0x2a0(%rbp,%rax,1),%eax
  movzbl %al,%edx
  cmpl   $0x0,-0x2f4(%rbp)
  je     L2
  lea    D9(%rip),%rax
  jmp    L11
L2:
  lea    D47(%rip),%rax
L11:
  mov    %rax,%rsi
  lea    D54(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  addl   $0x1,-0x2f4(%rbp)
L102:
  mov    -0x2f4(%rbp),%eax
  cmp    -0x2f8(%rbp),%eax
  jl     L66
  mov    $0xa,%edi
  call   <putchar@plt>
L123:
  mov    -0x2e0(%rbp),%rdx
  lea    -0x210(%rbp),%rax
  mov    $0x200,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  mov    %rax,-0x2e8(%rbp)
L54:
  cmpq   $0x0,-0x2e8(%rbp)
  jne    L135
  mov    -0x2e0(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
L71:
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L63
  call   <__stack_chk_fail@plt>
L63:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D21
type_infered: string
name: unpack_data
arguments: data_tag: D68
type_infered: string
name: unpack_data
arguments: data_tag: D50
type_infered: string
name: unpack_data
arguments: data_tag: D26
type_infered: string
name: unpack_data
arguments: data_tag: D9
type_infered: string
name: unpack_data
arguments: data_tag: D47
type_infered: string
name: unpack_data
arguments: data_tag: D54
type_infered: string

tool: D21: r

tool: D68: /proc/net/if_inet6

tool: D50: %32[0-9a-f] %02x %02x %02x %02x %31s

tool: D26: id6: 

tool: D9: :

tool: 

tool: D54: %s%02x

assistant: ```c
void getprefix(void) {
  FILE *ifs = fopen("/proc/net/if_inet6", "r");
  if (ifs) {
    char buffer[512];
    char ip6[40];
    int devnum;
    int preflen;
    int scope;
    int flags;
    char name[40];
    char *l = fgets(buffer, sizeof(buffer), ifs);
    while (l) {
      if (6 == sscanf(buffer, "%32[0-9a-f] %02x %02x %02x %02x %31s", ip6, &devnum, &preflen, &scope, &flags, name)) {
        if (scope == 0x00) {
          unsigned char id6[33];
          int i, j;
          int bits;
          memset(id6, 0, sizeof(id6));
          for (bits = preflen, i = 0; bits > 0; bits -= 8, i++) {
            char buf[3];
            long val;
            int mask;
            int maskit[] = {0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff};
            buf[0] = ip6[i * 2];
            buf[1] = ip6[i * 2 + 1];
            buf[2] = 0;
            val = strtol(buf, NULL, 16);
            mask = (bits >= 8) ? 0xff : maskit[bits];
            id6[i] = (unsigned char)val & mask;
          }
          printf("id6: ");
          for (j = 0; j < i; j++)
            printf("%s%02x", j ? ":" : "", id6[j]);
          printf("\n");
        }
      }
      l = fgets(buffer, sizeof(buffer), ifs);
    }
    fclose(ifs);
  }
}
```