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

```asm
<deinterlace_16>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %r9d,(%rsp)
  test   %r8d,%r8d
  jle    L65
  mov    %rdi,%r15
  mov    %rsi,%r14
  mov    %rdx,%rbx
  cmpl   $0x0,0x50(%rsp)
  jne    L9
  movslq %ecx,%rcx
  lea    0x0(,%rcx,4),%rax
  mov    %rax,(%rsp)
  mov    %r8d,%eax
  mov    %rax,0x8(%rsp)
  mov    $0x0,%ebp
  jmp    L69
L9:
  mov    %rdi,%r13
  movslq %ecx,%rcx
  lea    0x0(,%rcx,4),%rax
  mov    %rax,0x8(%rsp)
  mov    %rdx,%r12
  lea    -0x1(%r8),%eax
  lea    0x4(%rdi,%rax,4),%r15
  jmp    L57
L97:
  mov    %ebp,(%r12)
  mov    %ebx,0x4(%r12)
  add    $0x4,%r13
  add    $0x4,%r14
  add    0x8(%rsp),%r12
  cmp    %r15,%r13
  je     L65
L57:
  mov    (%r14),%ebp
  mov    %ebp,%eax
  imul   0x50(%rsp),%eax
  movzbl (%rsp),%ecx
  sar    %cl,%eax
  mov    0x0(%r13),%ebx
  sub    %eax,%ebx
  add    %ebx,%ebp
  mov    $0x0,%eax
  call   <isBigEndian@plt>
  test   %rax,%rax
  je     L97
  mov    %ebp,%eax
  shl    $0x8,%eax
  movzwl %ax,%eax
  mov    %ebp,%ecx
  movzbl %ch,%ebp
  or     %eax,%ebp
  mov    %ebx,%eax
  shl    $0x8,%eax
  movzwl %ax,%eax
  movzbl %bh,%ebx
  or     %eax,%ebx
  jmp    L97
L48:
  mov    %r13d,(%rbx)
  mov    %r12d,0x4(%rbx)
  add    $0x1,%rbp
  add    (%rsp),%rbx
  cmp    0x8(%rsp),%rbp
  je     L65
L69:
  mov    (%r15,%rbp,4),%r13d
  mov    (%r14,%rbp,4),%r12d
  mov    $0x0,%eax
  call   <isBigEndian@plt>
  test   %rax,%rax
  je     L48
  mov    %r13d,%eax
  shl    $0x8,%eax
  movzwl %ax,%eax
  mov    %r13d,%edx
  movzbl %dh,%esi
  mov    %esi,%r13d
  or     %eax,%r13d
  mov    %r12d,%eax
  shl    $0x8,%eax
  movzwl %ax,%eax
  mov    %r12d,%edx
  movzbl %dh,%edi
  mov    %edi,%r12d
  or     %eax,%r12d
  jmp    L48
L65:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void deinterlace_16(int32_t *buffer_a, int32_t *buffer_b, int16_t *buffer_out, int numchannels, int numsamples, uint8_t interlacing_shift, uint8_t interlacing_leftweight) {
  int i;
  if (numsamples <= 0)
    return;
  if (interlacing_leftweight) {
    for (i = 0; i < numsamples; i++) {
      int32_t difference, midright;
      int16_t left;
      int16_t right;
      midright = buffer_a[i];
      difference = buffer_b[i];
      right = midright - ((difference * interlacing_leftweight) >> interlacing_shift);
      left = right + difference;
      if (isBigEndian()) {
        do {
          left = (((left)&0x00FF) << 0x08) | (((left)&0xFF00) >> 0x08);
        } while (0);
        do {
          right = (((right)&0x00FF) << 0x08) | (((right)&0xFF00) >> 0x08);
        } while (0);
      }
      buffer_out[i * numchannels] = left;
      buffer_out[i * numchannels + 1] = right;
    }
    return;
  }
  for (i = 0; i < numsamples; i++) {
    int16_t left, right;
    left = buffer_a[i];
    right = buffer_b[i];
    if (isBigEndian()) {
      do {
        left = (((left)&0x00FF) << 0x08) | (((left)&0xFF00) >> 0x08);
      } while (0);
      do {
        right = (((right)&0x00FF) << 0x08) | (((right)&0xFF00) >> 0x08);
      } while (0);
    }
    buffer_out[i * numchannels] = left;
    buffer_out[i * numchannels + 1] = right;
  }
}
```