user: What is the c source code of the assembly code below?

```asm
<bn_div_words>:
  endbr64
  test   %edx,%edx
  je     L16
  push   %r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  mov    %edi,%ebx
  mov    %edx,%edi
  sub    $0x8,%rsp
  call   <BN_num_bits_word@plt>
  mov    %eax,%r13d
  cmp    $0x20,%eax
  je     L60
  mov    %r13d,%ecx
  mov    $0x1,%eax
  xor    %edi,%edi
  shl    %cl,%eax
  cmp    %ebx,%eax
  setb   %dil
  call   <assert@plt>
  mov    %ebx,%edx
  mov    $0x20,%eax
  sub    %r12d,%edx
  cmp    %ebx,%r12d
  cmovbe %edx,%ebx
  sub    %r13d,%eax
  je     L107
  mov    %eax,%ecx
  mov    %ebp,%edx
  shl    %cl,%ebx
  shl    %cl,%r12d
  mov    %r13d,%ecx
  shr    %cl,%edx
  mov    %eax,%ecx
  or     %edx,%ebx
  shl    %cl,%ebp
L107:
  mov    %r12d,%edi
  movzwl %r12w,%r8d
  mov    $0x2,%r9d
  xor    %r10d,%r10d
  shr    $0x10,%edi
L71:
  mov    %ebx,%edx
  mov    $0xffff,%eax
  shr    $0x10,%edx
  cmp    %edi,%edx
  je     L125
  mov    %ebx,%eax
  xor    %edx,%edx
  div    %edi
L125:
  mov    %eax,%r11d
  mov    %ebx,%edx
  mov    %eax,%esi
  imul   %edi,%r11d
  imul   %r8d,%esi
  sub    %r11d,%edx
  test   $0xffff0000,%edx
  jne    L40
  mov    %ebp,%r13d
  shl    $0x10,%edx
  shr    $0x10,%r13d
  or     %r13d,%edx
  cmp    %edx,%esi
  jbe    L40
  lea    (%rbx,%rdi,1),%edx
  sub    %r11d,%edx
  jmp    L57
  nopw   0x0(%rax,%rax,1)
L92:
  mov    %edx,%ecx
  add    %edi,%edx
  shl    $0x10,%ecx
  or     %r13d,%ecx
  cmp    %esi,%ecx
  jae    L40
L57:
  sub    $0x1,%eax
  sub    %edi,%r11d
  sub    %r8d,%esi
  test   $0xffff0000,%edx
  je     L92
L40:
  mov    %esi,%edx
  shr    $0x10,%esi
  shl    $0x10,%edx
  cmp    %edx,%ebp
  adc    %esi,%r11d
  cmp    %r11d,%ebx
  jae    L69
  add    %r12d,%ebx
  sub    $0x1,%eax
L69:
  cmp    $0x1,%r9d
  je     L75
  sub    %edx,%ebp
  shl    $0x10,%eax
  sub    %r11d,%ebx
  mov    $0x1,%r9d
  mov    %eax,%r10d
  mov    %ebp,%eax
  shl    $0x10,%ebx
  shr    $0x10,%eax
  shl    $0x10,%ebp
  or     %eax,%ebx
  jmp    L71
L60:
  mov    $0x1,%edi
  call   <assert@plt>
  mov    %ebx,%eax
  sub    %r12d,%eax
  cmp    %ebx,%r12d
  cmovbe %eax,%ebx
  jmp    L107
  nopw   0x0(%rax,%rax,1)
L75:
  add    $0x8,%rsp
  or     %r10d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  xchg   %ax,%ax
L16:
  mov    $0xffffffff,%eax
  ret
```

assistant: ```c
unsigned int bn_div_words(unsigned int h, unsigned int l, unsigned int d) {
  unsigned int dh, dl, q, ret = 0, th, tl, t;
  int i, count = 2;
  if (d == 0)
    return (0xffffffffL);
  i = BN_num_bits_word(d);
  assert((i == 32) || (h > (unsigned int)1 << i));
  i = 32 - i;
  if (h >= d)
    h -= d;
  if (i) {
    d <<= i;
    h = (h << i) | (l >> (32 - i));
    l <<= i;
  }
  dh = (d & (0xffff0000L)) >> 16;
  dl = (d & (0xffff));
  for (;;) {
    if ((h >> 16) == dh)
      q = (0xffff);
    else
      q = h / dh;
    th = q * dh;
    tl = dl * q;
    for (;;) {
      t = h - th;
      if ((t & (0xffff0000L)) || ((tl) <= ((t << 16) | ((l & (0xffff0000L)) >> 16))))
        break;
      q--;
      th -= dh;
      tl -= dl;
    }
    t = (tl >> 16);
    tl = (tl << 16) & (0xffff0000L);
    th += t;
    if (l < tl)
      th++;
    l -= tl;
    if (h < th) {
      h += d;
      q--;
    }
    h -= th;
    if (--count == 0)
      break;
    ret = q << 16;
    h = ((h << 16) | (l >> 16)) & (0xffffffffL);
    l = (l & (0xffff)) << 16;
  }
  ret |= q;
  return ret;
}
```