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

```asm
<WriteLog>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    $0x1,%r13d
  push   %r12
  push   %rbp
  mov    %rcx,%rbp
  push   %rbx
  mov    %edi,%ebx
  lea    D145(%rip),%rdi
  sub    $0xf8,%rsp
  mov    %rsi,0x10(%rsp)
  mov    %edx,0x1c(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0xe8(%rsp)
  xor    %eax,%eax
  call   <getenv@plt>
  test   %rax,%rax
  je     L36
  mov    %rax,%rdi
  call   <atoi@plt>
  cmp    %ebx,%eax
  setg   %r13b
  test   %eax,%eax
  sete   %al
  or     %eax,%r13d
L36:
  lea    D74(%rip),%rdi
  call   <getenv@plt>
  mov    %rax,%rdi
  test   %rax,%rax
  je     L9
  call   <atoi@plt>
L9:
  lea    D109(%rip),%rdi
  call   <getenv@plt>
  mov    %rax,%rdi
  test   %rax,%rax
  je     L104
  call   <atoi@plt>
L104:
  lea    0x60(%rsp),%r12
  mov    $0x81,%edx
  xor    %esi,%esi
  mov    %r12,%rdi
  call   <memset@plt>
  lea    D48(%rip),%rdi
  call   <getenv@plt>
  mov    $0x80,%edx
  mov    %rax,%rsi
  test   %rax,%rax
  je     L154
L138:
  mov    %r12,%rdi
  lea    0x40(%rsp),%r12
  lea    0x30(%rsp),%r14
  call   <strncpy@plt>
  mov    $0x20,%edx
  xor    %esi,%esi
  mov    %r12,%rdi
  call   <memset@plt>
  mov    $0x10,%edx
  xor    %esi,%esi
  mov    %r14,%rdi
  call   <memset@plt>
  lea    0x24(%rsp),%rdi
  lea    0x2c(%rsp),%r15
  call   <ftime@plt>
  mov    0x24(%rsp),%ecx
  mov    $0x4,%esi
  mov    %r15,%rdi
  lea    D122(%rip),%rdx
  call   <snprintf@plt>
  lea    0x28(%rsp),%rdi
  call   <localtime@plt>
  lea    D25(%rip),%rdx
  mov    $0x20,%esi
  mov    %r12,%rdi
  mov    %rax,%rcx
  mov    %rax,0x8(%rsp)
  call   <strftime@plt>
  lea    D79(%rip),%rsi
  mov    %r12,%rdi
  call   <strcat@plt>
  mov    %r15,%rsi
  mov    %r12,%rdi
  call   <strcat@plt>
  mov    0x8(%rsp),%rcx
  mov    $0x10,%esi
  mov    %r14,%rdi
  lea    D0(%rip),%rdx
  call   <strftime@plt>
  xor    %eax,%eax
  test   %r13b,%r13b
  je     L52
L156:
  mov    0xe8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L22
  add    $0xf8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L52:
  call   <open_log_file@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L148
  mov    0x1c(%rsp),%r8d
  mov    0x10(%rsp),%rcx
  cmp    $0x5,%ebx
  ja     L106
  lea    D84(%rip),%rdx
  movslq (%rdx,%rbx,4),%rax
  add    %rdx,%rax
  notrack jmp *%rax
  nopl   (%rax)
L154:
  lea    D75(%rip),%rsi
  jmp    L138
  nopl   0x0(%rax)
  mov    %r12,%rdx
  lea    D71(%rip),%rsi
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  nopl   0x0(%rax)
L21:
  xor    %r12d,%r12d
  mov    %rbp,%rsi
  mov    %r12d,%edi
  call   <va_start@plt>
  mov    %r12d,%edx
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <vfprintf@plt>
  mov    %r12d,%edi
  call   <va_end@plt>
  mov    %r13,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  mov    %r13,%rdi
  call   <fflush@plt>
  mov    %r13,%rdi
  call   <fclose@plt>
  xor    %eax,%eax
  jmp    L156
  nopl   0x0(%rax,%rax,1)
  mov    %r12,%rdx
  lea    D66(%rip),%rsi
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  jmp    L21
  cs nopw 0x0(%rax,%rax,1)
  mov    %r12,%rdx
  lea    D128(%rip),%rsi
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  jmp    L21
  nopl   0x0(%rax)
  mov    %r12,%rdx
  lea    D73(%rip),%rsi
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  jmp    L21
  nopl   0x0(%rax)
  mov    %r12,%rdx
  lea    D68(%rip),%rsi
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  jmp    L21
L106:
  mov    %r12,%rdx
  lea    D20(%rip),%rsi
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <fprintf@plt>
  jmp    L21
L148:
  mov    $0xffffffff,%eax
  jmp    L156
L22:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D145
datatype: string
name: unpack_data
arguments: tag: D74
datatype: string
name: unpack_data
arguments: tag: D109
datatype: string
name: unpack_data
arguments: tag: D48
datatype: string
name: unpack_data
arguments: tag: D122
datatype: string
name: unpack_data
arguments: tag: D25
datatype: string
name: unpack_data
arguments: tag: D79
datatype: string
name: unpack_data
arguments: tag: D0
datatype: string
name: unpack_data
arguments: tag: D75
datatype: string
name: unpack_data
arguments: tag: D71
datatype: string
name: unpack_data
arguments: tag: D66
datatype: string
name: unpack_data
arguments: tag: D128
datatype: string
name: unpack_data
arguments: tag: D73
datatype: string
name: unpack_data
arguments: tag: D68
datatype: string
name: unpack_data
arguments: tag: D20
datatype: string

tool: D145: LOG_MODE

tool: D74: LOG_SWITCH_MODE

tool: D109: LOG_SIZE

tool: D48: LOG_FILE_PATH

tool: D122: %03d

tool: D25: %Y-%m-%d %H:%M:%S

tool: D79: :

tool: D0: %Y%m%d%H%M%S

tool: D75: .

tool: D71: [%s][%s][%d][CRITICAL]: 

tool: D66: [%s][%s][%d][ERROR]: 

tool: D128: [%s][%s][%d][WARNING]: 

tool: D73: [%s][%s][%d][INFO]: 

tool: D68: [%s][%s][%d][DEBUG]: 

tool: D20: [%s][%s][%d]: 

assistant: ```c
int WriteLog(int log_mode, char *filename, int line_num, char *fmt, ...) {
  int param_log_mode;
  int param_log_switch_mode;
  int param_log_size;
  char param_log_file_path[128 + 1];
  struct timeb tb;
  char log_time[32];
  char date_time[16];
  char millitm[4];
  struct tm *local_tm;
  char *penv;
  FILE *fp;
  va_list ap;
  penv = getenv("LOG_MODE");
  param_log_mode = penv == NULL ? 0 : atoi(penv);
  if (param_log_mode == 0)
    param_log_mode = 0;
  penv = getenv("LOG_SWITCH_MODE");
  param_log_switch_mode = penv == NULL ? 0 : atoi(penv);
  if (param_log_switch_mode == 0)
    param_log_switch_mode = 1;
  penv = getenv("LOG_SIZE");
  param_log_size = penv == NULL ? 0 : atoi(penv);
  if (param_log_size == 0)
    param_log_size = 5;
  memset(param_log_file_path, 0, sizeof(param_log_file_path));
  penv = getenv("LOG_FILE_PATH");
  if (penv)
    strncpy(param_log_file_path, penv, 128);
  else
    strncpy(param_log_file_path, ".", 128);
  memset(log_time, 0, sizeof(log_time));
  memset(date_time, 0, sizeof(date_time));
  ftime(&tb);
  snprintf(millitm, sizeof(millitm), "%03d", tb.millitm);
  local_tm = localtime(&tb.time);
  strftime(log_time, sizeof(log_time), "%Y-%m-%d %H:%M:%S", local_tm);
  strcat(log_time, ":");
  strcat(log_time, millitm);
  strftime(date_time, sizeof(date_time), "%Y%m%d%H%M%S", local_tm);
  if (param_log_mode == 0 || log_mode < param_log_mode)
    return 0;
  fp = open_log_file();
  if (fp == NULL)
    return -1;
  switch (log_mode) {
  case 1:
    fprintf(fp, "[%s][%s][%d][DEBUG]: ", log_time, filename, line_num);
    break;
  case 2:
    fprintf(fp, "[%s][%s][%d][INFO]: ", log_time, filename, line_num);
    break;
  case 3:
    fprintf(fp, "[%s][%s][%d][WARNING]: ", log_time, filename, line_num);
    break;
  case 4:
    fprintf(fp, "[%s][%s][%d][ERROR]: ", log_time, filename, line_num);
    break;
  case 5:
    fprintf(fp, "[%s][%s][%d][CRITICAL]: ", log_time, filename, line_num);
    break;
  default:
    fprintf(fp, "[%s][%s][%d]: ", log_time, filename, line_num);
    break;
  }
  va_start(ap, fmt);
  vfprintf(fp, fmt, ap);
  va_end(ap);
  fprintf(fp, "\n");
  fflush(fp);
  fclose(fp);
  return 0;
}
```