user: 请从给定的汇编指令推导出C源代码:

```asm
<parse_validity>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xe8,%rsp
  mov    %esi,%r12d
  mov    %fs:0x28,%rax
  mov    %rax,0xd8(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  je     L357
  mov    %rdi,%rbp
  cmpb   $0x0,(%rdi)
  jne    L69
L357:
  mov    0xd8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L260
  mov    %r12d,%eax
  add    $0xe8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L69:
  movb   $0x0,(%rsp)
  lea    0x70(%rsp),%rbx
  mov    %rdi,%rcx
  lea    D19(%rip),%rdx
  mov    $0x64,%esi
  mov    %rbx,%rdi
  call   <snprintf@plt>
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <cutspaces@plt>
  movzbl 0x70(%rsp),%edi
  test   %dil,%dil
  je     L249
  mov    $0x0,%r14d
  mov    $0x0,%r13d
  mov    $0x1,%r15d
  jmp    L330
L87:
  mov    %dl,(%rcx)
  movsbl %dl,%edx
  sub    $0x30,%edx
  cmp    $0xa,%edx
  cmovae %r15d,%r14d
  cmovb  %r15d,%r13d
  add    $0x1,%rbx
  movzbl (%rbx),%edi
  test   %dil,%dil
  je     L125
L330:
  movsbl %dil,%edi
  call   <tolower@plt>
  mov    %rbx,%rcx
  mov    %al,(%rbx)
  mov    $0x20,%edx
  cmp    $0x9,%al
  je     L87
  mov    %eax,%edx
  jmp    L87
L125:
  test   %r13d,%r13d
  je     L249
  test   %r14d,%r14d
  je     L166
L249:
  lea    0x70(%rsp),%rdi
  mov    $0x20,%esi
  call   <strchr@plt>
  test   %rax,%rax
  je     L79
  movb   $0x0,(%rax)
L79:
  lea    0x70(%rsp),%rsi
  lea    D76(%rip),%rdi
  call   <strstr@plt>
  test   %rax,%rax
  je     L194
  lea    0x70(%rsp),%rcx
  mov    %rsp,%rdi
  mov    $0x61,%edx
  lea    D154(%rip),%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
L325:
  lea    D74(%rip),%rbp
  lea    D77(%rip),%r13
  lea    D110(%rip),%r15
L242:
  mov    %rsp,%rdi
  mov    $0x0,%eax
  call   <atoi@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  jle    L357
  mov    %rsp,%rdi
  mov    %rbp,%rsi
  call   <strstr@plt>
  test   %rax,%rax
  je     L373
  cmp    $0x2d0,%ebx
  jle    L61
  movslq %ebx,%rdx
  imul   $0xffffffff88888889,%rdx,%rdx
  shr    $0x20,%rdx
  add    %ebx,%edx
  sar    $0x5,%edx
  sar    $0x1f,%ebx
  sub    %ebx,%edx
  mov    %edx,%ebx
  mov    %rsp,%rdi
  lea    D117(%rip),%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
L373:
  mov    %rsp,%rdi
  mov    %r13,%rsi
  call   <strstr@plt>
  test   %rax,%rax
  je     L377
  cmp    $0xc,%ebx
  jle    L372
  cmp    $0x18,%ebx
  jle    L93
  movslq %ebx,%rdx
  imul   $0x2aaaaaab,%rdx,%rdx
  sar    $0x22,%rdx
  sar    $0x1f,%ebx
  sub    %ebx,%edx
  mov    %edx,%ebx
  mov    %rsp,%rdi
  lea    D46(%rip),%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
L377:
  mov    %rsp,%rdi
  mov    %r15,%rsi
  call   <strstr@plt>
  test   %rax,%rax
  je     L403
  cmp    $0x1,%ebx
  jle    L396
  cmp    $0x22,%ebx
  jle    L302
  movslq %ebx,%rdx
  imul   $0xffffffff92492493,%rdx,%rdx
  shr    $0x20,%rdx
  add    %ebx,%edx
  sar    $0x2,%edx
  sar    $0x1f,%ebx
  sub    %ebx,%edx
  mov    %edx,%ebx
  mov    %rsp,%r14
  lea    D92(%rip),%rsi
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  lea    D146(%rip),%rsi
  mov    %r14,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  je     L172
L371:
  mov    $0x3f,%eax
  cmp    %eax,%ebx
  cmovg  %eax,%ebx
  lea    0xc0(%rbx),%r12d
  jmp    L357
L166:
  lea    0x70(%rsp),%rdi
  mov    $0x0,%eax
  call   <atoi@plt>
  cmp    $0xff,%eax
  cmovbe %eax,%r12d
  jmp    L357
L194:
  mov    %rsp,%rdi
  mov    %rbp,%rcx
  mov    $0x63,%edx
  lea    D99(%rip),%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L325
L61:
  mov    $0x0,%r12d
  cmp    $0x4,%ebx
  jle    L357
  movslq %ebx,%r12
  imul   $0x66666667,%r12,%r12
  sar    $0x21,%r12
  sar    $0x1f,%ebx
  sub    %ebx,%r12d
  sub    $0x1,%r12d
  jmp    L357
L372:
  imul   $0x3c,%ebx,%edx
  mov    %rsp,%rdi
  lea    D91(%rip),%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L242
L93:
  lea    0x77(%rbx,%rbx,1),%r12d
  jmp    L357
L396:
  movabs $0x72756f68203432,%rax
  mov    %rax,(%rsp)
  jmp    L242
L302:
  mov    $0x1e,%eax
  cmp    %eax,%ebx
  cmovle %ebx,%eax
  lea    0xa6(%rax),%r12d
  jmp    L357
L403:
  mov    %rsp,%rdi
  lea    D146(%rip),%rsi
  call   <strstr@plt>
  test   %rax,%rax
  je     L172
  cmp    $0x4,%ebx
  jg     L371
  lea    0x0(,%rbx,8),%edx
  sub    %ebx,%edx
  mov    %rsp,%rdi
  lea    D46(%rip),%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L242
L172:
  mov    %rsp,%rdi
  lea    D2(%rip),%rsi
  call   <strstr@plt>
  test   %rax,%rax
  je     L299
  mov    $0x16d,%edx
  cmp    $0xc,%ebx
  je     L27
  imul   $0x1e,%ebx,%edx
L27:
  mov    %rsp,%rdi
  lea    D46(%rip),%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L242
L299:
  mov    %rsp,%rdi
  lea    D148(%rip),%rsi
  call   <strstr@plt>
  test   %rax,%rax
  je     L357
  cmp    $0x1,%ebx
  je     L277
  mov    $0xff,%r12d
  jmp    L357
L277:
  movabs $0x6b656577203235,%rax
  mov    %rax,(%rsp)
  jmp    L242
L260:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D19
datatype: string
name: read_data
arguments: data_tag: D76
datatype: string
name: read_data
arguments: data_tag: D154
datatype: string
name: read_data
arguments: data_tag: D74
datatype: string
name: read_data
arguments: data_tag: D77
datatype: string
name: read_data
arguments: data_tag: D110
datatype: string
name: read_data
arguments: data_tag: D117
datatype: string
name: read_data
arguments: data_tag: D46
datatype: string
name: read_data
arguments: data_tag: D92
datatype: string
name: read_data
arguments: data_tag: D146
datatype: string
name: read_data
arguments: data_tag: D99
datatype: string
name: read_data
arguments: data_tag: D91
datatype: string
name: read_data
arguments: data_tag: D2
datatype: string
name: read_data
arguments: data_tag: D148
datatype: string

tool: D19: %s

tool: D76: min hour day week month year

tool: D154: 1 %.*s

tool: D74: min

tool: D77: hour

tool: D110: day

tool: D117: %i hour

tool: D46: %i day

tool: D92: %i week

tool: D146: week

tool: D99: %.*s

tool: D91: %i min

tool: D2: month

tool: D148: year

assistant: ```c
int parse_validity(char *value, int defaultvalue) {
  int result = defaultvalue;
  char buffer[100];
  int i;
  char tmp[100];
  int got_numbers = 0;
  int got_letters = 0;
  int idx;
  char *p;
  if (value && *value) {
    *buffer = 0;
    snprintf(tmp, sizeof(tmp), "%s", value);
    cutspaces(tmp);
    for (idx = 0; tmp[idx]; idx++) {
      tmp[idx] = tolower((int)tmp[idx]);
      if (tmp[idx] == '\t')
        tmp[idx] = ' ';
      if (isdigit((int)(tmp[idx])))
        got_numbers = 1;
      else
        got_letters = 1;
    }
    if (got_numbers && !got_letters) {
      i = atoi(tmp);
      if (i >= 0 && i <= 255)
        result = i;
      return result;
    }
    if ((p = strchr(tmp, ' ')))
      *p = 0;
    if (strstr("min hour day week month year", tmp))
      sprintf(buffer, "1 %.*s", (int)sizeof(buffer) - 3, tmp);
    else
      sprintf(buffer, "%.*s", (int)sizeof(buffer) - 1, value);
    while ((i = atoi(buffer)) > 0) {
      if (strstr(buffer, "min")) {
        if (i <= 720) {
          result = (i < 5) ? 0 : i / 5 - 1;
          break;
        }
        sprintf(buffer, "%i hour", i /= 60);
      }
      if (strstr(buffer, "hour")) {
        if (i <= 12) {
          sprintf(buffer, "%i min", i * 60);
          continue;
        }
        if (i <= 24) {
          result = (i - 12) * 2 + 143;
          break;
        }
        sprintf(buffer, "%i day", i /= 24);
      }
      if (strstr(buffer, "day")) {
        if (i < 2) {
          sprintf(buffer, "24 hour");
          continue;
        }
        if (i <= 34) {
          result = (i <= 30) ? i + 166 : 30 + 166;
          break;
        }
        sprintf(buffer, "%i week", i /= 7);
      }
      if (strstr(buffer, "week")) {
        if (i < 5) {
          sprintf(buffer, "%i day", i * 7);
          continue;
        }
        result = (i <= 63) ? i + 192 : 255;
        break;
      }
      if (strstr(buffer, "month")) {
        sprintf(buffer, "%i day", (i == 12) ? 365 : i * 30);
        continue;
      }
      if (strstr(buffer, "year")) {
        if (i == 1) {
          sprintf(buffer, "52 week");
          continue;
        }
        result = 255;
      }
      break;
    }
  }
  return result;
}
```