user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<byte_extract>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %edi,-0x4(%rbp)
  mov    %esi,-0x8(%rbp)
  mov    %rdx,-0x10(%rbp)
  mov    %rcx,-0x18(%rbp)
  mov    %r8,-0x20(%rbp)
  mov    %r9,-0x28(%rbp)
  cmpl   $0x1,-0x4(%rbp)
  je     L82
  cmpl   $0x0,-0x4(%rbp)
  je     L82
  mov    $0xfffffffe,%eax
  jmp    L44
L82:
  mov    -0x8(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x10(%rbp),%rax
  add    %rax,%rdx
  mov    -0x20(%rbp),%rcx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <inBounds@plt>
  test   %eax,%eax
  jne    L15
  mov    $0xfffffffd,%eax
  jmp    L44
L15:
  mov    -0x10(%rbp),%rdx
  mov    -0x20(%rbp),%rcx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <inBounds@plt>
  test   %eax,%eax
  jne    L1
  mov    $0xfffffffd,%eax
  jmp    L44
L1:
  cmpl   $0x4,-0x8(%rbp)
  je     L100
  cmpl   $0x4,-0x8(%rbp)
  jg     L179
  cmpl   $0x1,-0x8(%rbp)
  je     L63
  cmpl   $0x2,-0x8(%rbp)
  je     L61
  jmp    L179
L63:
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  movzbl %al,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L43
L61:
  cmpl   $0x1,-0x4(%rbp)
  jne    L85
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  movzbl %al,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  shl    $0x8,%eax
  movzwl %ax,%eax
  or     %eax,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L43
L85:
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  shl    $0x8,%eax
  movzwl %ax,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  movzbl %al,%eax
  or     %eax,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L43
L100:
  cmpl   $0x1,-0x4(%rbp)
  jne    L39
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  movzbl %al,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  shl    $0x8,%eax
  movzwl %ax,%eax
  or     %eax,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%eax
  shl    $0x10,%eax
  and    $0xff0000,%eax
  or     %eax,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%rax
  add    $0xc,%rax
  mov    (%rax),%eax
  shl    $0x18,%eax
  or     %eax,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L43
L39:
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  shl    $0x18,%eax
  mov    %eax,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  shl    $0x10,%eax
  and    $0xff0000,%eax
  or     %eax,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%eax
  shl    $0x8,%eax
  movzwl %ax,%eax
  or     %eax,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%rax
  add    $0xc,%rax
  mov    (%rax),%eax
  movzbl %al,%eax
  or     %eax,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L43
L179:
  mov    $0xffffffff,%eax
  jmp    L44
L43:
  mov    $0x0,%eax
L44:
  leave
  ret
```

assistant: ```c
int byte_extract(int endianess, int bytes_to_grab, u_int8_t *ptr, u_int8_t *start, u_int8_t *end, u_int32_t *value) {
  if (endianess != 1 && endianess != 0) {
    return -2;
  }
  if (!inBounds(start, end, ptr + (bytes_to_grab - 1))) {
    return -3;
  }
  if (!inBounds(start, end, ptr)) {
    return -3;
  }
  switch (bytes_to_grab) {
  case 1:
    *value = (*ptr) & 0xFF;
    break;
  case 2:
    if (endianess == 1) {
      *value = (*ptr) & 0xFF;
      *value |= (*(ptr + 1) & 0xFF) << 8;
    } else {
      *value = ((*ptr) & 0xFF) << 8;
      *value |= (*(ptr + 1)) & 0xFF;
    }
    break;
  case 4:
    if (endianess == 1) {
      *value = (*ptr) & 0xFF;
      *value |= ((*(ptr + 1)) & 0xFF) << 8;
      *value |= ((*(ptr + 2)) & 0xFF) << 16;
      *value |= ((*(ptr + 3)) & 0xFF) << 24;
    } else {
      *value = ((*ptr) & 0xFF) << 24;
      *value |= ((*(ptr + 1)) & 0xFF) << 16;
      *value |= ((*(ptr + 2)) & 0xFF) << 8;
      *value |= (*(ptr + 3)) & 0xFF;
    }
    break;
  default:
    return -1;
  }
  return 0;
}
```