user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<test_strfmt>:
  endbr64
  push   %r15
  mov    $0x400,%esi
  lea    D150(%rip),%r15
  push   %r14
  lea    D123(%rip),%r14
  push   %r13
  mov    %r14,%rdx
  movabs $0x1b69b4bacd05f15,%r13
  push   %r12
  mov    %r13,%rcx
  push   %rbp
  push   %rbx
  sub    $0x818,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x808(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbp
  lea    0x400(%rsp),%r12
  mov    %rbp,%rdi
  call   <strfmt@plt>
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    $0x400,%esi
  mov    %eax,%ebx
  mov    %r12,%rdi
  lea    D65(%rip),%r14
  xor    %eax,%eax
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0x12,%ebx
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r14,%rdx
  mov    $0x7b,%ecx
  mov    %rbp,%rdi
  mov    $0x400,%esi
  xor    %eax,%eax
  call   <strfmt@plt>
  mov    %r14,%rdx
  mov    $0x7b,%ecx
  mov    %r12,%rdi
  mov    %eax,%ebx
  mov    $0x400,%esi
  lea    D104(%rip),%r14
  xor    %eax,%eax
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0x6,%ebx
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r14,%rdx
  mov    $0xffffff85,%ecx
  mov    %rbp,%rdi
  mov    $0x400,%esi
  xor    %eax,%eax
  call   <strfmt@plt>
  mov    %r14,%rdx
  mov    $0xffffff85,%ecx
  mov    %r12,%rdi
  mov    %eax,%ebx
  mov    $0x400,%esi
  lea    D96(%rip),%r14
  xor    %eax,%eax
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0x4,%ebx
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    $0x400,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <strfmt@plt>
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    $0x400,%esi
  mov    %eax,%ebx
  mov    %r12,%rdi
  lea    D80(%rip),%r14
  xor    %eax,%eax
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0x12,%ebx
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r14,%rdx
  mov    $0x7b,%ecx
  mov    %rbp,%rdi
  mov    $0x400,%esi
  xor    %eax,%eax
  call   <strfmt@plt>
  mov    %r14,%rdx
  mov    $0x7b,%ecx
  mov    %r12,%rdi
  mov    %eax,%ebx
  mov    $0x400,%esi
  lea    D79(%rip),%r14
  xor    %eax,%eax
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0x6,%ebx
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    $0x400,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <strfmt@plt>
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    $0x400,%esi
  mov    %eax,%ebx
  mov    %r12,%rdi
  xor    %eax,%eax
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0xf,%ebx
  lea    D106(%rip),%r13
  sete   %dil
  xor    %eax,%eax
  lea    D165(%rip),%r14
  call   <assert@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r13,%rdx
  mov    $0x7b,%ecx
  mov    %rbp,%rdi
  mov    $0x400,%esi
  xor    %eax,%eax
  call   <strfmt@plt>
  mov    %r13,%rdx
  mov    $0x7b,%ecx
  mov    %r12,%rdi
  mov    %eax,%ebx
  mov    $0x400,%esi
  lea    D125(%rip),%r13
  xor    %eax,%eax
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0x2,%ebx
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r13,%rdx
  mov    $0x123,%ecx
  mov    %rbp,%rdi
  mov    $0x400,%esi
  xor    %eax,%eax
  call   <strfmt@plt>
  mov    %r13,%rdx
  mov    $0x123,%ecx
  mov    %r12,%rdi
  mov    %eax,%ebx
  mov    $0x400,%esi
  lea    D90(%rip),%r13
  xor    %eax,%eax
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0x6,%ebx
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    $0x400,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <strfmt@plt>
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    $0x400,%esi
  mov    %eax,%ebx
  mov    %r12,%rdi
  xor    %eax,%eax
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0x15,%ebx
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r13,%rcx
  mov    %r15,%rdx
  mov    $0x400,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <strfmt@plt>
  mov    %r13,%rcx
  mov    %r15,%rdx
  mov    $0x400,%esi
  mov    %eax,%ebx
  mov    %r12,%rdi
  lea    D147(%rip),%r15
  xor    %eax,%eax
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0x15,%ebx
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r13,%rcx
  mov    %r15,%rdx
  mov    $0x400,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <strfmt@plt>
  mov    %r13,%rcx
  mov    %r15,%rdx
  mov    $0x400,%esi
  mov    %eax,%ebx
  mov    %r12,%rdi
  lea    D21(%rip),%r15
  xor    %eax,%eax
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0x27,%ebx
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r13,%rcx
  mov    %r15,%rdx
  mov    $0x400,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <strfmt@plt>
  mov    %r13,%rcx
  mov    %r15,%rdx
  mov    $0x400,%esi
  mov    %eax,%ebx
  mov    %r12,%rdi
  lea    D38(%rip),%r15
  xor    %eax,%eax
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0x27,%ebx
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    $0xa,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <strfmt@plt>
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    $0xa,%esi
  mov    %eax,%ebx
  mov    %r12,%rdi
  lea    D58(%rip),%r14
  xor    %eax,%eax
  call   <hack_snprintf@plt>
  xor    %edi,%edi
  cmp    %eax,%ebx
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  sub    $0x8,%rsp
  mov    %r15,%rcx
  mov    %r14,%rdx
  push   $0x2e
  lea    D134(%rip),%r9
  mov    $0x400,%esi
  xor    %eax,%eax
  mov    $0x20,%r8d
  mov    %rbp,%rdi
  call   <strfmt@plt>
  mov    %r15,%rcx
  mov    %r14,%rdx
  mov    $0x400,%esi
  movl   $0x2e,(%rsp)
  lea    D134(%rip),%r9
  mov    %eax,%r13d
  mov    %r12,%rdi
  mov    $0x20,%r8d
  xor    %eax,%eax
  call   <snprintf@plt>
  xor    %edi,%edi
  cmp    $0xc,%r13d
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  mov    %rbp,%rsp
  mov    0x808(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L7
  add    $0x818,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L7:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D150
type: string
name: disassemble_data
arguments: tag: D123
type: string
name: disassemble_data
arguments: tag: D65
type: string
name: disassemble_data
arguments: tag: D104
type: string
name: disassemble_data
arguments: tag: D96
type: string
name: disassemble_data
arguments: tag: D80
type: string
name: disassemble_data
arguments: tag: D79
type: string
name: disassemble_data
arguments: tag: D106
type: string
name: disassemble_data
arguments: tag: D165
type: string
name: disassemble_data
arguments: tag: D125
type: string
name: disassemble_data
arguments: tag: D90
type: string
name: disassemble_data
arguments: tag: D147
type: string
name: disassemble_data
arguments: tag: D21
type: string
name: disassemble_data
arguments: tag: D38
type: string
name: disassemble_data
arguments: tag: D58
type: string
name: disassemble_data
arguments: tag: D134
type: string

tool: D150: test %5s this

tool: D123: %06ld

tool: D65: %06d

tool: D104: %d

tool: D96: %06lu

tool: D80: %06u

tool: D79: %lx

tool: D106: %x

tool: D165: test %s this

tool: D125: %6x

tool: D90: hello world

tool: D147: test %-29s this

tool: D21: test %29s this

tool: D38: hello

tool: D58: %s%c%s%c

tool: D134: world

assistant: ```c
void test_strfmt(void) {
  char str1[1024], str2[1024];
  int n1, n2;
  n1 = strfmt(str1, sizeof(str1), "%06ld", 123456789123456789ul);
  n2 = snprintf(str2, sizeof(str2), "%06ld", 123456789123456789ul);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%06d", 123);
  n2 = snprintf(str2, sizeof(str2), "%06d", 123);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%d", -123);
  n2 = snprintf(str2, sizeof(str2), "%d", -123);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%06lu", 123456789123456789ul);
  n2 = snprintf(str2, sizeof(str2), "%06lu", 123456789123456789ul);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%06u", 123);
  n2 = snprintf(str2, sizeof(str2), "%06u", 123);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%lx", 123456789123456789ul);
  n2 = snprintf(str2, sizeof(str2), "%lx", 123456789123456789ul);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%x", 123);
  n2 = snprintf(str2, sizeof(str2), "%x", 123);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%6x", 0x123);
  n2 = snprintf(str2, sizeof(str2), "%6x", 0x123);
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "test %s this", "hello world");
  n2 = snprintf(str2, sizeof(str2), "test %s this", "hello world");
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "test %5s this", "hello world");
  n2 = snprintf(str2, sizeof(str2), "test %5s this", "hello world");
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "test %-29s this", "hello world");
  n2 = snprintf(str2, sizeof(str2), "test %-29s this", "hello world");
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "test %29s this", "hello world");
  n2 = snprintf(str2, sizeof(str2), "test %29s this", "hello world");
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, 10, "test %s this", "hello world");
  n2 = hack_snprintf(str2, 10, "test %s this", "hello world");
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
  n1 = strfmt(str1, sizeof(str1), "%s%c%s%c", "hello", ' ', "world", '.');
  n2 = snprintf(str2, sizeof(str2), "%s%c%s%c", "hello", ' ', "world", '.');
  assert(n1 == n2);
  assert(strcmp(str1, str2) == 0);
}
```