user: Please show me the C implementation that matches the assembly code listed below:

```asm
<bn_mul_words>:
  endbr64
  push   %r13
  mov    %rcx,%r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  mov    %edx,%edi
  not    %edi
  shr    $0x1f,%edi
  sub    $0x8,%rsp
  call   <assert@plt>
  xor    %r8d,%r8d
  test   %r12d,%r12d
  jle    L3
  movzwl %r13w,%esi
  shr    $0x10,%r13
  movzwl %r13w,%edx
  jmp    L40
  nopl   0x0(%rax,%rax,1)
L59:
  mov    0x8(%rbp),%rax
  mov    %rsi,%r9
  mov    %rsi,%rdi
  movzwl %ax,%ecx
  shr    $0x10,%rax
  movzwl %ax,%eax
  imul   %rcx,%r9
  imul   %rax,%rdi
  imul   %rdx,%rcx
  imul   %rdx,%rax
  add    %edi,%ecx
  mov    %ecx,%ecx
  lea    0x10000(%rax),%r10
  cmp    %rcx,%rdi
  mov    %rcx,%rdi
  cmova  %r10,%rax
  shl    $0x10,%rcx
  mov    %ecx,%r10d
  add    %r9d,%ecx
  shr    $0x10,%rdi
  mov    %ecx,%ecx
  cmp    %r10,%rcx
  adc    %rdi,%rax
  add    %r8d,%ecx
  mov    %ecx,%ecx
  cmp    %r8,%rcx
  mov    %rcx,0x8(%rbx)
  adc    $0x0,%rax
  mov    %eax,%r8d
  cmp    $0x2,%r12d
  je     L3
  mov    0x10(%rbp),%rax
  mov    %rsi,%r9
  mov    %rsi,%rdi
  movzwl %ax,%ecx
  shr    $0x10,%rax
  movzwl %ax,%eax
  imul   %rcx,%r9
  imul   %rax,%rdi
  imul   %rdx,%rcx
  imul   %rdx,%rax
  add    %edi,%ecx
  mov    %ecx,%ecx
  lea    0x10000(%rax),%r10
  cmp    %rcx,%rdi
  mov    %rcx,%rdi
  cmova  %r10,%rax
  shl    $0x10,%rcx
  mov    %ecx,%r10d
  add    %r9d,%ecx
  shr    $0x10,%rdi
  mov    %ecx,%ecx
  cmp    %r10,%rcx
  adc    %rdi,%rax
  add    %r8d,%ecx
  mov    %ecx,%ecx
  cmp    %r8,%rcx
  mov    %rcx,0x10(%rbx)
  adc    $0x0,%rax
  mov    %eax,%r8d
  cmp    $0x3,%r12d
  je     L3
  mov    0x18(%rbp),%rax
  mov    %rsi,%r9
  mov    %rsi,%rdi
  movzwl %ax,%ecx
  shr    $0x10,%rax
  movzwl %ax,%eax
  imul   %rcx,%r9
  imul   %rax,%rdi
  imul   %rdx,%rcx
  imul   %rdx,%rax
  add    %edi,%ecx
  mov    %ecx,%ecx
  lea    0x10000(%rax),%r10
  cmp    %rcx,%rdi
  mov    %rcx,%rdi
  cmova  %r10,%rax
  shl    $0x10,%rcx
  mov    %ecx,%r10d
  add    %r9d,%ecx
  shr    $0x10,%rdi
  mov    %ecx,%ecx
  cmp    %r10,%rcx
  adc    %rdi,%rax
  add    %r8d,%ecx
  mov    %ecx,%ecx
  cmp    %r8,%rcx
  mov    %rcx,0x18(%rbx)
  adc    $0x0,%rax
  mov    %eax,%r8d
  sub    $0x4,%r12d
  je     L3
  add    $0x20,%rbp
  add    $0x20,%rbx
L40:
  mov    0x0(%rbp),%rax
  mov    %rsi,%r9
  mov    %rsi,%rdi
  movzwl %ax,%ecx
  shr    $0x10,%rax
  movzwl %ax,%eax
  imul   %rcx,%r9
  imul   %rax,%rdi
  imul   %rdx,%rcx
  imul   %rdx,%rax
  add    %edi,%ecx
  mov    %ecx,%ecx
  lea    0x10000(%rax),%r10
  cmp    %rcx,%rdi
  mov    %rcx,%rdi
  cmova  %r10,%rax
  shl    $0x10,%rcx
  mov    %ecx,%r10d
  add    %r9d,%ecx
  shr    $0x10,%rdi
  mov    %ecx,%ecx
  cmp    %r10,%rcx
  adc    %rdi,%rax
  add    %r8d,%ecx
  mov    %ecx,%ecx
  cmp    %r8,%rcx
  mov    %rcx,(%rbx)
  adc    $0x0,%rax
  mov    %eax,%r8d
  cmp    $0x1,%r12d
  jne    L59
L3:
  add    $0x8,%rsp
  mov    %r8,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
unsigned long bn_mul_words(unsigned long *rp, const unsigned long *ap, int num, unsigned long w) {
  unsigned long carry = 0;
  unsigned long bl, bh;
  assert(num >= 0);
  if (num <= 0)
    return ((unsigned long)0);
  bl = ((w) & (0xffff));
  bh = (((w) >> 16) & (0xffff));
  for (;;) {
    {
      unsigned long l, h;
      h = (ap[0]);
      l = ((h) & (0xffff));
      h = (((h) >> 16) & (0xffff));
      {
        unsigned long m, m1, lt, ht;
        lt = l;
        ht = h;
        m = ((bh)) * (lt);
        lt = ((bl)) * (lt);
        m1 = ((bl)) * (ht);
        ht = ((bh)) * (ht);
        m = (m + m1) & (0xffffffffL);
        if (m < m1)
          ht += ((((unsigned long)1) << 16) & (0xffffffffL));
        ht += (((m) >> 16) & (0xffff));
        m1 = (((m) << 16) & (0xffffffffL));
        lt = (lt + m1) & (0xffffffffL);
        if (lt < m1)
          ht++;
        (l) = lt;
        (h) = ht;
      };
      l += (carry);
      if ((l & (0xffffffffL)) < (carry))
        h++;
      (carry) = h & (0xffffffffL);
      (rp[0]) = l & (0xffffffffL);
    };
    if (--num == 0)
      break;
    {
      unsigned long l, h;
      h = (ap[1]);
      l = ((h) & (0xffff));
      h = (((h) >> 16) & (0xffff));
      {
        unsigned long m, m1, lt, ht;
        lt = l;
        ht = h;
        m = ((bh)) * (lt);
        lt = ((bl)) * (lt);
        m1 = ((bl)) * (ht);
        ht = ((bh)) * (ht);
        m = (m + m1) & (0xffffffffL);
        if (m < m1)
          ht += ((((unsigned long)1) << 16) & (0xffffffffL));
        ht += (((m) >> 16) & (0xffff));
        m1 = (((m) << 16) & (0xffffffffL));
        lt = (lt + m1) & (0xffffffffL);
        if (lt < m1)
          ht++;
        (l) = lt;
        (h) = ht;
      };
      l += (carry);
      if ((l & (0xffffffffL)) < (carry))
        h++;
      (carry) = h & (0xffffffffL);
      (rp[1]) = l & (0xffffffffL);
    };
    if (--num == 0)
      break;
    {
      unsigned long l, h;
      h = (ap[2]);
      l = ((h) & (0xffff));
      h = (((h) >> 16) & (0xffff));
      {
        unsigned long m, m1, lt, ht;
        lt = l;
        ht = h;
        m = ((bh)) * (lt);
        lt = ((bl)) * (lt);
        m1 = ((bl)) * (ht);
        ht = ((bh)) * (ht);
        m = (m + m1) & (0xffffffffL);
        if (m < m1)
          ht += ((((unsigned long)1) << 16) & (0xffffffffL));
        ht += (((m) >> 16) & (0xffff));
        m1 = (((m) << 16) & (0xffffffffL));
        lt = (lt + m1) & (0xffffffffL);
        if (lt < m1)
          ht++;
        (l) = lt;
        (h) = ht;
      };
      l += (carry);
      if ((l & (0xffffffffL)) < (carry))
        h++;
      (carry) = h & (0xffffffffL);
      (rp[2]) = l & (0xffffffffL);
    };
    if (--num == 0)
      break;
    {
      unsigned long l, h;
      h = (ap[3]);
      l = ((h) & (0xffff));
      h = (((h) >> 16) & (0xffff));
      {
        unsigned long m, m1, lt, ht;
        lt = l;
        ht = h;
        m = ((bh)) * (lt);
        lt = ((bl)) * (lt);
        m1 = ((bl)) * (ht);
        ht = ((bh)) * (ht);
        m = (m + m1) & (0xffffffffL);
        if (m < m1)
          ht += ((((unsigned long)1) << 16) & (0xffffffffL));
        ht += (((m) >> 16) & (0xffff));
        m1 = (((m) << 16) & (0xffffffffL));
        lt = (lt + m1) & (0xffffffffL);
        if (lt < m1)
          ht++;
        (l) = lt;
        (h) = ht;
      };
      l += (carry);
      if ((l & (0xffffffffL)) < (carry))
        h++;
      (carry) = h & (0xffffffffL);
      (rp[3]) = l & (0xffffffffL);
    };
    if (--num == 0)
      break;
    ap += 4;
    rp += 4;
  }
  return (carry);
}
```