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

```asm
<btea>:
  endbr64
  mov    %rdi,%rcx
  mov    %rsi,%r9
  push   %r15
  mov    %rdx,%rdi
  push   %r14
  mov    (%rcx),%rsi
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  cmp    $0x1,%r9
  jg     L88
  mov    $0x1,%eax
  cmp    $0xffffffffffffffff,%r9
  jl     L118
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L88:
  mov    $0x34,%eax
  lea    -0x8(%rcx,%r9,8),%r12
  lea    -0x1(%r9),%r11
  xor    %r8d,%r8d
  cqto
  mov    (%r12),%rsi
  idiv   %r9
  mov    $0x9e3779b9,%edx
  imul   %rdx,%rax
  movabs $0x3b54cda56,%rdx
  add    %rdx,%rax
  mov    %rax,-0x10(%rsp)
  lea    -0x4(%r9),%rax
  and    $0xfffffffffffffffe,%rax
  mov    %rax,-0x8(%rsp)
  nopw   0x0(%rax,%rax,1)
L107:
  mov    $0x9e3779b9,%eax
  add    %rax,%r8
  mov    %r8,%rdx
  shr    $0x2,%rdx
  cmp    $0x3,%r9
  jle    L82
  mov    (%rcx),%rbx
  xor    %eax,%eax
L5:
  mov    %rdx,%r10
  mov    0x8(%rcx,%rax,8),%r13
  mov    %r8,%rbp
  mov    %rax,%r14
  xor    %rax,%r10
  and    $0x3,%r10d
  xor    %r13,%rbp
  mov    (%rdi,%r10,8),%r15
  xor    %rsi,%r15
  mov    %r15,%r10
  lea    0x0(,%r13,4),%r15
  add    %rbp,%r10
  mov    %rsi,%rbp
  shl    $0x4,%rsi
  shr    $0x5,%rbp
  xor    %r15,%rbp
  mov    %r13,%r15
  shr    $0x3,%r15
  xor    %r15,%rsi
  add    %rbp,%rsi
  mov    %r8,%rbp
  xor    %r10,%rsi
  lea    0x1(%rax),%r10
  xor    %rdx,%r10
  add    %rbx,%rsi
  mov    0x10(%rcx,%rax,8),%rbx
  and    $0x3,%r10d
  mov    %rsi,(%rcx,%rax,8)
  mov    (%rdi,%r10,8),%r15
  xor    %rbx,%rbp
  xor    %rsi,%r15
  mov    %r15,%r10
  mov    %rbx,%r15
  add    %rbp,%r10
  mov    %rsi,%rbp
  shr    $0x3,%r15
  shl    $0x4,%rbp
  shr    $0x5,%rsi
  xor    %r15,%rbp
  lea    0x0(,%rbx,4),%r15
  xor    %rsi,%r15
  add    %r15,%rbp
  xor    %rbp,%r10
  lea    (%r10,%r13,1),%rsi
  mov    %rsi,0x8(%rcx,%rax,8)
  add    $0x2,%rax
  cmp    %r14,-0x8(%rsp)
  jne    L5
  nopl   0x0(%rax)
L17:
  mov    %rdx,%rbx
  mov    0x8(%rcx,%rax,8),%r10
  mov    %r8,%rbp
  xor    %rax,%rbx
  and    $0x3,%ebx
  xor    %r10,%rbp
  mov    %r10,%r13
  shl    $0x2,%r10
  mov    (%rdi,%rbx,8),%r15
  shr    $0x3,%r13
  xor    %rsi,%r15
  mov    %r15,%rbx
  add    %rbp,%rbx
  mov    %rsi,%rbp
  shr    $0x5,%rsi
  shl    $0x4,%rbp
  xor    %rsi,%r10
  xor    %r13,%rbp
  lea    0x0(%rbp,%r10,1),%rsi
  xor    %rsi,%rbx
  add    (%rcx,%rax,8),%rbx
  mov    %rbx,(%rcx,%rax,8)
  add    $0x1,%rax
  mov    %rbx,%rsi
  cmp    %r11,%rax
  jl     L17
  xor    %r11,%rdx
  mov    (%rcx),%rax
  mov    %r8,%r10
  and    $0x3,%edx
  xor    (%rdi,%rdx,8),%rbx
  xor    %rax,%r10
  mov    %rbx,%rdx
  lea    0x0(,%rax,4),%rbx
  shr    $0x3,%rax
  add    %r10,%rdx
  mov    %rsi,%r10
  shl    $0x4,%rsi
  shr    $0x5,%r10
  xor    %rsi,%rax
  xor    %rbx,%r10
  add    %r10,%rax
  xor    %rax,%rdx
  add    (%r12),%rdx
  mov    %rdx,(%r12)
  mov    %rdx,%rsi
  cmp    -0x10(%rsp),%r8
  jne    L107
L47:
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L82:
  xor    %eax,%eax
  jmp    L17
L118:
  mov    %r9,%r8
  mov    $0x34,%eax
  movabs $0xffffffff61c88647,%rbp
  neg    %r8
  cqto
  idiv   %r8
  lea    0x6(%rax),%rdx
  mov    $0x9e3779b9,%eax
  imul   %rax,%rdx
  mov    %r9,%rax
  not    %rax
  lea    (%rcx,%rax,8),%r12
  lea    -0x2(%rax),%r8
  mov    %rax,%r9
  lea    -0x3(%rax),%rax
  mov    %rdx,%r10
  mov    %r12,%r13
  and    $0xfffffffffffffffe,%rax
  shr    $0x2,%r10
  sub    %rax,%r8
  mov    %r8,-0x10(%rsp)
  cmp    $0x2,%r9
  jle    L129
  nopl   0x0(%rax,%rax,1)
L14:
  mov    0x0(%r13),%r11
  mov    %r9,%r8
L65:
  mov    %r10,%rax
  mov    -0x8(%rcx,%r8,8),%rbx
  lea    0x0(,%rsi,4),%r14
  xor    %r8,%rax
  and    $0x3,%eax
  mov    (%rdi,%rax,8),%r15
  mov    %rsi,%rax
  shr    $0x3,%rsi
  xor    %rdx,%rax
  xor    %rbx,%r15
  add    %rax,%r15
  mov    %rbx,%rax
  shr    $0x5,%rax
  xor    %r14,%rax
  mov    %rbx,%r14
  shl    $0x4,%r14
  xor    %rsi,%r14
  mov    %r15,%rsi
  add    %r14,%rax
  xor    %rax,%rsi
  mov    %r11,%rax
  mov    -0x10(%rcx,%r8,8),%r11
  sub    %rsi,%rax
  lea    -0x1(%r8),%rsi
  xor    %r10,%rsi
  mov    %rax,(%rcx,%r8,8)
  mov    %rax,%r15
  and    $0x3,%esi
  shr    $0x3,%r15
  mov    (%rdi,%rsi,8),%r14
  xor    %r11,%r14
  mov    %r14,%rsi
  mov    %rax,%r14
  shl    $0x2,%rax
  xor    %rdx,%r14
  add    %r14,%rsi
  mov    %r11,%r14
  shl    $0x4,%r14
  xor    %r15,%r14
  mov    %r11,%r15
  shr    $0x5,%r15
  xor    %r15,%rax
  add    %rax,%r14
  xor    %rsi,%r14
  mov    %rbx,%rsi
  sub    %r14,%rsi
  mov    %rsi,-0x8(%rcx,%r8,8)
  sub    $0x2,%r8
  cmp    %r8,-0x10(%rsp)
  jne    L65
  nopl   0x0(%rax)
L49:
  mov    %r10,%r11
  mov    -0x8(%rcx,%r8,8),%rax
  mov    %rsi,%r14
  xor    %r8,%r11
  shr    $0x3,%r14
  and    $0x3,%r11d
  mov    (%rdi,%r11,8),%rbx
  xor    %rax,%rbx
  mov    %rbx,%r11
  mov    %rdx,%rbx
  xor    %rsi,%rbx
  shl    $0x2,%rsi
  add    %rbx,%r11
  mov    %rax,%rbx
  shr    $0x5,%rax
  shl    $0x4,%rbx
  xor    %rax,%rsi
  mov    %r11,%rax
  xor    %r14,%rbx
  add    %rbx,%rsi
  xor    %rsi,%rax
  mov    (%rcx,%r8,8),%rsi
  sub    %rax,%rsi
  mov    %rsi,(%rcx,%r8,8)
  sub    $0x1,%r8
  jne    L49
  mov    (%r12),%rax
  lea    0x0(,%rsi,4),%r11
  and    $0x3,%r10d
  mov    %rax,%r8
  mov    %rax,%rbx
  xor    (%rdi,%r10,8),%rax
  shr    $0x5,%r8
  shl    $0x4,%rbx
  xor    %r11,%r8
  mov    %rsi,%r11
  xor    %rdx,%rsi
  shr    $0x3,%r11
  add    %rax,%rsi
  xor    %rbx,%r11
  add    %r11,%r8
  mov    %r8,%rax
  xor    %rsi,%rax
  mov    (%rcx),%rsi
  sub    %rax,%rsi
  mov    %rsi,(%rcx)
  add    %rbp,%rdx
  je     L47
  mov    %rdx,%r10
  shr    $0x2,%r10
  cmp    $0x2,%r9
  jg     L14
L129:
  mov    %r9,%r8
  jmp    L49
```

assistant: ```c
long btea(long *v, long length, long *key) {
  unsigned long z, y = v[0], sum = 0, e, DELTA = 0x9e3779b9;
  long p, q;
  if (length > 1) {
    z = v[length - 1];
    q = 6 + 52 / length;
    while (q-- > 0) {
      sum += DELTA;
      e = (sum >> 2) & 3;
      for (p = 0; p < length - 1; p++)
        y = v[p + 1], z = v[p] += ((((z >> 5) ^ (y << 2)) + ((y >> 3) ^ (z << 4))) ^ ((sum ^ y) + (key[(p & 3) ^ e] ^ z)));
      y = v[0];
      z = v[length - 1] += ((((z >> 5) ^ (y << 2)) + ((y >> 3) ^ (z << 4))) ^ ((sum ^ y) + (key[(p & 3) ^ e] ^ z)));
    }
    return 0;
  } else if (length < -1) {
    length = -length;
    q = 6 + 52 / length;
    sum = q * DELTA;
    while (sum != 0) {
      e = (sum >> 2) & 3;
      for (p = length - 1; p > 0; p--)
        z = v[p - 1], y = v[p] -= ((((z >> 5) ^ (y << 2)) + ((y >> 3) ^ (z << 4))) ^ ((sum ^ y) + (key[(p & 3) ^ e] ^ z)));
      z = v[length - 1];
      y = v[0] -= ((((z >> 5) ^ (y << 2)) + ((y >> 3) ^ (z << 4))) ^ ((sum ^ y) + (key[(p & 3) ^ e] ^ z)));
      sum -= DELTA;
    }
    return 0;
  }
  return 1;
}
```