#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef scalar_t__ time_t;
struct tm {
  int tm_mday;
  scalar_t__ tm_year;
  scalar_t__ tm_mon;
  scalar_t__ tm_isdst;
  scalar_t__ tm_yday;
  scalar_t__ tm_wday;
  scalar_t__ tm_hour;
  scalar_t__ tm_min;
  scalar_t__ tm_sec;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ dohelp(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
scalar_t__ mktime(struct tm *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int strtol(char *, int /*<<< orphan*/ *, int);
scalar_t__ time(int /*<<< orphan*/);
time_t parsetimestring(const char *dts) {
  struct tm dt;
  char work[32];
  time_t when;
  time_t now = time(0);
  dt.tm_sec = 0;
  dt.tm_min = 0;
  dt.tm_hour = 0;
  dt.tm_mday = 1;
  dt.tm_mon = 0;
  dt.tm_year = 0;
  dt.tm_wday = 0;
  dt.tm_yday = 0;
  dt.tm_isdst = 0;
  strcpy(work, dts);
  if (strlen(work) > 8)
    work[8] = '\0';
  switch (strlen(work)) {
    char buf[8];
  case 8:
    strncpy(buf, &work[6], 2);
    buf[2] = '\0';
    dt.tm_mday = strtol(buf, NULL, 10);
  case 6:
    strncpy(buf, &work[4], 2);
    buf[2] = '\0';
    dt.tm_mon = strtol(buf, NULL, 10) - 1;
  case 4:
    strncpy(buf, work, 4);
    buf[4] = '\0';
    dt.tm_year = strtol(buf, NULL, 10) - 1900;
    break;
  default:
    fprintf(stderr, "%s must be an even number long.\n", dts);
    dohelp(EXIT_FAILURE);
    break;
  }
  when = mktime(&dt);
  if (when > now) {
    fprintf(stderr, "%s is a time in the future.\n", dts);
    dohelp(EXIT_FAILURE);
  }
  return mktime(&dt);
}


x86 assembly (clang, -O0):
<parsetimestring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
xor    %edi,%edi
call   1090 <time@plt>
mov    %rax,-0x80(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x50(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x70(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x8,%eax
jle    1204 <parsetimestring+0x84>
movb   $0x0,-0x68(%rbp)
lea    -0x70(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    %ecx,-0x8c(%rbp)
sub    $0x4,%eax
je     12c1 <parsetimestring+0x141>
jmp    1223 <parsetimestring+0xa3>
mov    -0x8c(%rbp),%eax
sub    $0x6,%eax
je     1283 <parsetimestring+0x103>
jmp    1237 <parsetimestring+0xb7>
mov    -0x8c(%rbp),%eax
sub    $0x8,%eax
jne    1302 <parsetimestring+0x182>
jmp    124b <parsetimestring+0xcb>
lea    -0x88(%rbp),%rdi
lea    -0x70(%rbp),%rsi
add    $0x6,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x86(%rbp)
lea    -0x88(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %eax,-0x50(%rbp)
lea    -0x88(%rbp),%rdi
lea    -0x70(%rbp),%rsi
add    $0x4,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x86(%rbp)
lea    -0x88(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1080 <strtol@plt>
sub    $0x1,%eax
cltq
mov    %rax,-0x40(%rbp)
lea    -0x88(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x84(%rbp)
lea    -0x88(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1080 <strtol@plt>
sub    $0x76c,%eax
cltq
mov    %rax,-0x48(%rbp)
jmp    1329 <parsetimestring+0x1a9>
mov    0x2cd7(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xcea(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2cb6(%rip),%rax
mov    (%rax),%edi
call   1050 <dohelp@plt>
lea    -0x50(%rbp),%rdi
call   10a0 <mktime@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
cmp    -0x80(%rbp),%rax
jle    136b <parsetimestring+0x1eb>
mov    0x2c95(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xcc9(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2c74(%rip),%rax
mov    (%rax),%edi
call   1050 <dohelp@plt>
lea    -0x50(%rbp),%rdi
call   10a0 <mktime@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsetimestring>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%r15
xor    %edi,%edi
call   1090 <time@plt>
mov    %rax,%r14
xorps  %xmm0,%xmm0
movups %xmm0,0x68(%rsp)
movq   $0x0,0x78(%rsp)
movl   $0x1,0x38(%rsp)
movups %xmm0,0x40(%rsp)
movups %xmm0,0x50(%rsp)
movq   $0x0,0x60(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cmp    $0x9,%eax
jl     11e7 <parsetimestring+0x67>
movb   $0x0,0x18(%rsp)
lea    0x10(%rsp),%rdi
call   1060 <strlen@plt>
cmp    $0x4,%eax
je     1268 <parsetimestring+0xe8>
cmp    $0x6,%eax
je     1233 <parsetimestring+0xb3>
cmp    $0x8,%eax
jne    12a1 <parsetimestring+0x121>
lea    0x16(%rsp),%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xa(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %eax,0x38(%rsp)
lea    0x14(%rsp),%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xa(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <strtol@plt>
add    $0xffffffff,%eax
cltq
mov    %rax,0x48(%rsp)
lea    0x8(%rsp),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xc(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <strtol@plt>
add    $0xfffff894,%eax
cltq
mov    %rax,0x40(%rsp)
jmp    12c7 <parsetimestring+0x147>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
lea    0xd4f(%rip),%rsi
mov    %r15,%rdx
call   1070 <fprintf@plt>
mov    0x2d18(%rip),%rax
mov    (%rax),%edi
call   1050 <dohelp@plt>
lea    0x38(%rsp),%rdi
call   10a0 <mktime@plt>
cmp    %r14,%rax
jle    12fc <parsetimestring+0x17c>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
lea    0xd3b(%rip),%rsi
mov    %r15,%rdx
call   1070 <fprintf@plt>
mov    0x2ce3(%rip),%rax
mov    (%rax),%edi
call   1050 <dohelp@plt>
lea    0x38(%rsp),%rdi
call   10a0 <mktime@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32, i64, i64, i64, i64, i64, i64, i64, i64 }
@stderr = global i32 0
@.str = [33 x i8] c"%s must be an even number long.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [29 x i8] c"%s is a time in the future.\0A\00"
define i64 @parsetimestring(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.tm
%4 = alloca [32 x i8]
%5 = alloca i64
%6 = alloca i64
%7 = alloca [8 x i8]
store i8* %0, i8** %2
%8 = call i64 @time(i32 0)
store i64 %8, i64* %6
%9 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 8
store i64 0, i64* %9
%10 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 7
store i64 0, i64* %10
%11 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 6
store i64 0, i64* %11
%12 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 0
store i32 1, i32* %12
%13 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 2
store i64 0, i64* %13
%14 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 1
store i64 0, i64* %14
%15 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 5
store i64 0, i64* %15
%16 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 4
store i64 0, i64* %16
%17 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 3
store i64 0, i64* %17
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%19 = load i8*, i8** %2
%20 = call i32 @strcpy(i8* %18, i8* %19)
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = icmp sgt i32 %22, 8
br i1 %23, label %24, label %26
24: ; preds = %1
%25 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 8
store i8 0, i8* %25
br label %26
26: ; preds = %24, %1
%27 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
switch i32 %28, label %57 [
i32 8, label %29
i32 6, label %37
i32 4, label %47
]
29: ; preds = %26
%30 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 6
%32 = call i32 @strncpy(i8* %30, i8* %31, i32 2)
%33 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 2
store i8 0, i8* %33
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%35 = call i32 @strtol(i8* %34, i32* null, i32 10)
%36 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 0
store i32 %35, i32* %36
br label %37
37: ; preds = %26, %29
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%39 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 4
%40 = call i32 @strncpy(i8* %38, i8* %39, i32 2)
%41 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 2
store i8 0, i8* %41
%42 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%43 = call i32 @strtol(i8* %42, i32* null, i32 10)
%44 = sub nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 2
store i64 %45, i64* %46
br label %47
47: ; preds = %26, %37
%48 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%49 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%50 = call i32 @strncpy(i8* %48, i8* %49, i32 4)
%51 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 4
store i8 0, i8* %51
%52 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%53 = call i32 @strtol(i8* %52, i32* null, i32 10)
%54 = sub nsw i32 %53, 1900
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 1
store i64 %55, i64* %56
br label %63
57: ; preds = %26
%58 = load i32, i32* @stderr
%59 = load i8*, i8** %2
%60 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %59)
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @dohelp(i32 %61)
br label %63
63: ; preds = %57, %47
%64 = call i64 @mktime(%struct.tm* %3)
store i64 %64, i64* %5
%65 = load i64, i64* %5
%66 = load i64, i64* %6
%67 = icmp sgt i64 %65, %66
br i1 %67, label %68, label %74
68: ; preds = %63
%69 = load i32, i32* @stderr
%70 = load i8*, i8** %2
%71 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %70)
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @dohelp(i32 %72)
br label %74
74: ; preds = %68, %63
%75 = call i64 @mktime(%struct.tm* %3)
ret i64 %75
}

LLVM IR (-O2):
%struct.tm = type { i32, i64, i64, i64, i64, i64, i64, i64, i64 }
@stderr = global i32 0
@.str = [33 x i8] c"%s must be an even number long.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [29 x i8] c"%s is a time in the future.\0A\00"
define i64 @parsetimestring(i8* %0) {
%2 = alloca %struct.tm
%3 = alloca [32 x i8]
%4 = alloca [8 x i8]
%5 = bitcast %struct.tm* %2 to i8*
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%7 = tail call i64 @time(i32 0)
%8 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 6
%9 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
%10 = bitcast i64* %8 to i8*
store i32 1, i32* %9
%11 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 2
%12 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 1
%13 = bitcast i64* %12 to i8*
%14 = call i32 @strcpy(i8* %6, i8* %0)
%15 = call i32 @strlen(i8* %6)
%16 = icmp sgt i32 %15, 8
br i1 %16, label %17, label %19
17: ; preds = %1
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 8
store i8 0, i8* %18
br label %19
19: ; preds = %17, %1
%20 = call i32 @strlen(i8* %6)
switch i32 %20, label %42 [
i32 8, label %21
i32 6, label %27
i32 4, label %35
]
21: ; preds = %19
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 6
%24 = call i32 @strncpy(i8* %22, i8* %23, i32 2)
%25 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 2
store i8 0, i8* %25
%26 = call i32 @strtol(i8* nocapture %22, i32* null, i32 10)
store i32 %26, i32* %9
br label %27
27: ; preds = %19, %21
%28 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 4
%30 = call i32 @strncpy(i8* %28, i8* %29, i32 2)
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 2
store i8 0, i8* %31
%32 = call i32 @strtol(i8* nocapture %28, i32* null, i32 10)
%33 = add nsw i32 %32, -1
%34 = sext i32 %33 to i64
store i64 %34, i64* %11
br label %35
35: ; preds = %19, %27
%36 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%37 = call i32 @strncpy(i8* %36, i8* %6, i32 4)
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 4
store i8 0, i8* %38
%39 = call i32 @strtol(i8* nocapture %36, i32* null, i32 10)
%40 = add nsw i32 %39, -1900
%41 = sext i32 %40 to i64
store i64 %41, i64* %12
br label %47
42: ; preds = %19
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %0)
%45 = load i32, i32* @EXIT_FAILURE
%46 = call i32 @dohelp(i32 %45)
br label %47
47: ; preds = %42, %35
%48 = call i64 @mktime(%struct.tm* %2)
%49 = icmp sgt i64 %48, %7
br i1 %49, label %50, label %55
50: ; preds = %47
%51 = load i32, i32* @stderr
%52 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%53 = load i32, i32* @EXIT_FAILURE
%54 = call i32 @dohelp(i32 %53)
br label %55
55: ; preds = %50, %47
%56 = call i64 @mktime(%struct.tm* %2)
ret i64 %56
}