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

```asm
<LongDiv>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xfd8,%rsp
  mov    %rsi,%r12
  mov    %rdx,%rbx
  mov    %rdx,0x8(%rsp)
  mov    %rcx,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0xfc8(%rsp)
  xor    %eax,%eax
  mov    %rcx,%rsi
  call   <Copy@plt>
  mov    %rbx,%rdi
  call   <Initialize@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <Compare@plt>
  cmp    $0xffffffff,%eax
  je     L219
  mov    %r12,%rdi
  call   <Degree@plt>
  mov    %eax,0x4(%rsp)
  cltq
  lea    (%r12,%rax,4),%rax
  mov    %rax,0x10(%rsp)
  mov    (%rax),%eax
  test   $0x80,%ah
  jne    L147
  movl   $0x0,0x18(%rsp)
L20:
  add    %eax,%eax
  addl   $0x1,0x18(%rsp)
  test   $0x80,%ah
  je     L20
L215:
  mov    0x18(%rsp),%ebx
  mov    %ebx,%esi
  mov    %rbp,%rdi
  call   <LeftShift@plt>
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <LeftShift@plt>
  mov    0x4(%rsp),%eax
  lea    0x4(,%rax,4),%r14
  lea    0x20(%rsp),%rbx
  jmp    L3
L147:
  movl   $0x0,0x18(%rsp)
  jmp    L215
L29:
  sub    0x4(%rsp),%r13d
  movslq %r13d,%r13
  mov    0x8(%rsp),%rax
  mov    %r15d,-0x4(%rax,%r13,4)
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <Sub@plt>
  jmp    L117
L140:
  shl    $0x10,%eax
  add    -0x4(%rbp,%rdx,1),%eax
  mov    $0x0,%edx
  div    %ecx
  mov    %eax,0x1c(%rsp)
  mov    %eax,%r15d
  mov    %rbx,%rdi
  call   <Initialize@plt>
  lea    0x7f0(%rsp),%rdi
  call   <Initialize@plt>
  mov    0x4(%rsp),%ecx
  test   %ecx,%ecx
  js     L188
  mov    %r13d,%eax
  sub    %ecx,%eax
  cltq
  lea    (%rbx,%rax,4),%rcx
  mov    $0x0,%eax
L121:
  mov    (%r12,%rax,1),%edx
  mov    %edx,-0x4(%rcx,%rax,1)
  add    $0x4,%rax
  cmp    %r14,%rax
  jne    L121
L188:
  lea    0x7f0(%rsp),%rsi
  mov    %rbx,%rdi
  call   <Copy@plt>
  mov    0x1c(%rsp),%esi
  mov    %rbx,%rdi
  call   <Mul@plt>
L38:
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <Compare@plt>
  cmp    $0x1,%eax
  jbe    L176
  lea    0x7f0(%rsp),%rsi
  mov    %rbx,%rdi
  call   <Sub@plt>
  sub    $0x1,%r15d
  jmp    L38
L176:
  sub    0x4(%rsp),%r13d
  movslq %r13d,%r13
  mov    0x8(%rsp),%rax
  mov    %r15d,-0x4(%rax,%r13,4)
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <Sub@plt>
L117:
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <Compare@plt>
  cmp    $0xffffffff,%eax
  je     L192
L3:
  mov    %rbp,%rdi
  call   <Degree@plt>
  mov    %eax,%r13d
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    0x0(%rbp,%rax,4),%eax
  mov    0x10(%rsp),%rcx
  mov    (%rcx),%ecx
  cmp    %ecx,%eax
  jb     L140
  mov    %rbx,%rdi
  call   <Initialize@plt>
  mov    0x4(%rsp),%ecx
  test   %ecx,%ecx
  js     L70
  mov    %r13d,%eax
  sub    %ecx,%eax
  cltq
  lea    (%rbx,%rax,4),%r15
  mov    $0x0,%eax
L39:
  mov    (%r12,%rax,1),%edx
  mov    %edx,(%r15,%rax,1)
  add    $0x4,%rax
  cmp    %r14,%rax
  jne    L39
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <Compare@plt>
  cmp    $0x1,%eax
  ja     L136
L163:
  sub    0x4(%rsp),%r13d
  movslq %r13d,%r13
  mov    0x8(%rsp),%rax
  movl   $0x1,(%rax,%r13,4)
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <Sub@plt>
  jmp    L117
L192:
  mov    0x18(%rsp),%ebx
  mov    %ebx,%esi
  mov    %rbp,%rdi
  call   <RightShift@plt>
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <RightShift@plt>
L219:
  mov    0xfc8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L18
  add    $0xfd8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L70:
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <Compare@plt>
  cmp    $0x1,%eax
  jbe    L163
  mov    %rbx,%rdi
  call   <Initialize@plt>
  lea    0x7f0(%rsp),%rdi
  call   <Initialize@plt>
  jmp    L11
L136:
  mov    %rbx,%rdi
  call   <Initialize@plt>
  lea    0x7f0(%rsp),%rdi
  call   <Initialize@plt>
  mov    $0x0,%eax
L52:
  mov    (%r12,%rax,1),%edx
  mov    %edx,-0x4(%r15,%rax,1)
  add    $0x4,%rax
  cmp    %r14,%rax
  jne    L52
L11:
  lea    0x7f0(%rsp),%rsi
  mov    %rbx,%rdi
  call   <Copy@plt>
  mov    $0xffff,%esi
  mov    %rbx,%rdi
  call   <Mul@plt>
  mov    $0xffff,%r15d
L21:
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <Compare@plt>
  cmp    $0x1,%eax
  jbe    L29
  lea    0x7f0(%rsp),%rsi
  mov    %rbx,%rdi
  call   <Sub@plt>
  sub    $0x1,%r15d
  jmp    L21
L18:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void LongDiv(unsigned a[], unsigned b[], unsigned quot[], unsigned res[]) {
  int s, t, k, sh;
  int i;
  unsigned x, D, Q;
  unsigned c[500], d[500];
  Copy(a, res);
  Initialize(quot);
  if (Compare(res, b) == -1)
    return;
  t = Degree(b);
  sh = 0;
  x = b[t];
  while ((x & (0x8000)) == 0) {
    x = x << 1;
    sh++;
  }
  LeftShift(res, sh);
  LeftShift(b, sh);
  while (1) {
    s = Degree(res);
    if (res[s] >= b[t]) {
      Initialize(c);
      for (i = 0; i <= t; i++)
        c[s - t + i] = b[i];
      k = Compare(res, c);
      if (k == 1 || k == 0) {
        quot[s - t] = 1;
        Sub(res, c);
      } else {
        Initialize(c);
        Initialize(d);
        for (i = 0; i <= t; i++)
          c[s - t - 1 + i] = b[i];
        Copy(c, d);
        D = 0xffff;
        Mul(c, D);
        while (1) {
          k = Compare(res, c);
          if (k == 1 || k == 0)
            break;
          Sub(c, d);
          D--;
        }
        quot[s - t - 1] = D;
        Sub(res, c);
      }
    } else {
      x = (res[s] << 16) + res[s - 1];
      Q = x / b[t];
      Initialize(c);
      Initialize(d);
      for (i = 0; i <= t; i++)
        c[s - t - 1 + i] = b[i];
      Copy(c, d);
      Mul(c, Q);
      while (1) {
        k = Compare(res, c);
        if (k == 1 || k == 0)
          break;
        Sub(c, d);
        Q--;
      }
      quot[s - t - 1] = Q;
      Sub(res, c);
    }
    k = Compare(res, b);
    if (k == -1)
      break;
  }
  RightShift(res, sh);
  RightShift(b, sh);
}
```