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

```asm
<fread_endian>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %ecx,-0x20(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0x1,-0x1c(%rbp)
  jne    L143
  mov    -0x28(%rbp),%rdx
  lea    -0xc(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  cmp    $0x1,%eax
  je     L99
  mov    $0xffffffff,%eax
  jmp    L192
L99:
  movzbl -0xc(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %dl,(%rax)
  mov    $0x1,%eax
  jmp    L192
L143:
  cmpl   $0x2,-0x1c(%rbp)
  jne    L91
  mov    -0x28(%rbp),%rdx
  lea    -0xc(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  cmp    $0x1,%eax
  je     L82
  mov    $0xffffffff,%eax
  jmp    L192
L82:
  mov    -0x28(%rbp),%rdx
  lea    -0xb(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  cmp    $0x1,%eax
  je     L189
  mov    $0xffffffff,%eax
  jmp    L192
L189:
  movzbl -0xb(%rbp),%eax
  movzbl %al,%ecx
  movzbl -0xc(%rbp),%eax
  movzbl %al,%eax
  mov    -0x20(%rbp),%edx
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <endian2@plt>
  mov    -0x18(%rbp),%rdx
  mov    %al,(%rdx)
  mov    $0x2,%eax
  jmp    L192
L91:
  cmpl   $0x4,-0x1c(%rbp)
  jne    L21
  mov    -0x28(%rbp),%rdx
  lea    -0xc(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  cmp    $0x1,%eax
  je     L53
  mov    $0xffffffff,%eax
  jmp    L192
L53:
  mov    -0x28(%rbp),%rdx
  lea    -0xb(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  cmp    $0x1,%eax
  je     L123
  mov    $0xffffffff,%eax
  jmp    L192
L123:
  mov    -0x28(%rbp),%rdx
  lea    -0xa(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  cmp    $0x1,%eax
  je     L157
  mov    $0xffffffff,%eax
  jmp    L192
L157:
  mov    -0x28(%rbp),%rdx
  lea    -0x9(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  cmp    $0x1,%eax
  je     L113
  mov    $0xffffffff,%eax
  jmp    L192
L113:
  movzbl -0x9(%rbp),%eax
  movzbl %al,%ecx
  movzbl -0xa(%rbp),%eax
  movzbl %al,%edx
  movzbl -0xb(%rbp),%eax
  movzbl %al,%esi
  movzbl -0xc(%rbp),%eax
  movzbl %al,%eax
  mov    -0x20(%rbp),%edi
  mov    %edi,%r8d
  mov    %eax,%edi
  call   <endian4@plt>
  mov    -0x18(%rbp),%rdx
  mov    %al,(%rdx)
  mov    $0x4,%eax
  jmp    L192
L21:
  mov    -0x18(%rbp),%rax
  movb   $0x0,(%rax)
  mov    $0x0,%eax
L192:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L51
  call   <__stack_chk_fail@plt>
L51:
  leave
  ret
```

assistant: ```c
int fread_endian(ulong *x, int bytes, FILE *fp, int endian) {
  unsigned char u1, u2, u3, u4;
  if (bytes == 1) {
    if (fread(&u1, 1, 1, fp) != 1)
      return -1;
    *x = u1;
    return 1;
  } else if (bytes == 2) {
    if (fread(&u1, 1, 1, fp) != 1)
      return -1;
    if (fread(&u2, 1, 1, fp) != 1)
      return -1;
    *x = endian2(u1, u2, endian);
    return 2;
  } else if (bytes == 4) {
    if (fread(&u1, 1, 1, fp) != 1)
      return -1;
    if (fread(&u2, 1, 1, fp) != 1)
      return -1;
    if (fread(&u3, 1, 1, fp) != 1)
      return -1;
    if (fread(&u4, 1, 1, fp) != 1)
      return -1;
    *x = endian4(u1, u2, u3, u4, endian);
    return 4;
  } else {
    *x = 0;
    return 0;
  }
}
```