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

```asm
<parse_ip>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %rdx,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    (%rdi),%eax
  mov    %eax,0xc(%rsp)
  mov    (%rsi),%rdx
  mov    %rdx,0x10(%rsp)
  cmp    $0x1,%eax
  jle    L83
  mov    %rdi,%rbp
  mov    %rsi,%rbx
  lea    D50(%rip),%rsi
  mov    (%rdx),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L133
  lea    D90(%rip),%rsi
  mov    0x10(%rsp),%rax
  mov    (%rax),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L126
  lea    D64(%rip),%rsi
  mov    0x10(%rsp),%rax
  mov    (%rax),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L269
  lea    D0(%rip),%rsi
  mov    0x10(%rsp),%rax
  mov    (%rax),%rdi
  call   <matches@plt>
  test   %rax,%rax
  jne    L291
L269:
  mov    $0x0,%eax
  call   <NEXT_ARG@plt>
  lea    0x10(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  mov    $0x0,%r8d
  mov    $0x1,%ecx
  mov    %r12,%rdx
  call   <parse_u8@plt>
  jmp    L54
L133:
  call   <NEXT_ARG@plt>
  lea    0x10(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  mov    $0xc,%ecx
  mov    %r12,%rdx
  call   <parse_ip_addr@plt>
L54:
  mov    0xc(%rsp),%edx
  mov    %edx,0x0(%rbp)
  mov    0x10(%rsp),%rdx
  mov    %rdx,(%rbx)
L195:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L74
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L126:
  call   <NEXT_ARG@plt>
  lea    0x10(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  mov    $0x10,%ecx
  mov    %r12,%rdx
  call   <parse_ip_addr@plt>
  jmp    L54
L291:
  lea    D78(%rip),%rsi
  mov    0x10(%rsp),%rax
  mov    (%rax),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L236
  lea    D24(%rip),%rsi
  mov    0x10(%rsp),%rax
  mov    (%rax),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L3
  lea    D145(%rip),%rsi
  mov    0x10(%rsp),%rax
  mov    (%rax),%rdi
  call   <matches@plt>
  test   %rax,%rax
  je     L5
  lea    D23(%rip),%rsi
  mov    0x10(%rsp),%rax
  mov    (%rax),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L161
  lea    D134(%rip),%rsi
  mov    0x10(%rsp),%rax
  mov    (%rax),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L228
  lea    D113(%rip),%rsi
  mov    0x10(%rsp),%rax
  mov    (%rax),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L297
  lea    D107(%rip),%rsi
  mov    0x10(%rsp),%rax
  mov    (%rax),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L108
  lea    D87(%rip),%rsi
  mov    0x10(%rsp),%rax
  mov    (%rax),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L77
  lea    D13(%rip),%rsi
  mov    0x10(%rsp),%rax
  mov    (%rax),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L256
  lea    D80(%rip),%rsi
  mov    0x10(%rsp),%rax
  mov    (%rax),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L135
  lea    D77(%rip),%rsi
  mov    0x10(%rsp),%rax
  mov    (%rax),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L292
  call   <NEXT_ARG@plt>
  lea    0x10(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  mov    $0x1,%r8d
  mov    $0x14,%ecx
  mov    %r12,%rdx
  call   <parse_u8@plt>
  jmp    L54
L236:
  call   <NEXT_ARG@plt>
  lea    0x10(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  mov    $0x0,%r8d
  mov    $0x0,%ecx
  mov    %r12,%rdx
  call   <parse_u8@plt>
  jmp    L54
L3:
  call   <NEXT_ARG@plt>
  lea    0x10(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  mov    $0x0,%r8d
  mov    $0x9,%ecx
  mov    %r12,%rdx
  call   <parse_u8@plt>
  jmp    L54
L5:
  call   <NEXT_ARG@plt>
  lea    0x10(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  mov    $0x0,%r8d
  mov    $0x1,%ecx
  mov    %r12,%rdx
  call   <parse_u8@plt>
  jmp    L54
L161:
  subl   $0x1,0xc(%rsp)
  addq   $0x8,0x10(%rsp)
  mov    $0x0,%r8d
  mov    $0x6,%ecx
  mov    $0x3fff,%edx
  mov    $0x0,%esi
  mov    %r12,%rdi
  call   <pack_key16@plt>
  jmp    L54
L228:
  subl   $0x1,0xc(%rsp)
  addq   $0x8,0x10(%rsp)
  mov    $0x0,%r8d
  mov    $0x6,%ecx
  mov    $0x1fff,%edx
  mov    $0x0,%esi
  mov    %r12,%rdi
  call   <pack_key16@plt>
  jmp    L54
L297:
  subl   $0x1,0xc(%rsp)
  addq   $0x8,0x10(%rsp)
  mov    $0x0,%r8d
  mov    $0x6,%ecx
  mov    $0x4000,%edx
  mov    $0x4000,%esi
  mov    %r12,%rdi
  call   <pack_key16@plt>
  jmp    L54
L108:
  subl   $0x1,0xc(%rsp)
  addq   $0x8,0x10(%rsp)
  mov    $0x0,%r8d
  mov    $0x6,%ecx
  mov    $0x2000,%edx
  mov    $0x2000,%esi
  mov    %r12,%rdi
  call   <pack_key16@plt>
  jmp    L54
L77:
  call   <NEXT_ARG@plt>
  lea    0x10(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  mov    $0x0,%r8d
  mov    $0x16,%ecx
  mov    %r12,%rdx
  call   <parse_u16@plt>
  jmp    L54
L256:
  call   <NEXT_ARG@plt>
  lea    0x10(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  mov    $0x0,%r8d
  mov    $0x14,%ecx
  mov    %r12,%rdx
  call   <parse_u16@plt>
  jmp    L54
L135:
  call   <NEXT_ARG@plt>
  lea    0x10(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  mov    $0x0,%r8d
  mov    $0x14,%ecx
  mov    %r12,%rdx
  call   <parse_u8@plt>
  jmp    L54
L83:
  mov    $0xffffffff,%eax
  jmp    L195
L292:
  mov    $0xffffffff,%eax
  jmp    L195
L74:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D50
datatype: string
name: read_data
arguments: tag: D90
datatype: string
name: read_data
arguments: tag: D64
datatype: string
name: read_data
arguments: tag: D0
datatype: string
name: read_data
arguments: tag: D78
datatype: string
name: read_data
arguments: tag: D24
datatype: string
name: read_data
arguments: tag: D145
datatype: string
name: read_data
arguments: tag: D23
datatype: string
name: read_data
arguments: tag: D134
datatype: string
name: read_data
arguments: tag: D113
datatype: string
name: read_data
arguments: tag: D107
datatype: string
name: read_data
arguments: tag: D87
datatype: string
name: read_data
arguments: tag: D13
datatype: string
name: read_data
arguments: tag: D80
datatype: string
name: read_data
arguments: tag: D77
datatype: string

tool: D50: src

tool: D90: dst

tool: D64: tos

tool: D0: dsfield

tool: D78: ihl

tool: D24: protocol

tool: D145: precedence

tool: D23: nofrag

tool: D134: firstfrag

tool: D113: df

tool: D107: mf

tool: D87: dport

tool: D13: sport

tool: D80: icmp_type

tool: D77: icmp_code

assistant: ```c
int parse_ip(int *argc_p, char ***argv_p, struct tc_u32_sel *sel) {
  int res = -1;
  int argc = *argc_p;
  char **argv = *argv_p;
  if (argc < 2)
    return -1;
  if (strcmp(*argv, "src") == 0) {
    NEXT_ARG();
    res = parse_ip_addr(&argc, &argv, sel, 12);
    goto done;
  }
  if (strcmp(*argv, "dst") == 0) {
    NEXT_ARG();
    res = parse_ip_addr(&argc, &argv, sel, 16);
    goto done;
  }
  if (strcmp(*argv, "tos") == 0 || matches(*argv, "dsfield") == 0) {
    NEXT_ARG();
    res = parse_u8(&argc, &argv, sel, 1, 0);
    goto done;
  }
  if (strcmp(*argv, "ihl") == 0) {
    NEXT_ARG();
    res = parse_u8(&argc, &argv, sel, 0, 0);
    goto done;
  }
  if (strcmp(*argv, "protocol") == 0) {
    NEXT_ARG();
    res = parse_u8(&argc, &argv, sel, 9, 0);
    goto done;
  }
  if (matches(*argv, "precedence") == 0) {
    NEXT_ARG();
    res = parse_u8(&argc, &argv, sel, 1, 0);
    goto done;
  }
  if (strcmp(*argv, "nofrag") == 0) {
    argc--;
    argv++;
    res = pack_key16(sel, 0, 0x3FFF, 6, 0);
    goto done;
  }
  if (strcmp(*argv, "firstfrag") == 0) {
    argc--;
    argv++;
    res = pack_key16(sel, 0, 0x1FFF, 6, 0);
    goto done;
  }
  if (strcmp(*argv, "df") == 0) {
    argc--;
    argv++;
    res = pack_key16(sel, 0x4000, 0x4000, 6, 0);
    goto done;
  }
  if (strcmp(*argv, "mf") == 0) {
    argc--;
    argv++;
    res = pack_key16(sel, 0x2000, 0x2000, 6, 0);
    goto done;
  }
  if (strcmp(*argv, "dport") == 0) {
    NEXT_ARG();
    res = parse_u16(&argc, &argv, sel, 22, 0);
    goto done;
  }
  if (strcmp(*argv, "sport") == 0) {
    NEXT_ARG();
    res = parse_u16(&argc, &argv, sel, 20, 0);
    goto done;
  }
  if (strcmp(*argv, "icmp_type") == 0) {
    NEXT_ARG();
    res = parse_u8(&argc, &argv, sel, 20, 0);
    goto done;
  }
  if (strcmp(*argv, "icmp_code") == 0) {
    NEXT_ARG();
    res = parse_u8(&argc, &argv, sel, 20, 1);
    goto done;
  }
  return -1;
done:
  *argc_p = argc;
  *argv_p = argv;
  return res;
}
```