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

```asm
<rec>:
  endbr64
  push   %r15
  mov    %ecx,%r11d
  movsbl %r8b,%ecx
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rsi,%rbp
  mov    %edx,%esi
  push   %rbx
  mov    %r9d,%ebx
  sub    $0x18,%rsp
  mov    0x50(%rsp),%r13
  test   %r11d,%r11d
  jne    L160
  cmp    %rbx,%rbp
  jl     L62
  mov    %rbp,%rax
  cqto
  idiv   %rbx
  mov    %rax,%r14
  cmp    %rbx,%rax
  jge    L53
L114:
  mov    %r11d,%edx
  mov    %r12,%rdi
  call   <fmt_sign_pad@plt>
  movslq %eax,%rcx
  add    %r12,%rcx
L167:
  mov    %r14,%rax
  add    $0x1,%rcx
  cqto
  idiv   %rbx
  movzbl 0x0(%r13,%rdx,1),%eax
  mov    %al,-0x1(%rcx)
  sub    %r12d,%ecx
  add    %r12,%rcx
  jmp    L111
  nopl   0x0(%rax)
L160:
  lea    -0x1(%r11),%r8d
  cmp    %rbx,%rbp
  jl     L30
  mov    %rbp,%rax
  cqto
  idiv   %rbx
  mov    %rax,%r14
  test   %r8d,%r8d
  je     L171
  lea    -0x2(%r11),%edi
  cmp    %rbx,%rax
  jl     L24
  cqto
  idiv   %rbx
  mov    %rax,%r15
  test   %edi,%edi
  je     L164
  lea    -0x3(%r11),%r10d
  cmp    %rbx,%rax
  jl     L85
  cqto
  sub    $0x4,%r11d
  idiv   %rbx
  test   %r10d,%r10d
  cmovne %r11d,%r10d
  mov    %rax,0x8(%rsp)
L126:
  cmp    %rbx,%rax
  jl     L1
  cqto
  sub    $0x8,%rsp
  mov    %ecx,%r8d
  mov    %r12,%rdi
  idiv   %rbx
  push   %r13
  mov    %esi,%edx
  mov    %r10d,%ecx
  mov    %rax,%rsi
  call   <rec>
  mov    %eax,%ecx
  pop    %rax
  pop    %rdx
  add    %r12,%rcx
L95:
  mov    0x8(%rsp),%rax
  add    $0x1,%rcx
  cqto
  idiv   %rbx
  movzbl 0x0(%r13,%rdx,1),%eax
  mov    %al,-0x1(%rcx)
  sub    %r12d,%ecx
  add    %r12,%rcx
L165:
  mov    %r15,%rax
  add    $0x1,%rcx
  cqto
  idiv   %rbx
  movzbl 0x0(%r13,%rdx,1),%eax
  mov    %al,-0x1(%rcx)
  sub    %r12d,%ecx
  add    %r12,%rcx
  jmp    L167
  nopl   0x0(%rax,%rax,1)
L62:
  xor    %r8d,%r8d
L30:
  mov    %r8d,%edx
  mov    %r12,%rdi
  call   <fmt_sign_pad@plt>
  movslq %eax,%rcx
  add    %r12,%rcx
L111:
  mov    %rbp,%rax
  cqto
  idiv   %rbx
  movzbl 0x0(%r13,%rdx,1),%eax
  mov    %al,(%rcx)
  add    $0x18,%rsp
  lea    0x1(%rcx),%rax
  pop    %rbx
  sub    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L171:
  cmp    %rbx,%rax
  jl     L66
L53:
  cqto
  idiv   %rbx
  mov    %rax,%r15
L164:
  cmp    %rbx,%r15
  jl     L73
  mov    %r15,%rax
  xor    %r10d,%r10d
  cqto
  idiv   %rbx
  mov    %rax,0x8(%rsp)
  jmp    L126
  nopw   0x0(%rax,%rax,1)
L24:
  mov    %edi,%r11d
  jmp    L114
  nopl   0x0(%rax,%rax,1)
L73:
  xor    %r10d,%r10d
L85:
  mov    %r10d,%edx
  mov    %r12,%rdi
  call   <fmt_sign_pad@plt>
  movslq %eax,%rcx
  add    %r12,%rcx
  jmp    L165
  nopl   0x0(%rax)
L1:
  mov    %r10d,%edx
  mov    %r12,%rdi
  call   <fmt_sign_pad@plt>
  movslq %eax,%rcx
  add    %r12,%rcx
  jmp    L95
  cs nopw 0x0(%rax,%rax,1)
L66:
  xor    %r11d,%r11d
  jmp    L114
```

assistant: ```c
unsigned rec(char *buffer, long long num, int sign, unsigned width, char pad, unsigned base, const char *digits) {
  char *s = buffer;
  if (width)
    --width;
  if (num >= (long long)base)
    s += rec(s, num / base, sign, width, pad, base, digits);
  else
    s += fmt_sign_pad(s, sign, width, pad);
  *s++ = digits[num % base];
  return s - buffer;
}
```