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

```asm
<gnulliver64>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  cmpl   $0x0,D23(%rip)
  jne    L35
L39:
  mov    %rbx,%rdx
  mov    D18(%rip),%eax
  test   %eax,%eax
  je     L11
  cmp    $0xf,%eax
  je     L18
  mov    %rbx,%rax
  shl    $0x8,%rax
  sar    $0x38,%rax
  mov    %al,%dl
  movzbl %bl,%eax
  shl    $0x30,%rax
  movabs $0xff00ffffffffffff,%rcx
  and    %rdx,%rcx
  or     %rax,%rcx
  mov    %rcx,%rdx
  mov    %rbx,%rax
  sar    $0x38,%rax
  mov    %al,%dh
  movzbl %bh,%ecx
  shl    $0x38,%rcx
  movabs $0xffffffffffffff,%rax
  and    %rdx,%rax
  or     %rcx,%rax
  mov    %rbx,%rdx
  shr    $0x10,%rdx
  and    $0xff0000,%edx
  and    $0xffffffffff00ffff,%rax
  or     %rdx,%rax
  mov    %ebx,%edx
  shl    $0x8,%edx
  sar    $0x18,%edx
  movzbl %dl,%edx
  shl    $0x20,%rdx
  movabs $0xffffff00ffffffff,%rcx
  and    %rcx,%rax
  or     %rdx,%rax
  mov    %rbx,%rdx
  shr    $0x10,%rdx
  and    $0xff000000,%edx
  movabs $0xffffffff00ffffff,%rcx
  and    %rcx,%rax
  or     %rdx,%rax
  sar    $0x18,%ebx
  movzbl %bl,%ebx
  shl    $0x28,%rbx
  movabs $0xffff00ffffffffff,%rdx
  and    %rdx,%rax
  or     %rbx,%rax
  mov    %rax,%rdx
L11:
  mov    %rdx,%rax
  pop    %rbx
  ret
L35:
  mov    $0x0,%eax
  call   <gnulliver@plt>
  mov    %eax,D33(%rip)
  movl   $0x0,D23(%rip)
  jmp    L39
L18:
  mov    %rbx,%rax
  sar    $0x38,%rax
  mov    %al,%dl
  mov    %rbx,%rcx
  shl    $0x38,%rcx
  movabs $0xffffffffffffff,%rax
  and    %rdx,%rax
  or     %rcx,%rax
  mov    %rax,%rdx
  mov    %rbx,%rax
  shl    $0x8,%rax
  sar    $0x38,%rax
  mov    %al,%dh
  movzbl %bh,%ecx
  shl    $0x30,%rcx
  movabs $0xff00ffffffffffff,%rax
  and    %rdx,%rax
  or     %rcx,%rax
  mov    %rbx,%rdx
  shr    $0x18,%rdx
  and    $0xff0000,%edx
  and    $0xffffffffff00ffff,%rax
  or     %rdx,%rax
  mov    %ebx,%edx
  shl    $0x8,%edx
  sar    $0x18,%edx
  movzbl %dl,%edx
  shl    $0x28,%rdx
  movabs $0xffff00ffffffffff,%rcx
  and    %rcx,%rax
  or     %rdx,%rax
  mov    %rbx,%rdx
  shr    $0x8,%rdx
  and    $0xff000000,%edx
  movabs $0xffffffff00ffffff,%rcx
  and    %rcx,%rax
  or     %rdx,%rax
  mov    %ebx,%edx
  sar    $0x18,%edx
  movzbl %dl,%edx
  shl    $0x20,%rdx
  movabs $0xffffff00ffffffff,%rcx
  and    %rcx,%rax
  or     %rax,%rdx
  jmp    L11
```

assistant: ```c
unsigned long gnulliver64(unsigned long input) {
  static unsigned endian, init = 1;
  char tmpch;
  union {
    unsigned long u;
    char ch[8];
  } bytes;
  if (init) {
    endian = gnulliver();
    init = 0;
  }
  bytes.u = input;
  if (endian != 0) {
    if (endian == (1 | 2 | 4 | 8)) {
      tmpch = bytes.ch[0];
      bytes.ch[0] = bytes.ch[7];
      bytes.ch[7] = tmpch;
      tmpch = bytes.ch[1];
      bytes.ch[1] = bytes.ch[6];
      bytes.ch[6] = tmpch;
      tmpch = bytes.ch[2];
      bytes.ch[2] = bytes.ch[5];
      bytes.ch[5] = tmpch;
      tmpch = bytes.ch[3];
      bytes.ch[3] = bytes.ch[4];
      bytes.ch[4] = tmpch;
    } else {
      tmpch = bytes.ch[0];
      bytes.ch[0] = bytes.ch[6];
      bytes.ch[6] = tmpch;
      tmpch = bytes.ch[1];
      bytes.ch[1] = bytes.ch[7];
      bytes.ch[7] = tmpch;
      tmpch = bytes.ch[2];
      bytes.ch[2] = bytes.ch[4];
      bytes.ch[4] = tmpch;
      tmpch = bytes.ch[3];
      bytes.ch[3] = bytes.ch[5];
      bytes.ch[5] = tmpch;
    }
  }
  return (bytes.u);
}
```