user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<append_str>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  je     L94
  mov    %rdi,%rbp
  mov    %esi,%ebx
  mov    %edx,%r13d
  mov    %ecx,%r12d
  test   %esi,%esi
  jle    L105
L108:
  movslq D196(%rip),%rsi
  movslq %ebx,%rcx
  mov    D10(%rip),%rax
  mov    %rsi,%rdx
  lea    0x50(%rsi,%rcx,1),%rsi
  movslq D18(%rip),%rcx
  cmp    %rcx,%rsi
  jae    L117
  test   %rax,%rax
  je     L114
L56:
  lea    -0x1(%rbx),%ecx
  test   %ebx,%ebx
  jle    L13
  lea    D110(%rip),%r14
  jmp    L164
  nopl   0x0(%rax)
L118:
  movslq D196(%rip),%rax
  mov    %ecx,%ebx
  mov    %rsi,%rbp
  lea    -0x1(%rbx),%ecx
  lea    0x1(%rax),%edi
  mov    %edi,D181(%rip)
  mov    D10(%rip),%rdi
  mov    %dl,(%rdi,%rax,1)
  test   %ebx,%ebx
  jle    L70
L164:
  movzbl 0x0(%rbp),%edx
  lea    0x1(%rbp),%rsi
  cmp    $0x25,%dl
  jne    L118
  cmpb   $0x64,0x1(%rbp)
  jne    L118
  mov    %rsp,%r15
  mov    %r13d,%edx
  mov    %r14,%rsi
  sub    $0x2,%ebx
  mov    %r15,%rdi
  add    $0x2,%rbp
  mov    %r12d,%r13d
  call   <sprintf@plt>
  movslq D181(%rip),%rdi
  mov    %r15,%rsi
  add    D10(%rip),%rdi
  call   <strcpy@plt>
  movslq D181(%rip),%rdi
  add    D10(%rip),%rdi
  call   <strlen@plt>
  lea    -0x1(%rbx),%ecx
  add    %eax,D181(%rip)
  test   %ebx,%ebx
  jg     L164
  nopw   0x0(%rax,%rax,1)
L70:
  mov    D10(%rip),%rax
L13:
  movslq D181(%rip),%rdx
  movb   $0x0,(%rax,%rdx,1)
L98:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L9
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L105:
  je     L147
  add    %esi,D181(%rip)
  js     L173
L147:
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  jmp    L108
  nopl   0x0(%rax)
L117:
  lea    0x118(%rdx,%rbx,1),%esi
  mov    %rax,%rdi
  mov    %esi,D181(%rip)
  call   <realloc@plt>
  mov    %rax,D181(%rip)
  test   %rax,%rax
  jne    L56
L114:
  lea    D181(%rip),%rax
  jmp    L98
  xchg   %ax,%ax
L94:
  movl   $0x0,D181(%rip)
  mov    D181(%rip),%rax
  jmp    L98
L173:
  mov    $0xc47,%esi
  lea    D147(%rip),%rdi
  call   <myassert@plt>
  jmp    L147
L9:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_tag: D110
data_type: string
name: disassemble_data
arguments: data_tag: D181
data_type: string
name: disassemble_data
arguments: data_tag: D147
data_type: string

tool: D110: %d

tool: 

tool: D147: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bowlofstew/enterprise-search/refs/heads/master/src/parse_summary/lemon.c

assistant: ```c
char *append_str(char *zText, int n, int p1, int p2) {
  static char *z = 0;
  static int alloced = 0;
  static int used = 0;
  int c;
  char zInt[40];
  if (zText == 0) {
    used = 0;
    return z;
  }
  if (n <= 0) {
    if (n < 0) {
      used += n;
      if (!(used >= 0))
        myassert("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bowlofstew/enterprise-search/refs/heads/master/src/parse_summary/lemon.c", 3143);
    }
    n = strlen(zText);
  }
  if (n + sizeof(zInt) * 2 + used >= alloced) {
    alloced = n + sizeof(zInt) * 2 + used + 200;
    z = realloc(z, alloced);
  }
  if (z == 0)
    return "";
  while (n-- > 0) {
    c = *(zText++);
    if (c == '%' && zText[0] == 'd') {
      sprintf(zInt, "%d", p1);
      p1 = p2;
      strcpy(&z[used], zInt);
      used += strlen(&z[used]);
      zText++;
      n--;
    } else {
      z[used++] = c;
    }
  }
  z[used] = 0;
  return z;
}
```