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

```asm
<jpeg_extract_segment>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x8(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    %rdx,-0x18(%rbp)
  mov    %rcx,-0x20(%rbp)
  mov    %r8,-0x28(%rbp)
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  cmp    $0x1,%eax
  jg     L139
  mov    $0x0,%eax
  jmp    L79
L139:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  lea    0x1(%rax),%rcx
  mov    -0x8(%rbp),%rdx
  mov    %rcx,(%rdx)
  movzbl (%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x1(%rax),%edx
  mov    -0x10(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0xff,%al
  je     L60
  mov    $0x0,%eax
  jmp    L79
L74:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  lea    0x1(%rax),%rcx
  mov    -0x8(%rbp),%rdx
  mov    %rcx,(%rdx)
  movzbl (%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x1(%rax),%edx
  mov    -0x10(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0xff,%al
  jne    L145
L60:
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jg     L74
  jmp    L2
L145:
  nop
L2:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0xcf,%al
  jbe    L81
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0xd7,%al
  jbe    L87
L81:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0xd8,%al
  je     L87
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0xd9,%al
  jne    L94
L87:
  mov    $0x1,%eax
  jmp    L79
L94:
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  cmp    $0x1,%eax
  jg     L97
  mov    $0x0,%eax
  jmp    L79
L97:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  shl    $0x8,%eax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  or     %eax,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  lea    0x2(%rax),%rdx
  mov    -0x8(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x2(%rax),%edx
  mov    -0x10(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x2(%rax),%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jge    L70
  mov    $0x0,%eax
  jmp    L79
L70:
  mov    -0x10(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  sub    %eax,%edx
  mov    -0x10(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  cltq
  add    %rax,%rdx
  mov    -0x8(%rbp),%rax
  mov    %rdx,(%rax)
  mov    $0x1,%eax
L79:
  pop    %rbp
  ret
```

assistant: ```c
int jpeg_extract_segment(const unsigned char **data, int *size, unsigned char *seg_type, const unsigned char **seg_data, int *seg_len) {
  if (*size < 2)
    return 0;
  { *seg_type = (uint8_t) * (*data)++; };
  (*size)--;
  if (*seg_type != 0xFF)
    return 0;
  while (*size >= 1) {
    { *seg_type = (uint8_t) * (*data)++; };
    (*size)--;
    if (*seg_type != 0xFF)
      break;
  }
  if ((*seg_type >= 0xD0 && *seg_type <= 0xD7) || *seg_type == 0xD8 || *seg_type == 0xD9)
    return 1;
  if (*size < 2)
    return 0;
  {
    *seg_len = (((*data)[0] << 8) | (*data)[1]);
    (*data) += 2;
  };
  *size -= 2;
  *seg_len -= 2;
  if (*size < *seg_len)
    return 0;
  *size -= *seg_len;
  *seg_data = *data;
  *data += *seg_len;
  return 1;
}
```