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

```asm
<appaserver_link_get_tail_half>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  mov    %rcx,%r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %r9,%r12
  push   %rbp
  mov    %r8d,%ebp
  push   %rbx
  sub    $0x1a8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x198(%rsp)
  xor    %eax,%eax
  mov    0x1e0(%rsp),%rbx
  movb   $0x0,0x90(%rsp)
  test   %rdx,%rdx
  je     L115
  cmpb   $0x0,(%rdx)
  jne    L40
L115:
  test   %r14,%r14
  je     L39
  cmpb   $0x0,(%r14)
  jne    L75
L39:
  test   %r12,%r12
  je     L66
  cmpb   $0x0,(%r12)
  jne    L122
L66:
  test   %ebp,%ebp
  jne    L117
  movb   $0x0,0x110(%rsp)
  lea    0x110(%rsp),%r14
L32:
  movb   $0x0,0x10(%rsp)
  lea    0x10(%rsp),%r12
  test   %r15,%r15
  je     L50
  lea    D86(%rip),%r8
  mov    %r15,%rcx
  mov    %r12,%rdi
  xor    %eax,%eax
  lea    D48(%rip),%rdx
  lea    D13(%rip),%rsi
  call   <sprintf@plt>
L50:
  test   %rbx,%rbx
  lea    D71(%rip),%rax
  mov    %r12,%rdx
  mov    %r14,%r9
  cmove  %rax,%rbx
  lea    0x90(%rsp),%r8
  mov    %r13,%rcx
  cmpb   $0x0,0x90(%rsp)
  lea    D47(%rip),%rax
  lea    D42(%rip),%r12
  cmove  %rax,%r8
  sub    $0x8,%rsp
  mov    %r12,%rdi
  xor    %eax,%eax
  push   %rbx
  lea    D7(%rip),%rsi
  call   <sprintf@plt>
  pop    %rax
  pop    %rdx
  mov    0x198(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L49
  add    $0x1a8,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L122:
  lea    0x110(%rsp),%r14
  mov    %r12,%rdx
  lea    D78(%rip),%rsi
  xor    %eax,%eax
  mov    %r14,%rdi
  call   <sprintf@plt>
  jmp    L32
  nopl   0x0(%rax)
L75:
  lea    0x90(%rsp),%rdi
  mov    %rdi,0x8(%rsp)
  call   <strlen@plt>
  mov    0x8(%rsp),%rdi
  mov    %r14,%rdx
  lea    D78(%rip),%rsi
  cltq
  add    %rax,%rdi
  xor    %eax,%eax
  call   <sprintf@plt>
  jmp    L39
  nopw   0x0(%rax,%rax,1)
L40:
  lea    0x90(%rsp),%rdi
  lea    D78(%rip),%rsi
  call   <sprintf@plt>
  jmp    L115
  nopl   0x0(%rax)
L117:
  lea    0x110(%rsp),%r14
  mov    %ebp,%edx
  lea    D12(%rip),%rsi
  xor    %eax,%eax
  mov    %r14,%rdi
  call   <sprintf@plt>
  jmp    L32
L49:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D86
type_guessed: string
name: read_data
arguments: tag: D48
type_guessed: string
name: read_data
arguments: tag: D13
type_guessed: string
name: read_data
arguments: tag: D71
type_guessed: string
name: read_data
arguments: tag: D47
type_guessed: string
name: read_data
arguments: tag: D7
type_guessed: string
name: read_data
arguments: tag: D78
type_guessed: string
name: read_data
arguments: tag: D12
type_guessed: string

tool: D86: data

tool: D48: appaserver

tool: D13: /%s/%s/%s/

tool: D71: null

tool: 

tool: D7: %s%s%s%s.%s

tool: D78: _%s

tool: D12: _%d

assistant: ```c
char *appaserver_link_get_tail_half(char *application_name, char *filename_stem, char *begin_date_string, char *end_date_string, pid_t process_id, char *session, char *extension) {
  static char tail_half[512];
  char application_part[128];
  char date_part[128];
  char key_part[128];
  *date_part = '\0';
  if (begin_date_string && *begin_date_string) {
    sprintf(date_part, "_%s", begin_date_string);
  }
  if (end_date_string && *end_date_string) {
    sprintf(date_part + strlen(date_part), "_%s", end_date_string);
  }
  if (session && *session) {
    sprintf(key_part, "_%s", session);
  } else if (process_id) {
    sprintf(key_part, "_%d", process_id);
  } else {
    *key_part = '\0';
  }
  *application_part = '\0';
  if (application_name) {
    sprintf(application_part, "/%s/%s/%s/", "appaserver", application_name, "data");
  }
  sprintf(tail_half, "%s%s%s%s.%s", application_part, filename_stem, (*date_part) ? date_part : "", key_part, (extension) ? extension : "null");
  return tail_half;
}
```