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

```asm
<szwrite>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movabs $0x5a455054474d4b00,%rax
  mov    %rax,-0x11(%rbp)
  movb   $0x59,-0x9(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  jne    L111
  cmpq   $0x0,-0x40(%rbp)
  je     L111
  mov    -0x40(%rbp),%rax
  mov    %rax,-0x38(%rbp)
  jmp    L115
L111:
  cmpq   $0x0,-0x38(%rbp)
  je     L115
  cmpq   $0x0,-0x40(%rbp)
  jne    L115
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x40(%rbp)
L115:
  movq   $0x0,-0x20(%rbp)
  jmp    L154
L170:
  addq   $0x1,-0x20(%rbp)
  mov    -0x30(%rbp),%rax
  shr    $0xa,%rax
  mov    %rax,-0x30(%rbp)
L154:
  cmpq   $0x8,-0x20(%rbp)
  ja     L76
  cmpq   $0x270f,-0x30(%rbp)
  ja     L170
L76:
  lea    -0x11(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x12(%rbp)
  cmpq   $0x270f,-0x30(%rbp)
  jbe    L109
  movb   $0x3e,-0x17(%rbp)
  movb   $0x39,-0x13(%rbp)
  movzbl -0x13(%rbp),%eax
  mov    %al,-0x14(%rbp)
  movzbl -0x14(%rbp),%eax
  mov    %al,-0x15(%rbp)
  movzbl -0x15(%rbp),%eax
  mov    %al,-0x16(%rbp)
  movq   $0x0,-0x20(%rbp)
  jmp    L70
L109:
  cmpq   $0x0,-0x30(%rbp)
  jne    L167
  mov    -0x20(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x20(%rbp)
  movb   $0x30,-0x17(%rbp,%rax,1)
  jmp    L70
L167:
  movq   $0x4,-0x20(%rbp)
  jmp    L46
L66:
  mov    -0x30(%rbp),%rcx
  movabs $0xcccccccccccccccd,%rdx
  mov    %rcx,%rax
  mul    %rdx
  shr    $0x3,%rdx
  mov    %rdx,%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  add    %rax,%rax
  sub    %rax,%rcx
  mov    %rcx,%rdx
  mov    %edx,%eax
  add    $0x30,%eax
  mov    %eax,%edx
  lea    -0x17(%rbp),%rcx
  mov    -0x20(%rbp),%rax
  add    %rcx,%rax
  mov    %dl,(%rax)
  subq   $0x1,-0x20(%rbp)
  mov    -0x30(%rbp),%rax
  movabs $0xcccccccccccccccd,%rdx
  mul    %rdx
  mov    %rdx,%rax
  shr    $0x3,%rax
  mov    %rax,-0x30(%rbp)
L46:
  cmpq   $0x0,-0x20(%rbp)
  je     L70
  cmpq   $0x0,-0x30(%rbp)
  jne    L66
L70:
  addq   $0x1,-0x20(%rbp)
  mov    $0x6,%eax
  sub    -0x20(%rbp),%rax
  mov    %rax,-0x30(%rbp)
  lea    -0x17(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x30(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  movzbl -0x12(%rbp),%eax
  test   %al,%al
  je     L51
  mov    -0x40(%rbp),%rax
  mov    %rax,-0x38(%rbp)
L51:
  cmpq   $0x0,-0x38(%rbp)
  je     L104
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x20(%rbp)
  mov    -0x28(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x20(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x20(%rbp),%rax
  add    %rax,-0x30(%rbp)
L104:
  mov    -0x30(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L31
  call   <__stack_chk_fail@plt>
L31:
  leave
  ret
```

assistant: ```c
size_t szwrite(char *out, size_t s, const char *suf, const char *sufs) {
  const char suffix[] = {0, 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'};
  char b[6];
  size_t i;
  if (suf == NULL && sufs != NULL)
    suf = sufs;
  else if (suf != NULL && sufs == NULL)
    sufs = suf;
  for (i = 0; i < sizeof(suffix) && s > 9999; i++, s /= 1024)
    ;
  b[5] = suffix[i];
  if (s > 9999) {
    b[0] = '>';
    b[1] = b[2] = b[3] = b[4] = '9';
    i = 0;
  } else if (s == 0)
    b[i--] = '0';
  else
    for (i = 4; i > 0 && s > 0; i--, s /= 10)
      b[i] = s % 10 + '0';
  i++;
  s = sizeof(b) - i;
  (void)memcpy(out, b + i, s);
  if (b[5])
    suf = sufs;
  if (suf != NULL) {
    i = strlen(suf);
    (void)memcpy(out + s, suf, i);
    s += i;
  }
  return (s);
}
```