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

```asm
<get_service>:
  endbr64
  cmp    %esi,%edx
  jae    L57
  push   %r15
  lea    D2(%rip),%r9
  mov    %r8,%r15
  xor    %r8d,%r8d
  push   %r14
  xor    %r14d,%r14d
  push   %r13
  mov    %rdi,%r13
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x28,%rsp
L106:
  mov    %ebx,%edx
  movzbl 0x0(%r13,%rdx,1),%eax
  test   %al,%al
  je     L81
  test   $0xc0,%al
  je     L49
  cmp    $0x64,%r14d
  ja     L81
  add    $0x2,%ebx
  cmp    %r12d,%ebx
  ja     L81
  movzbl 0x1(%r13,%rdx,1),%ebx
  shl    $0x8,%eax
  add    $0x1,%r14d
  or     %eax,%ebx
  and    $0x3fff,%ebx
L77:
  cmp    %r12d,%ebx
  jb     L106
L81:
  add    $0x28,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L49:
  lea    0x1(%rbx),%edx
  movzbl %al,%ebp
  lea    (%rdx,%rbp,1),%r11d
  cmp    %r12d,%r11d
  ja     L81
  lea    0x0(%r13,%rdx,1),%rdi
  cmpb   $0x5f,(%rdi)
  je     L93
  mov    %r11d,%ebx
  xor    %r8d,%r8d
  jmp    L77
  nopl   0x0(%rax)
L93:
  mov    %r9,%rdx
  mov    %ebp,%esi
  mov    %rcx,0x18(%rsp)
  mov    %r8d,0x10(%rsp)
  mov    %r11d,0xc(%rsp)
  mov    %rdi,(%rsp)
  call   <label_equals@plt>
  mov    (%rsp),%rdi
  mov    0xc(%rsp),%r11d
  lea    D2(%rip),%r9
  test   %rax,%rax
  mov    0x10(%rsp),%r8d
  mov    0x18(%rsp),%rcx
  lea    D38(%rip),%r10
  je     L99
L69:
  test   %r8d,%r8d
  jne    L125
L83:
  mov    %ebx,%r8d
  mov    %r11d,%ebx
  jmp    L77
  nopl   0x0(%rax,%rax,1)
L99:
  mov    %r10,%rdx
  mov    %ebp,%esi
  mov    %rcx,0x10(%rsp)
  mov    %r8d,0xc(%rsp)
  mov    %r11d,(%rsp)
  call   <label_equals@plt>
  mov    (%rsp),%r11d
  mov    0xc(%rsp),%r8d
  lea    D2(%rip),%r9
  test   %rax,%rax
  mov    0x10(%rsp),%rcx
  jne    L69
  jmp    L83
L57:
  xor    %eax,%eax
  ret
L125:
  lea    0x1(%r13,%r8,1),%rax
  mov    %rax,(%rcx)
  movzbl 0x0(%r13,%r8,1),%eax
  mov    %eax,(%r15)
  jmp    L81
```

tool_calls: name: disassemble_data
arguments: data_tag: D2
datatype: string
name: disassemble_data
arguments: data_tag: D38
datatype: string

tool: D2: _udp

tool: D38: _tcp

assistant: ```c
unsigned get_service(const unsigned char *px, unsigned length, unsigned offset, const unsigned char **r_service, unsigned *r_service_length) {
  unsigned recurse_count = 0;
  unsigned offset_of_serv = 0;
  while (offset < length) {
    unsigned len;
    if (px[offset] == 0x00)
      break;
    if (px[offset] & 0xC0) {
      if (recurse_count > 100)
        return 0;
      else
        recurse_count++;
      if (offset + 2 > length)
        return 0;
      offset = (*((unsigned char *)(px + offset) + 0) << 8 | *((unsigned char *)(px + offset) + 1) << 0) & 0x3FFF;
      continue;
    }
    len = px[offset++];
    if (offset + len > length)
      return 0;
    if (px[offset] == '_') {
      if (label_equals(px + offset, len, "_udp") || label_equals(px + offset, len, "_tcp")) {
        if (offset_of_serv) {
          *r_service = px + offset_of_serv + 1;
          *r_service_length = px[offset_of_serv];
          return 0;
        }
      }
      offset_of_serv = offset - 1;
    } else
      offset_of_serv = 0;
    offset += len;
  }
  return 0;
}
```