user: What is the c source code of the assembly code below?

```asm
<xgetdate_r>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x78,%rsp
  mov    (%rdx),%rsi
  mov    %fs:0x28,%rax
  mov    %rax,0x68(%rsp)
  xor    %eax,%eax
  test   %rsi,%rsi
  je     L105
  mov    D4(%rip),%r12
  mov    %rdi,%rbx
  lea    0x8(%rdx),%r13
  nopw   0x0(%rax,%rax,1)
L6:
  mov    (%r12),%rax
  mov    %rbp,%rdx
  mov    %rbx,%rdi
  movl   $0xffffffff,0x38(%rbp)
  movq   $0x0,0x48(%rbp)
  mov    %rax,0x18(%rbp)
  mov    %rax,0x10(%rbp)
  mov    %rax,0x8(%rbp)
  mov    %rax,0x0(%rbp)
  mov    %rax,0x30(%rbp)
  mov    %rax,0x28(%rbp)
  mov    %rax,0x20(%rbp)
  movq   $0x0,0x40(%rbp)
  call   <my_strptime@plt>
  test   %rax,%rax
  je     L248
  cmpb   $0x0,(%rax)
  je     L113
L248:
  mov    0x0(%r13),%rsi
  add    $0x8,%r13
  test   %rsi,%rsi
  jne    L6
  test   %rax,%rax
  je     L105
  cmpb   $0x0,(%rax)
  je     L113
L105:
  mov    $0x7,%eax
L243:
  mov    0x68(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L98
  add    $0x78,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L113:
  lea    0x8(%rsp),%r13
  mov    %r13,%rdi
  call   <time@plt>
  lea    0x10(%rsp),%rsi
  mov    %r13,%rdi
  call   <localtime_r@plt>
  mov    0x18(%rbp),%rsi
  cmp    $0x6,%rsi
  jbe    L325
  mov    (%r12),%rcx
  mov    0x8(%rbp),%r8
  xor    %r9d,%r9d
  mov    0x0(%rbp),%rdi
L76:
  cmp    $0xb,%r8
  ja     L269
  cmp    %rcx,0x10(%rbp)
  je     L184
L269:
  mov    0x20(%rbp),%rax
  mov    0x30(%rbp),%rdx
  mov    0x28(%rbp),%rsi
  cmp    %rcx,%rax
  je     L336
L276:
  cmp    $0x17,%rax
  ja     L204
  cmp    %rdi,%rcx
  je     L363
L24:
  cmp    %rax,%rcx
  je     L150
L360:
  cmp    %rdx,%rcx
  je     L148
L375:
  cmp    %rsi,%rcx
  je     L119
L77:
  test   %r9d,%r9d
  jne    L132
  mov    0x0(%rbp),%rax
  mov    0x10(%rbp),%rdx
  mov    0x8(%rbp),%rsi
  lea    0x76c(%rax),%rdi
  call   <check_mday@plt>
  test   %eax,%eax
  je     L262
L132:
  mov    %rbp,%rdi
  call   <mktime@plt>
  cmp    $0xffffffffffffffff,%rax
  sete   %al
  movzbl %al,%eax
  shl    $0x3,%eax
  jmp    L243
  nopl   0x0(%rax)
L325:
  mov    0x0(%rbp),%rdi
  mov    (%r12),%rcx
  xor    %r9d,%r9d
  mov    0x8(%rbp),%r8
  cmp    %rcx,%rdi
  jne    L76
  cmp    %r8,%rdi
  jne    L76
  cmp    0x10(%rbp),%rdi
  jne    L269
  mov    %rsi,%r9
  sub    0x28(%rsp),%r9
  mov    0x10(%rsp),%rdi
  movabs $0x4924924924924925,%rdx
  add    $0x7,%r9
  mov    0x18(%rsp),%r8
  mov    %r9,%rax
  mov    %rdi,0x0(%rbp)
  imul   %rdx
  mov    %r8,0x8(%rbp)
  mov    %rdx,%rax
  mov    %r9,%rdx
  sar    $0x3f,%rdx
  sar    %rax
  sub    %rdx,%rax
  lea    0x0(,%rax,8),%rdx
  sub    %rax,%rdx
  mov    %r9,%rax
  mov    $0x1,%r9d
  sub    %rdx,%rax
  add    0x20(%rsp),%rax
  mov    %rax,0x10(%rbp)
  jmp    L76
  xchg   %ax,%ax
L363:
  mov    0x10(%rsp),%rdi
  mov    %rdi,%r8
  cmp    %rcx,0x8(%rbp)
  jne    L231
  cmp    %rcx,0x10(%rbp)
  jne    L231
  cmp    %rcx,0x18(%rbp)
  jne    L231
  mov    0x18(%rsp),%r8
  mov    %rdi,0x0(%rbp)
  mov    $0x1,%r9d
  mov    %r8,0x8(%rbp)
  mov    %rax,%r8
  sub    0x30(%rsp),%r8
  shr    $0x3f,%r8
  add    0x20(%rsp),%r8
  mov    %r8,0x10(%rbp)
  nopw   0x0(%rax,%rax,1)
L204:
  cmp    %rcx,%rdi
  jne    L24
  mov    0x10(%rsp),%r8
L231:
  mov    %r8,0x0(%rbp)
  cmp    %rax,%rcx
  jne    L360
L150:
  movq   $0x0,0x20(%rbp)
  cmp    %rdx,%rcx
  jne    L375
L148:
  movq   $0x0,0x30(%rbp)
  cmp    %rsi,%rcx
  jne    L77
L119:
  movq   $0x0,0x28(%rbp)
  jmp    L77
L184:
  cmp    %rcx,%rdi
  je     L293
L125:
  mov    %esi,%edx
  mov    %r8,%rsi
  call   <first_wday@plt>
  mov    (%r12),%rcx
  mov    0x0(%rbp),%rdi
  mov    $0x1,%r9d
  mov    %rax,0x10(%rbp)
  jmp    L269
  nopl   0x0(%rax,%rax,1)
L336:
  cmp    %rcx,%rdx
  jne    L276
  cmp    %rsi,%rcx
  jne    L276
  mov    0x30(%rsp),%rax
  mov    0x40(%rsp),%rdx
  mov    0x38(%rsp),%rsi
  mov    %rax,0x20(%rbp)
  mov    %rdx,0x30(%rbp)
  mov    %rsi,0x28(%rbp)
  jmp    L276
L262:
  mov    $0x8,%eax
  jmp    L243
L293:
  mov    %r8,%rdi
  sub    0x18(%rsp),%rdi
  shr    $0x3f,%rdi
  add    0x10(%rsp),%rdi
  mov    %rdi,0x0(%rbp)
  jmp    L125
L98:
  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;
}
```