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

```asm
<put_hexd>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rdx
  mov    %rdx,0x18(%rsp)
  xor    %edx,%edx
  mov    %edi,%edx
  and    $0xf,%edx
  lea    0x30(%rdx),%ecx
  add    $0x37,%edx
  cmp    $0x39,%cl
  cmovbe %ecx,%edx
  mov    %rdi,%rcx
  shr    $0x4,%rcx
  mov    %dl,0xe(%rsp)
  cmp    $0xf,%rdi
  jbe    L131
  mov    %ecx,%edx
  mov    %rdi,%rax
  and    $0xf,%edx
  lea    0x30(%rdx),%esi
  add    $0x37,%edx
  cmp    $0x39,%sil
  cmovbe %esi,%edx
  mov    %rax,%rsi
  shr    $0x8,%rsi
  mov    %dl,0xf(%rsp)
  cmp    $0xf,%rcx
  jbe    L94
  mov    %esi,%edx
  and    $0xf,%edx
  lea    0x30(%rdx),%ecx
  add    $0x37,%edx
  cmp    $0x39,%cl
  cmovbe %ecx,%edx
  mov    %rax,%rcx
  shr    $0xc,%rcx
  mov    %dl,0x10(%rsp)
  cmp    $0xf,%rsi
  jbe    L28
  mov    %ecx,%edx
  and    $0xf,%edx
  lea    0x30(%rdx),%esi
  add    $0x37,%edx
  cmp    $0x39,%sil
  cmovbe %esi,%edx
  mov    %rax,%rsi
  shr    $0x10,%rsi
  mov    %dl,0x11(%rsp)
  cmp    $0xf,%rcx
  jbe    L22
  mov    %esi,%edx
  and    $0xf,%edx
  lea    0x30(%rdx),%ecx
  add    $0x37,%edx
  cmp    $0x39,%cl
  cmovbe %ecx,%edx
  mov    %rax,%rcx
  shr    $0x14,%rcx
  mov    %dl,0x12(%rsp)
  cmp    $0xf,%rsi
  jbe    L148
  mov    %ecx,%edx
  and    $0xf,%edx
  lea    0x30(%rdx),%esi
  add    $0x37,%edx
  cmp    $0x39,%sil
  cmovbe %esi,%edx
  mov    %rax,%rsi
  shr    $0x18,%rsi
  mov    %dl,0x13(%rsp)
  cmp    $0xf,%rcx
  jbe    L14
  mov    %esi,%edx
  and    $0xf,%edx
  lea    0x30(%rdx),%ecx
  add    $0x37,%edx
  cmp    $0x39,%cl
  cmovbe %ecx,%edx
  mov    %rax,%rcx
  shr    $0x1c,%rcx
  mov    %dl,0x14(%rsp)
  cmp    $0xf,%rsi
  jbe    L2
  mov    %ecx,%edx
  and    $0xf,%edx
  lea    0x30(%rdx),%esi
  add    $0x37,%edx
  cmp    $0x39,%sil
  cmovbe %esi,%edx
  mov    %rax,%rsi
  shr    $0x20,%rsi
  mov    %dl,0x15(%rsp)
  cmp    $0xf,%rcx
  jbe    L164
  mov    %esi,%edx
  and    $0xf,%edx
  lea    0x30(%rdx),%ecx
  add    $0x37,%edx
  cmp    $0x39,%cl
  cmovbe %ecx,%edx
  shr    $0x24,%rax
  mov    %dl,0x16(%rsp)
  cmp    $0xf,%rsi
  jbe    L126
  and    $0xf,%eax
  mov    $0xa,%r13d
  lea    0x30(%rax),%edx
  add    $0x37,%eax
  cmp    $0x3a,%dl
  cmovae %eax,%edx
  mov    %dl,0x17(%rsp)
L166:
  lea    0xe(%rsp),%r12
  lea    -0x1(%r13),%ebx
  add    %r12,%rbx
L1:
  movsbl (%rbx),%edi
  mov    %rbp,%rsi
  call   <fputc@plt>
  mov    %rbx,%rax
  sub    $0x1,%rbx
  cmp    %r12,%rax
  jne    L1
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L80
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L14:
  mov    $0x6,%r13d
  nopl   0x0(%rax)
L146:
  mov    $0x7,%ebx
  nopl   (%rax)
L172:
  mov    %rbp,%rsi
  mov    $0x30,%edi
  call   <fputc@plt>
  mov    %ebx,%eax
  sub    $0x1,%ebx
  cmp    %eax,%r13d
  jne    L172
  jmp    L166
  nopl   0x0(%rax)
L131:
  mov    $0x1,%r13d
  jmp    L146
L94:
  mov    $0x2,%r13d
  jmp    L146
L28:
  mov    $0x3,%r13d
  jmp    L146
L22:
  mov    $0x4,%r13d
  jmp    L146
L148:
  mov    $0x5,%r13d
  jmp    L146
L2:
  mov    $0x7,%r13d
  jmp    L146
L164:
  mov    $0x8,%r13d
  jmp    L166
L126:
  mov    $0x9,%r13d
  jmp    L166
L80:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void put_hexd(unsigned long value, FILE *fout) {
  char stack[10];
  unsigned int i, j;
  i = 0;
  j = 8;
  do {
    stack[i] = (value % 16) + '0';
    if (stack[i] > 0x39)
      stack[i] += 7;
    i++;
  } while (value /= 16);
  while (i < j--) {
    fputc('0', fout);
  }
  while (i) {
    fputc(stack[--i], fout);
  }
}
```