user: 请将以下的汇编代码转换成C语言代码：

```asm
<xgetdate_r>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x78,%rsp
  mov    %rsi,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x68(%rsp)
  xor    %eax,%eax
  mov    (%rdx),%rsi
  test   %rsi,%rsi
  je     L194
  mov    %rdi,%r13
  lea    0x8(%rdx),%rbp
  mov    D12(%rip),%r12
  jmp    L50
L56:
  add    $0x8,%rbp
  mov    -0x8(%rbp),%rsi
  test   %rsi,%rsi
  je     L176
L50:
  mov    (%r12),%rax
  mov    %rax,0x18(%rbx)
  mov    %rax,0x10(%rbx)
  mov    %rax,0x8(%rbx)
  mov    %rax,(%rbx)
  mov    (%r12),%rax
  mov    %rax,0x30(%rbx)
  mov    %rax,0x28(%rbx)
  mov    %rax,0x20(%rbx)
  movl   $0xffffffff,0x38(%rbx)
  movq   $0x0,0x48(%rbx)
  movq   $0x0,0x40(%rbx)
  mov    %rbx,%rdx
  mov    %r13,%rdi
  call   <my_strptime@plt>
  test   %rax,%rax
  je     L56
  cmpb   $0x0,(%rax)
  jne    L56
L316:
  lea    0x8(%rsp),%rbp
  mov    %rbp,%rdi
  call   <time@plt>
  lea    0x10(%rsp),%rsi
  mov    %rbp,%rdi
  call   <localtime_r@plt>
  mov    0x18(%rbx),%rcx
  cmp    $0x6,%rcx
  ja     L129
  mov    D12(%rip),%rax
  mov    (%rax),%rax
  mov    $0x0,%esi
  cmp    %rax,(%rbx)
  jne    L207
  cmp    0x8(%rbx),%rax
  jne    L207
  cmp    0x10(%rbx),%rax
  jne    L331
  mov    0x10(%rsp),%rax
  mov    %rax,(%rbx)
  mov    0x18(%rsp),%rax
  mov    %rax,0x8(%rbx)
  mov    %rcx,%rsi
  sub    0x28(%rsp),%rsi
  add    $0x7,%rsi
  movabs $0x4924924924924925,%rdx
  mov    %rsi,%rax
  imul   %rdx
  mov    %rdx,%rax
  sar    %rax
  mov    %rsi,%rdx
  sar    $0x3f,%rdx
  sub    %rdx,%rax
  lea    0x0(,%rax,8),%rdx
  sub    %rax,%rdx
  mov    %rsi,%rax
  sub    %rdx,%rax
  add    0x20(%rsp),%rax
  mov    %rax,0x10(%rbx)
  mov    $0x1,%esi
  jmp    L207
L176:
  test   %rax,%rax
  je     L237
  mov    $0x7,%edx
  cmpb   $0x0,(%rax)
  jne    L33
  jmp    L316
L129:
  mov    $0x0,%esi
L207:
  mov    0x8(%rbx),%rax
  cmp    $0xb,%rax
  ja     L331
  mov    D12(%rip),%rdx
  mov    (%rdx),%rdx
  cmp    %rdx,0x10(%rbx)
  je     L10
L331:
  mov    D12(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,0x20(%rbx)
  je     L389
L376:
  mov    0x20(%rbx),%rdx
  cmp    $0x17,%rdx
  ja     L275
  cmp    (%rbx),%rax
  jne    L78
  cmp    0x8(%rbx),%rax
  je     L282
L100:
  mov    0x10(%rsp),%rax
  mov    %rax,(%rbx)
  jmp    L78
L10:
  cmp    (%rbx),%rdx
  je     L318
L300:
  mov    %ecx,%edx
  mov    %rax,%rsi
  mov    (%rbx),%rdi
  call   <first_wday@plt>
  mov    %rax,0x10(%rbx)
  mov    $0x1,%esi
  jmp    L331
L318:
  mov    %rax,%rdx
  sub    0x18(%rsp),%rdx
  shr    $0x3f,%rdx
  add    0x10(%rsp),%rdx
  mov    %rdx,(%rbx)
  jmp    L300
L389:
  cmp    0x30(%rbx),%rax
  jne    L376
  cmp    0x28(%rbx),%rax
  jne    L376
  mov    0x30(%rsp),%rdx
  mov    %rdx,0x20(%rbx)
  mov    0x40(%rsp),%rdx
  mov    %rdx,0x30(%rbx)
  mov    0x38(%rsp),%rdx
  mov    %rdx,0x28(%rbx)
  jmp    L376
L282:
  cmp    0x10(%rbx),%rax
  jne    L100
  cmp    0x18(%rbx),%rax
  jne    L100
  mov    0x10(%rsp),%rax
  mov    %rax,(%rbx)
  mov    0x18(%rsp),%rax
  mov    %rax,0x8(%rbx)
  mov    %rdx,%rax
  sub    0x30(%rsp),%rax
  shr    $0x3f,%rax
  add    0x20(%rsp),%rax
  mov    %rax,0x10(%rbx)
  mov    $0x1,%esi
L275:
  mov    D12(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rbx)
  je     L100
L78:
  mov    D12(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  je     L375
L116:
  cmp    0x30(%rbx),%rax
  je     L152
L225:
  cmp    0x28(%rbx),%rax
  je     L228
L233:
  test   %esi,%esi
  jne    L48
  mov    0x10(%rbx),%rdx
  mov    0x8(%rbx),%rsi
  mov    (%rbx),%rax
  lea    0x76c(%rax),%rdi
  call   <check_mday@plt>
  mov    $0x8,%edx
  test   %eax,%eax
  je     L33
L48:
  mov    %rbx,%rdi
  call   <mktime@plt>
  cmp    $0xffffffffffffffff,%rax
  sete   %dl
  movzbl %dl,%edx
  shl    $0x3,%edx
L33:
  mov    0x68(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L238
  mov    %edx,%eax
  add    $0x78,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L375:
  movq   $0x0,0x20(%rbx)
  jmp    L116
L152:
  movq   $0x0,0x30(%rbx)
  jmp    L225
L228:
  movq   $0x0,0x28(%rbx)
  jmp    L233
L194:
  mov    $0x7,%edx
  jmp    L33
L237:
  mov    $0x7,%edx
  jmp    L33
L238:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int xgetdate_r(const char *string, struct tm *tp, const char *const *template) {
  const char *line;
  char *result = NULL;
  time_t timer;
  struct tm tm;
  int mday_ok = 0;
  line = NULL;
  while ((line = *template ++)) {
    tp->tm_year = tp->tm_mon = tp->tm_mday = tp->tm_wday = INT_MIN;
    tp->tm_hour = tp->tm_sec = tp->tm_min = INT_MIN;
    tp->tm_isdst = -1;
    tp->tm_gmtoff = 0;
    tp->tm_zone = NULL;
    result = my_strptime(string, line, tp);
    if (result && *result == '\0')
      break;
  }
  if (result == NULL || *result != '\0')
    return 7;
  time(&timer);
  localtime_r(&timer, &tm);
  if (tp->tm_wday >= 0 && tp->tm_wday <= 6 && tp->tm_year == INT_MIN && tp->tm_mon == INT_MIN && tp->tm_mday == INT_MIN) {
    tp->tm_year = tm.tm_year;
    tp->tm_mon = tm.tm_mon;
    tp->tm_mday = tm.tm_mday + (tp->tm_wday - tm.tm_wday + 7) % 7;
    mday_ok = 1;
  }
  if (tp->tm_mon >= 0 && tp->tm_mon <= 11 && tp->tm_mday == INT_MIN) {
    if (tp->tm_year == INT_MIN)
      tp->tm_year = tm.tm_year + (((tp->tm_mon - tm.tm_mon) < 0) ? 1 : 0);
    tp->tm_mday = first_wday(tp->tm_year, tp->tm_mon, tp->tm_wday);
    mday_ok = 1;
  }
  if (tp->tm_hour == INT_MIN && tp->tm_min == INT_MIN && tp->tm_sec == INT_MIN) {
    tp->tm_hour = tm.tm_hour;
    tp->tm_min = tm.tm_min;
    tp->tm_sec = tm.tm_sec;
  }
  if (tp->tm_hour >= 0 && tp->tm_hour <= 23 && tp->tm_year == INT_MIN && tp->tm_mon == INT_MIN && tp->tm_mday == INT_MIN && tp->tm_wday == INT_MIN) {
    tp->tm_year = tm.tm_year;
    tp->tm_mon = tm.tm_mon;
    tp->tm_mday = tm.tm_mday + ((tp->tm_hour - tm.tm_hour) < 0 ? 1 : 0);
    mday_ok = 1;
  }
  if (tp->tm_year == INT_MIN)
    tp->tm_year = tm.tm_year;
  if (tp->tm_hour == INT_MIN)
    tp->tm_hour = 0;
  if (tp->tm_min == INT_MIN)
    tp->tm_min = 0;
  if (tp->tm_sec == INT_MIN)
    tp->tm_sec = 0;
  if ((!mday_ok && !check_mday(1900 + tp->tm_year, tp->tm_mon, tp->tm_mday)) || mktime(tp) == (time_t)-1)
    return 8;
  return 0;
}
```