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;
}


x86 assembly (clang, -O0):
<parse_validity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0xf4(%rbp)
movl   $0x0,-0xf8(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     16d1 <parse_validity+0x551>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     16d1 <parse_validity+0x551>
movb   $0x0,-0x80(%rbp)
lea    -0xf0(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x64,%esi
lea    0xe1e(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
lea    -0xf0(%rbp),%rdi
mov    $0x0,%al
call   1070 <cutspaces@plt>
movl   $0x0,-0xfc(%rbp)
movslq -0xfc(%rbp),%rax
cmpb   $0x0,-0xf0(%rbp,%rax,1)
je     12b0 <parse_validity+0x130>
movslq -0xfc(%rbp),%rax
movsbl -0xf0(%rbp,%rax,1),%edi
ff
call   1060 <tolower@plt>
mov    %al,%cl
movslq -0xfc(%rbp),%rax
mov    %cl,-0xf0(%rbp,%rax,1)
movslq -0xfc(%rbp),%rax
movsbl -0xf0(%rbp,%rax,1),%eax
ff
cmp    $0x9,%eax
jne    1261 <parse_validity+0xe1>
movslq -0xfc(%rbp),%rax
movb   $0x20,-0xf0(%rbp,%rax,1)
20
movslq -0xfc(%rbp),%rax
movsbl -0xf0(%rbp,%rax,1),%edi
ff
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     128d <parse_validity+0x10d>
movl   $0x1,-0xf4(%rbp)
jmp    1297 <parse_validity+0x117>
movl   $0x1,-0xf8(%rbp)
jmp    129c <parse_validity+0x11c>
mov    -0xfc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfc(%rbp)
jmp    1201 <parse_validity+0x81>
cmpl   $0x0,-0xf4(%rbp)
je     130f <parse_validity+0x18f>
cmpl   $0x0,-0xf8(%rbp)
jne    130f <parse_validity+0x18f>
lea    -0xf0(%rbp),%rdi
mov    $0x0,%al
call   1080 <atoi@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jl     1304 <parse_validity+0x184>
cmpl   $0xff,-0x84(%rbp)
jg     1304 <parse_validity+0x184>
mov    -0x84(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    16d7 <parse_validity+0x557>
lea    -0xf0(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    %rax,-0x108(%rbp)
cmp    $0x0,%rax
je     133b <parse_validity+0x1bb>
mov    -0x108(%rbp),%rax
movb   $0x0,(%rax)
lea    -0xf0(%rbp),%rsi
lea    0xcba(%rip),%rdi
call   10a0 <strstr@plt>
cmp    $0x0,%rax
je     137b <parse_validity+0x1fb>
lea    -0x80(%rbp),%rdi
lea    -0xf0(%rbp),%rcx
lea    0xcb6(%rip),%rsi
mov    $0x61,%edx
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    1396 <parse_validity+0x216>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rcx
lea    0xc98(%rip),%rsi
mov    $0x63,%edx
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    139b <parse_validity+0x21b>
lea    -0x80(%rbp),%rdi
mov    $0x0,%al
call   1080 <atoi@plt>
mov    %eax,-0x84(%rbp)
cmp    $0x0,%eax
jle    16cc <parse_validity+0x54c>
lea    -0x80(%rbp),%rdi
lea    0xc72(%rip),%rsi
call   10a0 <strstr@plt>
cmp    $0x0,%rax
je     1446 <parse_validity+0x2c6>
cmpl   $0x2d0,-0x84(%rbp)
jg     141e <parse_validity+0x29e>
cmpl   $0x5,-0x84(%rbp)
jge    13f9 <parse_validity+0x279>
xor    %eax,%eax
mov    %eax,-0x10c(%rbp)
jmp    1410 <parse_validity+0x290>
mov    -0x84(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
sub    $0x1,%eax
mov    %eax,-0x10c(%rbp)
mov    -0x10c(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    16cc <parse_validity+0x54c>
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    %edx,-0x84(%rbp)
lea    0xbe8(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x80(%rbp),%rdi
lea    0xbef(%rip),%rsi
call   10a0 <strstr@plt>
cmp    $0x0,%rax
je     14d9 <parse_validity+0x359>
cmpl   $0xc,-0x84(%rbp)
jg     148b <parse_validity+0x30b>
lea    -0x80(%rbp),%rdi
imul   $0x3c,-0x84(%rbp),%edx
lea    0xbb0(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    139b <parse_validity+0x21b>
cmpl   $0x18,-0x84(%rbp)
jg     14b1 <parse_validity+0x331>
mov    -0x84(%rbp),%eax
sub    $0xc,%eax
shl    $0x1,%eax
add    $0x8f,%eax
mov    %eax,-0x18(%rbp)
jmp    16cc <parse_validity+0x54c>
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%eax
mov    $0x18,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    %edx,-0x84(%rbp)
lea    0xb64(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x80(%rbp),%rdi
lea    0xb55(%rip),%rsi
call   10a0 <strstr@plt>
cmp    $0x0,%rax
je     158d <parse_validity+0x40d>
cmpl   $0x2,-0x84(%rbp)
jge    1517 <parse_validity+0x397>
lea    -0x80(%rbp),%rdi
lea    0xb32(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    139b <parse_validity+0x21b>
cmpl   $0x22,-0x84(%rbp)
jg     1565 <parse_validity+0x3e5>
cmpl   $0x1e,-0x84(%rbp)
jg     1547 <parse_validity+0x3c7>
mov    -0x84(%rbp),%eax
add    $0xa6,%eax
mov    %eax,-0x110(%rbp)
jmp    1557 <parse_validity+0x3d7>
mov    $0xc4,%eax
mov    %eax,-0x110(%rbp)
jmp    1557 <parse_validity+0x3d7>
mov    -0x110(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    16cc <parse_validity+0x54c>
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    %edx,-0x84(%rbp)
lea    0xabf(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x80(%rbp),%rdi
lea    0xabe(%rip),%rsi
call   10a0 <strstr@plt>
cmp    $0x0,%rax
je     1613 <parse_validity+0x493>
cmpl   $0x5,-0x84(%rbp)
jge    15d2 <parse_validity+0x452>
lea    -0x80(%rbp),%rdi
imul   $0x7,-0x84(%rbp),%edx
lea    0xa70(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    139b <parse_validity+0x21b>
cmpl   $0x3f,-0x84(%rbp)
jg     15f5 <parse_validity+0x475>
mov    -0x84(%rbp),%eax
add    $0xc0,%eax
mov    %eax,-0x114(%rbp)
jmp    1605 <parse_validity+0x485>
mov    $0xff,%eax
mov    %eax,-0x114(%rbp)
jmp    1605 <parse_validity+0x485>
mov    -0x114(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    16cc <parse_validity+0x54c>
lea    -0x80(%rbp),%rdi
lea    0xa2f(%rip),%rsi
call   10a0 <strstr@plt>
cmp    $0x0,%rax
je     1682 <parse_validity+0x502>
lea    -0x80(%rbp),%rax
mov    %rax,-0x120(%rbp)
cmpl   $0xc,-0x84(%rbp)
jne    1655 <parse_validity+0x4d5>
mov    $0x16d,%eax
mov    %eax,-0x124(%rbp)
jmp    1662 <parse_validity+0x4e2>
imul   $0x1e,-0x84(%rbp),%eax
mov    %eax,-0x124(%rbp)
mov    -0x120(%rbp),%rdi
mov    -0x124(%rbp),%edx
lea    0x9c0(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    139b <parse_validity+0x21b>
lea    -0x80(%rbp),%rdi
lea    0x98e(%rip),%rsi
call   10a0 <strstr@plt>
cmp    $0x0,%rax
je     16c7 <parse_validity+0x547>
cmpl   $0x1,-0x84(%rbp)
jne    16c0 <parse_validity+0x540>
lea    -0x80(%rbp),%rdi
lea    0x99f(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
jmp    139b <parse_validity+0x21b>
movl   $0xff,-0x18(%rbp)
jmp    16cc <parse_validity+0x54c>
jmp    16d1 <parse_validity+0x551>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_validity>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %esi,%r13d
test   %rdi,%rdi
je     14c6 <parse_validity+0x356>
mov    %rdi,%r15
cmpb   $0x0,(%rdi)
je     14c6 <parse_validity+0x356>
movb   $0x0,0x80(%rsp)
lea    0xe58(%rip),%rdx
xor    %ebp,%ebp
lea    0x10(%rsp),%r14
mov    $0x64,%esi
mov    %r14,%rdi
mov    %r15,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <cutspaces@plt>
mov    0x10(%rsp),%al
test   %al,%al
je     1245 <parse_validity+0xd5>
mov    %r13d,0xc(%rsp)
lea    0x11(%rsp),%rbx
mov    $0x20,%r14d
mov    $0x1,%r12d
xor    %r13d,%r13d
nopl   0x0(%rax)
movsbl %al,%edi
call   1050 <tolower@plt>
cmp    $0x9,%al
cmove  %r14d,%eax
movsbl %al,%ecx
add    $0xffffffd0,%ecx
cmp    $0xa,%ecx
cmovb  %r12d,%r13d
cmovae %r12d,%ebp
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11f0 <parse_validity+0x80>
test   %r13d,%r13d
mov    0xc(%rsp),%r13d
je     1245 <parse_validity+0xd5>
test   %ebp,%ebp
jne    1245 <parse_validity+0xd5>
lea    0x10(%rsp),%rdi
xor    %eax,%eax
call   1070 <atoi@plt>
cmp    $0x100,%eax
cmovb  %eax,%r13d
jmp    14c6 <parse_validity+0x356>
lea    0x10(%rsp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     125c <parse_validity+0xec>
movb   $0x0,(%rax)
lea    0xda0(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     128d <parse_validity+0x11d>
lea    0xda7(%rip),%rsi
lea    0x80(%rsp),%rdi
lea    0x10(%rsp),%rcx
mov    $0x61,%edx
jmp    12a4 <parse_validity+0x134>
lea    0xd8e(%rip),%rsi
lea    0x80(%rsp),%rdi
mov    $0x63,%edx
mov    %r15,%rcx
xor    %eax,%eax
call   1080 <sprintf@plt>
lea    0x80(%rsp),%rdi
xor    %eax,%eax
call   1070 <atoi@plt>
test   %eax,%eax
jle    14c6 <parse_validity+0x356>
mov    %eax,%r12d
lea    0xd66(%rip),%r14
lea    0x80(%rsp),%rbx
lea    0xd4f(%rip),%r15
lea    0xd54(%rip),%rbp
jmp    131a <parse_validity+0x1aa>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
imul   $0x3c,%r12d,%edx
mov    %rbx,%rdi
lea    0xd31(%rip),%rsi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <atoi@plt>
mov    %eax,%r12d
test   %eax,%eax
jle    14c6 <parse_validity+0x356>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     135b <parse_validity+0x1eb>
cmp    $0x2d0,%r12d
jbe    14a0 <parse_validity+0x330>
mov    %r12d,%r12d
mov    $0x88888889,%eax
imul   %rax,%r12
shr    $0x25,%r12
mov    %rbx,%rdi
lea    0xcd6(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     139f <parse_validity+0x22f>
cmp    $0xc,%r12d
jbe    12f0 <parse_validity+0x180>
cmp    $0x18,%r12d
jbe    14be <parse_validity+0x34e>
mov    %r12d,%r12d
mov    $0xaaaaaaab,%eax
imul   %rax,%r12
shr    $0x24,%r12
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
lea    0xc90(%rip),%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     1409 <parse_validity+0x299>
cmp    $0x1,%r12d
ja     13d0 <parse_validity+0x260>
movabs $0x72756f68203432,%rax
mov    %rax,0x80(%rsp)
jmp    1305 <parse_validity+0x195>
cmp    $0x22,%r12d
jbe    14f2 <parse_validity+0x382>
mov    %r12d,%eax
imul   $0x24924925,%rax,%rax
shr    $0x20,%rax
sub    %eax,%r12d
shr    %r12d
add    %eax,%r12d
shr    $0x2,%r12d
mov    %rbx,%rdi
lea    0xc3e(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
lea    0xc2d(%rip),%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     1434 <parse_validity+0x2c4>
cmp    $0x4,%r12d
ja     14db <parse_validity+0x36b>
lea    0x0(,%r12,8),%edx
sub    %r12d,%edx
jmp    1460 <parse_validity+0x2f0>
mov    %rbx,%rdi
lea    0xc07(%rip),%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     146b <parse_validity+0x2fb>
mov    %r12d,%edx
shl    $0x5,%edx
sub    %r12d,%edx
sub    %r12d,%edx
cmp    $0xc,%r12d
mov    $0x16d,%eax
cmove  %eax,%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
jmp    12fe <parse_validity+0x18e>
mov    %rbx,%rdi
lea    0xba6(%rip),%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     14c6 <parse_validity+0x356>
cmp    $0x1,%r12d
jne    1509 <parse_validity+0x399>
movabs $0x6b656577203235,%rax
mov    %rax,0x80(%rsp)
jmp    1305 <parse_validity+0x195>
xor    %r13d,%r13d
cmp    $0x5,%r12d
jb     14c6 <parse_validity+0x356>
movzwl %r12w,%eax
imul   $0xcccd,%eax,%r13d
shr    $0x12,%r13d
add    $0xffffffff,%r13d
jmp    14c6 <parse_validity+0x356>
lea    (%r12,%r12,1),%r13d
add    $0x77,%r13d
mov    %r13d,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc0(%r12),%eax
cmp    $0x40,%r12d
mov    $0xff,%r13d
jmp    123c <parse_validity+0xcc>
lea    0xa6(%r12),%eax
cmp    $0x1f,%r12d
mov    $0xc4,%r13d
jmp    123c <parse_validity+0xcc>
mov    $0xff,%r13d
jmp    14c6 <parse_validity+0x356>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [29 x i8] c"min hour day week month year\00"
@.str.2 = [7 x i8] c"1 %.*s\00"
@.str.3 = [5 x i8] c"%.*s\00"
@.str.4 = [4 x i8] c"min\00"
@.str.5 = [8 x i8] c"%i hour\00"
@.str.6 = [5 x i8] c"hour\00"
@.str.7 = [7 x i8] c"%i min\00"
@.str.8 = [7 x i8] c"%i day\00"
@.str.9 = [4 x i8] c"day\00"
@.str.10 = [8 x i8] c"24 hour\00"
@.str.11 = [8 x i8] c"%i week\00"
@.str.12 = [5 x i8] c"week\00"
@.str.13 = [6 x i8] c"month\00"
@.str.14 = [5 x i8] c"year\00"
@.str.15 = [8 x i8] c"52 week\00"
define i32 @parse_validity(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca i32
%9 = alloca [100 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
%14 = load i32, i32* %5
store i32 %14, i32* %6
store i32 0, i32* %10
store i32 0, i32* %11
%15 = load i8*, i8** %4
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %234
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %234
22: ; preds = %17
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
store i8 0, i8* %23
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%25 = load i8*, i8** %4
%26 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %24, i64 100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%28 = call i32 (i8*, ...) bitcast (i32 (...)* @cutspaces to i32 (i8*, ...)*)(i8* %27)
store i32 0, i32* %12
br label %29
29: ; preds = %67, %22
%30 = load i32, i32* %12
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = icmp ne i8 %33, 0
br i1 %34, label %35, label %70
35: ; preds = %29
%36 = load i32, i32* %12
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = call i32 @tolower(i32 %40)
%42 = trunc i32 %41 to i8
%43 = load i32, i32* %12
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 %44
store i8 %42, i8* %45
%46 = load i32, i32* %12
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 9
br i1 %51, label %52, label %56
52: ; preds = %35
%53 = load i32, i32* %12
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 %54
store i8 32, i8* %55
br label %56
56: ; preds = %52, %35
%57 = load i32, i32* %12
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = call i32 @isdigit(i32 %61)
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %56
store i32 1, i32* %10
br label %66
65: ; preds = %56
store i32 1, i32* %11
br label %66
66: ; preds = %65, %64
br label %67
67: ; preds = %66
%68 = load i32, i32* %12
%69 = add nsw i32 %68, 1
store i32 %69, i32* %12
br label %29
70: ; preds = %29
%71 = load i32, i32* %10
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %88
73: ; preds = %70
%74 = load i32, i32* %11
%75 = icmp ne i32 %74, 0
br i1 %75, label %88, label %76
76: ; preds = %73
%77 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%78 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %77)
store i32 %78, i32* %8
%79 = load i32, i32* %8
%80 = icmp sge i32 %79, 0
br i1 %80, label %81, label %86
81: ; preds = %76
%82 = load i32, i32* %8
%83 = icmp sle i32 %82, 255
br i1 %83, label %84, label %86
84: ; preds = %81
%85 = load i32, i32* %8
store i32 %85, i32* %6
br label %86
86: ; preds = %84, %81, %76
%87 = load i32, i32* %6
store i32 %87, i32* %3
br label %236
88: ; preds = %73, %70
%89 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%90 = call i8* @strchr(i8* %89, i32 32)
store i8* %90, i8** %13
%91 = icmp ne i8* %90, null
br i1 %91, label %92, label %94
92: ; preds = %88
%93 = load i8*, i8** %13
store i8 0, i8* %93
br label %94
94: ; preds = %92, %88
%95 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%96 = call i8* @strstr(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %95)
%97 = icmp ne i8* %96, null
br i1 %97, label %98, label %102
98: ; preds = %94
%99 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%100 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%101 = call i32 (i8*, i8*, ...) @sprintf(i8* %99, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 97, i8* %100)
br label %106
102: ; preds = %94
%103 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%104 = load i8*, i8** %4
%105 = call i32 (i8*, i8*, ...) @sprintf(i8* %103, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 99, i8* %104)
br label %106
106: ; preds = %102, %98
br label %107
107: ; preds = %228, %218, %192, %165, %140, %106
%108 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%109 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %108)
store i32 %109, i32* %8
%110 = icmp sgt i32 %109, 0
br i1 %110, label %111, label %233
111: ; preds = %107
%112 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%113 = call i8* @strstr(i8* %112, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%114 = icmp ne i8* %113, null
br i1 %114, label %115, label %133
115: ; preds = %111
%116 = load i32, i32* %8
%117 = icmp sle i32 %116, 720
br i1 %117, label %118, label %128
118: ; preds = %115
%119 = load i32, i32* %8
%120 = icmp slt i32 %119, 5
br i1 %120, label %121, label %122
121: ; preds = %118
br label %126
122: ; preds = %118
%123 = load i32, i32* %8
%124 = sdiv i32 %123, 5
%125 = sub nsw i32 %124, 1
br label %126
126: ; preds = %122, %121
%127 = phi i32 [ 0, %121 ], [ %125, %122 ]
store i32 %127, i32* %6
br label %233
128: ; preds = %115
%129 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%130 = load i32, i32* %8
%131 = sdiv i32 %130, 60
store i32 %131, i32* %8
%132 = call i32 (i8*, i8*, ...) @sprintf(i8* %129, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %131)
br label %133
133: ; preds = %128, %111
%134 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%135 = call i8* @strstr(i8* %134, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%136 = icmp ne i8* %135, null
br i1 %136, label %137, label %158
137: ; preds = %133
%138 = load i32, i32* %8
%139 = icmp sle i32 %138, 12
br i1 %139, label %140, label %145
140: ; preds = %137
%141 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%142 = load i32, i32* %8
%143 = mul nsw i32 %142, 60
%144 = call i32 (i8*, i8*, ...) @sprintf(i8* %141, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %143)
br label %107
145: ; preds = %137
%146 = load i32, i32* %8
%147 = icmp sle i32 %146, 24
br i1 %147, label %148, label %153
148: ; preds = %145
%149 = load i32, i32* %8
%150 = sub nsw i32 %149, 12
%151 = mul nsw i32 %150, 2
%152 = add nsw i32 %151, 143
store i32 %152, i32* %6
br label %233
153: ; preds = %145
%154 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%155 = load i32, i32* %8
%156 = sdiv i32 %155, 24
store i32 %156, i32* %8
%157 = call i32 (i8*, i8*, ...) @sprintf(i8* %154, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %156)
br label %158
158: ; preds = %153, %133
%159 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%160 = call i8* @strstr(i8* %159, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%161 = icmp ne i8* %160, null
br i1 %161, label %162, label %185
162: ; preds = %158
%163 = load i32, i32* %8
%164 = icmp slt i32 %163, 2
br i1 %164, label %165, label %168
165: ; preds = %162
%166 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%167 = call i32 (i8*, i8*, ...) @sprintf(i8* %166, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
br label %107
168: ; preds = %162
%169 = load i32, i32* %8
%170 = icmp sle i32 %169, 34
br i1 %170, label %171, label %180
171: ; preds = %168
%172 = load i32, i32* %8
%173 = icmp sle i32 %172, 30
br i1 %173, label %174, label %177
174: ; preds = %171
%175 = load i32, i32* %8
%176 = add nsw i32 %175, 166
br label %178
177: ; preds = %171
br label %178
178: ; preds = %177, %174
%179 = phi i32 [ %176, %174 ], [ 196, %177 ]
store i32 %179, i32* %6
br label %233
180: ; preds = %168
%181 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%182 = load i32, i32* %8
%183 = sdiv i32 %182, 7
store i32 %183, i32* %8
%184 = call i32 (i8*, i8*, ...) @sprintf(i8* %181, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i32 %183)
br label %185
185: ; preds = %180, %158
%186 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%187 = call i8* @strstr(i8* %186, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%188 = icmp ne i8* %187, null
br i1 %188, label %189, label %206
189: ; preds = %185
%190 = load i32, i32* %8
%191 = icmp slt i32 %190, 5
br i1 %191, label %192, label %197
192: ; preds = %189
%193 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%194 = load i32, i32* %8
%195 = mul nsw i32 %194, 7
%196 = call i32 (i8*, i8*, ...) @sprintf(i8* %193, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %195)
br label %107
197: ; preds = %189
%198 = load i32, i32* %8
%199 = icmp sle i32 %198, 63
br i1 %199, label %200, label %203
200: ; preds = %197
%201 = load i32, i32* %8
%202 = add nsw i32 %201, 192
br label %204
203: ; preds = %197
br label %204
204: ; preds = %203, %200
%205 = phi i32 [ %202, %200 ], [ 255, %203 ]
store i32 %205, i32* %6
br label %233
206: ; preds = %185
%207 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%208 = call i8* @strstr(i8* %207, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
%209 = icmp ne i8* %208, null
br i1 %209, label %210, label %221
210: ; preds = %206
%211 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%212 = load i32, i32* %8
%213 = icmp eq i32 %212, 12
br i1 %213, label %214, label %215
214: ; preds = %210
br label %218
215: ; preds = %210
%216 = load i32, i32* %8
%217 = mul nsw i32 %216, 30
br label %218
218: ; preds = %215, %214
%219 = phi i32 [ 365, %214 ], [ %217, %215 ]
%220 = call i32 (i8*, i8*, ...) @sprintf(i8* %211, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %219)
br label %107
221: ; preds = %206
%222 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%223 = call i8* @strstr(i8* %222, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%224 = icmp ne i8* %223, null
br i1 %224, label %225, label %232
225: ; preds = %221
%226 = load i32, i32* %8
%227 = icmp eq i32 %226, 1
br i1 %227, label %228, label %231
228: ; preds = %225
%229 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%230 = call i32 (i8*, i8*, ...) @sprintf(i8* %229, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0))
br label %107
231: ; preds = %225
store i32 255, i32* %6
br label %232
232: ; preds = %231, %221
br label %233
233: ; preds = %232, %204, %178, %148, %126, %107
br label %234
234: ; preds = %233, %17, %2
%235 = load i32, i32* %6
store i32 %235, i32* %3
br label %236
236: ; preds = %234, %86
%237 = load i32, i32* %3
ret i32 %237
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [29 x i8] c"min hour day week month year\00"
@.str.2 = [7 x i8] c"1 %.*s\00"
@.str.3 = [5 x i8] c"%.*s\00"
@.str.4 = [4 x i8] c"min\00"
@.str.5 = [8 x i8] c"%i hour\00"
@.str.6 = [5 x i8] c"hour\00"
@.str.7 = [7 x i8] c"%i min\00"
@.str.8 = [7 x i8] c"%i day\00"
@.str.9 = [4 x i8] c"day\00"
@.str.11 = [8 x i8] c"%i week\00"
@.str.12 = [5 x i8] c"week\00"
@.str.13 = [6 x i8] c"month\00"
@.str.14 = [5 x i8] c"year\00"
define i32 @parse_validity(i8* %0, i32 %1) {
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%7 = icmp eq i8* %0, null
br i1 %7, label %140, label %8
8: ; preds = %2
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 0
br i1 %10, label %140, label %11
11: ; preds = %8
store i8 0, i8* %5
%12 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %6, i64 100, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%13 = call i32 (i8*, ...) bitcast (i32 (...)* @cutspaces to i32 (i8*, ...)*)(i8* %6)
%14 = load i8, i8* %6
%15 = icmp eq i8 %14, 0
br i1 %15, label %45, label %16
16: ; preds = %11, %16
%17 = phi i64 [ %33, %16 ], [ 0, %11 ]
%18 = phi i8 [ %35, %16 ], [ %14, %11 ]
%19 = phi i8* [ %34, %16 ], [ %6, %11 ]
%20 = phi i32 [ %32, %16 ], [ 0, %11 ]
%21 = phi i32 [ %31, %16 ], [ 0, %11 ]
%22 = sext i8 %18 to i32
%23 = call i32 @tolower(i32 %22)
%24 = trunc i32 %23 to i8
%25 = and i32 %23, 255
%26 = icmp eq i32 %25, 9
%27 = select i1 %26, i8 32, i8 %24
store i8 %27, i8* %19
%28 = sext i8 %27 to i32
%29 = add nsw i32 %28, -48
%30 = icmp ult i32 %29, 10
%31 = select i1 %30, i32 1, i32 %21
%32 = select i1 %30, i32 %20, i32 1
%33 = add nuw nsw i64 %17, 1
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
br i1 %36, label %37, label %16
37: ; preds = %16
%38 = icmp eq i32 %31, 0
%39 = icmp ne i32 %32, 0
%40 = select i1 %38, i1 true, i1 %39
br i1 %40, label %45, label %41
41: ; preds = %37
%42 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %6)
%43 = icmp ult i32 %42, 256
%44 = select i1 %43, i32 %42, i32 %1
br label %140
45: ; preds = %11, %37
%46 = call i8* @strchr(i8* %6, i32 32)
%47 = icmp eq i8* %46, null
br i1 %47, label %49, label %48
48: ; preds = %45
store i8 0, i8* %46
br label %49
49: ; preds = %48, %45
%50 = call i8* @strstr(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%51 = icmp eq i8* %50, null
br i1 %51, label %54, label %52
52: ; preds = %49
%53 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 97, i8* %6)
br label %56
54: ; preds = %49
%55 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 99, i8* %0)
br label %56
56: ; preds = %54, %52
%57 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %5)
%58 = icmp sgt i32 %57, 0
br i1 %58, label %59, label %140
59: ; preds = %56
%60 = bitcast [100 x i8]* %3 to i64*
br label %61
61: ; preds = %59, %86
%62 = phi i32 [ %57, %59 ], [ %87, %86 ]
%63 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%64 = icmp eq i8* %63, null
br i1 %64, label %77, label %65
65: ; preds = %61
%66 = icmp ult i32 %62, 721
br i1 %66, label %67, label %74
67: ; preds = %65
%68 = icmp ult i32 %62, 5
br i1 %68, label %140, label %69
69: ; preds = %67
%70 = trunc i32 %62 to i16
%71 = udiv i16 %70, 5
%72 = zext i16 %71 to i32
%73 = add nsw i32 %72, -1
br label %140
74: ; preds = %65
%75 = udiv i32 %62, 60
%76 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %74, %61
%78 = phi i32 [ %75, %74 ], [ %62, %61 ]
%79 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%80 = icmp eq i8* %79, null
br i1 %80, label %97, label %81
81: ; preds = %77
%82 = icmp ult i32 %78, 13
br i1 %82, label %83, label %89
83: ; preds = %81
%84 = mul nuw nsw i32 %78, 60
%85 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %84)
br label %86
86: ; preds = %83, %103, %119, %129, %139
%87 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %5)
%88 = icmp sgt i32 %87, 0
br i1 %88, label %61, label %140
89: ; preds = %81
%90 = icmp ult i32 %78, 25
br i1 %90, label %91, label %94
91: ; preds = %89
%92 = shl nuw nsw i32 %78, 1
%93 = add nuw nsw i32 %92, 119
br label %140
94: ; preds = %89
%95 = udiv i32 %78, 24
%96 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %95)
br label %97
97: ; preds = %94, %77
%98 = phi i32 [ %95, %94 ], [ %78, %77 ]
%99 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%100 = icmp eq i8* %99, null
br i1 %100, label %113, label %101
101: ; preds = %97
%102 = icmp ult i32 %98, 2
br i1 %102, label %103, label %104
103: ; preds = %101
store i64 32217268693775410, i64* %60
br label %86
104: ; preds = %101
%105 = icmp ult i32 %98, 35
br i1 %105, label %106, label %110
106: ; preds = %104
%107 = icmp ult i32 %98, 31
%108 = add nuw nsw i32 %98, 166
%109 = select i1 %107, i32 %108, i32 196
br label %140
110: ; preds = %104
%111 = udiv i32 %98, 7
%112 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i32 %111)
br label %113
113: ; preds = %110, %97
%114 = phi i32 [ %111, %110 ], [ %98, %97 ]
%115 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%116 = icmp eq i8* %115, null
br i1 %116, label %126, label %117
117: ; preds = %113
%118 = icmp ult i32 %114, 5
br i1 %118, label %119, label %122
119: ; preds = %117
%120 = mul nuw nsw i32 %114, 7
%121 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %120)
br label %86
122: ; preds = %117
%123 = icmp ult i32 %114, 64
%124 = add nuw nsw i32 %114, 192
%125 = select i1 %123, i32 %124, i32 255
br label %140
126: ; preds = %113
%127 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
%128 = icmp eq i8* %127, null
br i1 %128, label %134, label %129
129: ; preds = %126
%130 = icmp eq i32 %114, 12
%131 = mul nsw i32 %114, 30
%132 = select i1 %130, i32 365, i32 %131
%133 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %132)
br label %86
134: ; preds = %126
%135 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
%136 = icmp eq i8* %135, null
br i1 %136, label %140, label %137
137: ; preds = %134
%138 = icmp eq i32 %114, 1
br i1 %138, label %139, label %140
139: ; preds = %137
store i64 30229308972741173, i64* %60
br label %86
140: ; preds = %137, %86, %134, %56, %2, %8, %122, %106, %91, %67, %69, %41
%141 = phi i32 [ %44, %41 ], [ %93, %91 ], [ %109, %106 ], [ %125, %122 ], [ %1, %8 ], [ %1, %2 ], [ %73, %69 ], [ 0, %67 ], [ %1, %56 ], [ 255, %137 ], [ %1, %86 ], [ %1, %134 ]
ret i32 %141
}