#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 int /*<<< orphan*/ time_t;
struct tm {
  int tm_sec;
  int tm_min;
  int tm_hour;
  int tm_mday;
  int tm_mon;
  int tm_year;
};

/* Variables and functions */
int /*<<< orphan*/ mktime(struct tm *);
int sscanf(char const *, char *, int *, ...);
scalar_t__ strtomonth(int *, char *);
int strtotime(time_t *time, const char *s) {
  struct tm tm;
  int dd, mm, yy;
  int hrs, min, sec;
  char buf[20];
  if (sscanf(s, "%u-%u-%u %u:%u:%u", &yy, &mm, &dd, &hrs, &min, &sec) != 6) {
    if (sscanf(s, "%u/%u/%u %u:%u:%u", &yy, &mm, &dd, &hrs, &min, &sec) != 6) {
      if (sscanf(s, "%u-%19[a-zA-Z]-%u %u:%u:%u", &yy, buf, &dd, &hrs, &min,
                 &sec) != 6 &&
          strtomonth(&mm, buf) == 0) {
        hrs = 0;
        min = 0;
        sec = 0;
        if (sscanf(s, "%u-%u-%u", &yy, &mm, &dd) != 3) {
          if (sscanf(s, "%u/%u/%u", &yy, &mm, &dd) != 3) {
            if (sscanf(s, "%u-%19[a-zA-Z]-%u", &yy, buf, &dd) != 3 &&
                strtomonth(&mm, buf) == 0) {
              return 0;
            }
          }
        }
      }
    }
  }
  tm.tm_sec = sec;
  tm.tm_min = min;
  tm.tm_hour = hrs;
  tm.tm_mday = dd;
  tm.tm_mon = mm - 1;
  tm.tm_year = yy - 1900;
  *time = mktime(&tm);
  return 1;
}


x86 assembly (clang, -O0):
<strtotime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeb5(%rip),%rsi
lea    -0x3c(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x34(%rbp),%r8
lea    -0x40(%rbp),%r9
lea    -0x44(%rbp),%r10
lea    -0x48(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x6,%eax
je     12d1 <strtotime+0x1a1>
mov    -0x18(%rbp),%rdi
lea    0xe8b(%rip),%rsi
lea    -0x3c(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x34(%rbp),%r8
lea    -0x40(%rbp),%r9
lea    -0x44(%rbp),%r10
lea    -0x48(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x6,%eax
je     12cc <strtotime+0x19c>
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rcx
lea    0xe5d(%rip),%rsi
lea    -0x3c(%rbp),%rdx
lea    -0x34(%rbp),%r8
lea    -0x40(%rbp),%r9
lea    -0x44(%rbp),%r10
lea    -0x48(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x6,%eax
je     12c7 <strtotime+0x197>
lea    -0x60(%rbp),%rsi
lea    -0x38(%rbp),%rdi
call   1030 <strtomonth@plt>
cmp    $0x0,%rax
jne    12c7 <strtotime+0x197>
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe14(%rip),%rsi
lea    -0x3c(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x34(%rbp),%r8
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     12c2 <strtotime+0x192>
mov    -0x18(%rbp),%rdi
lea    0xdf6(%rip),%rsi
lea    -0x3c(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x34(%rbp),%r8
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     12bd <strtotime+0x18d>
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rcx
lea    0xdd4(%rip),%rsi
lea    -0x3c(%rbp),%rdx
lea    -0x34(%rbp),%r8
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     12b8 <strtotime+0x188>
lea    -0x60(%rbp),%rsi
lea    -0x38(%rbp),%rdi
call   1030 <strtomonth@plt>
cmp    $0x0,%rax
jne    12b8 <strtotime+0x188>
movl   $0x0,-0x4(%rbp)
jmp    1315 <strtotime+0x1e5>
jmp    12bd <strtotime+0x18d>
jmp    12c2 <strtotime+0x192>
jmp    12c7 <strtotime+0x197>
jmp    12cc <strtotime+0x19c>
jmp    12d1 <strtotime+0x1a1>
mov    -0x48(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x38(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x3c(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x1c(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <mktime@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtotime>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x10(%rsp),%rbp
lea    0x14(%rsp),%r15
lea    0xeaf(%rip),%rsi
mov    %rsp,%rdx
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0xc(%rsp),%r9
mov    %rbx,%rdi
xor    %eax,%eax
push   %rbp
push   %r15
call   1040 <sscanf@plt>
add    $0x10,%rsp
cmp    $0x6,%eax
je     1292 <strtotime+0x162>
lea    0xe8e(%rip),%rsi
mov    %rsp,%rdx
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0xc(%rsp),%r9
mov    %rbx,%rdi
xor    %eax,%eax
push   %rbp
push   %r15
call   1040 <sscanf@plt>
add    $0x10,%rsp
cmp    $0x6,%eax
je     1292 <strtotime+0x162>
lea    0xe6d(%rip),%rsi
mov    %rsp,%rdx
lea    0x30(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0xc(%rsp),%r9
mov    %rbx,%rdi
xor    %eax,%eax
push   %rbp
push   %r15
call   1040 <sscanf@plt>
add    $0x10,%rsp
cmp    $0x6,%eax
je     1292 <strtotime+0x162>
lea    0x4(%rsp),%rdi
lea    0x30(%rsp),%rsi
call   1030 <strtomonth@plt>
test   %rax,%rax
jne    1292 <strtotime+0x162>
movl   $0x0,0xc(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xe25(%rip),%rsi
mov    %rsp,%rdx
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     1292 <strtotime+0x162>
lea    0xe0b(%rip),%rsi
mov    %rsp,%rdx
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     1292 <strtotime+0x162>
lea    0xdf1(%rip),%rsi
xor    %ebp,%ebp
mov    %rsp,%rdx
lea    0x30(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     1292 <strtotime+0x162>
lea    0x4(%rsp),%rdi
lea    0x30(%rsp),%rsi
call   1030 <strtomonth@plt>
test   %rax,%rax
je     12db <strtotime+0x1ab>
mov    0x10(%rsp),%eax
mov    %eax,0x18(%rsp)
mov    0x14(%rsp),%eax
mov    %eax,0x1c(%rsp)
mov    0xc(%rsp),%eax
mov    %eax,0x20(%rsp)
mov    0x8(%rsp),%eax
mov    %eax,0x24(%rsp)
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
mov    %eax,0x28(%rsp)
mov    $0xfffff894,%eax
add    (%rsp),%eax
mov    %eax,0x2c(%rsp)
lea    0x18(%rsp),%rdi
call   1050 <mktime@plt>
mov    %eax,(%r14)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [18 x i8] c"%u-%u-%u %u:%u:%u\00"
@.str.1 = [18 x i8] c"%u/%u/%u %u:%u:%u\00"
@.str.2 = [27 x i8] c"%u-%19[a-zA-Z]-%u %u:%u:%u\00"
@.str.3 = [9 x i8] c"%u-%u-%u\00"
@.str.4 = [9 x i8] c"%u/%u/%u\00"
@.str.5 = [18 x i8] c"%u-%19[a-zA-Z]-%u\00"
define i32 @strtotime(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca %struct.tm
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [20 x i8]
store i32* %0, i32** %4
store i8* %1, i8** %5
%14 = load i8*, i8** %5
%15 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* %9, i32* %8, i32* %7, i32* %10, i32* %11, i32* %12)
%16 = icmp ne i32 %15, 6
br i1 %16, label %17, label %53
17: ; preds = %2
%18 = load i8*, i8** %5
%19 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32* %9, i32* %8, i32* %7, i32* %10, i32* %11, i32* %12)
%20 = icmp ne i32 %19, 6
br i1 %20, label %21, label %52
21: ; preds = %17
%22 = load i8*, i8** %5
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %13, i64 0, i64 0
%24 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %22, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32* %9, i8* %23, i32* %7, i32* %10, i32* %11, i32* %12)
%25 = icmp ne i32 %24, 6
br i1 %25, label %26, label %51
26: ; preds = %21
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %13, i64 0, i64 0
%28 = call i64 @strtomonth(i32* %8, i8* %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %51
30: ; preds = %26
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
%31 = load i8*, i8** %5
%32 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %9, i32* %8, i32* %7)
%33 = icmp ne i32 %32, 3
br i1 %33, label %34, label %50
34: ; preds = %30
%35 = load i8*, i8** %5
%36 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %35, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %9, i32* %8, i32* %7)
%37 = icmp ne i32 %36, 3
br i1 %37, label %38, label %49
38: ; preds = %34
%39 = load i8*, i8** %5
%40 = getelementptr inbounds [20 x i8], [20 x i8]* %13, i64 0, i64 0
%41 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %39, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32* %9, i8* %40, i32* %7)
%42 = icmp ne i32 %41, 3
br i1 %42, label %43, label %48
43: ; preds = %38
%44 = getelementptr inbounds [20 x i8], [20 x i8]* %13, i64 0, i64 0
%45 = call i64 @strtomonth(i32* %8, i8* %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %43
store i32 0, i32* %3
br label %70
48: ; preds = %43, %38
br label %49
49: ; preds = %48, %34
br label %50
50: ; preds = %49, %30
br label %51
51: ; preds = %50, %26, %21
br label %52
52: ; preds = %51, %17
br label %53
53: ; preds = %52, %2
%54 = load i32, i32* %12
%55 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 0
store i32 %54, i32* %55
%56 = load i32, i32* %11
%57 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 1
store i32 %56, i32* %57
%58 = load i32, i32* %10
%59 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 2
store i32 %58, i32* %59
%60 = load i32, i32* %7
%61 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 3
store i32 %60, i32* %61
%62 = load i32, i32* %8
%63 = sub nsw i32 %62, 1
%64 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 4
store i32 %63, i32* %64
%65 = load i32, i32* %9
%66 = sub nsw i32 %65, 1900
%67 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 5
store i32 %66, i32* %67
%68 = call i32 @mktime(%struct.tm* %6)
%69 = load i32*, i32** %4
store i32 %68, i32* %69
store i32 1, i32* %3
br label %70
70: ; preds = %53, %47
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [18 x i8] c"%u-%u-%u %u:%u:%u\00"
@.str.1 = [18 x i8] c"%u/%u/%u %u:%u:%u\00"
@.str.2 = [27 x i8] c"%u-%19[a-zA-Z]-%u %u:%u:%u\00"
@.str.3 = [9 x i8] c"%u-%u-%u\00"
@.str.4 = [9 x i8] c"%u/%u/%u\00"
@.str.5 = [18 x i8] c"%u-%19[a-zA-Z]-%u\00"
define i32 @strtotime(i32* nocapture writeonly %0, i8* nocapture %1) {
%3 = alloca %struct.tm
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [20 x i8]
%11 = bitcast %struct.tm* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = bitcast i32* %5 to i8*
%14 = bitcast i32* %6 to i8*
%15 = bitcast i32* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = bitcast i32* %9 to i8*
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%19 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* %6, i32* %5, i32* %4, i32* %7, i32* %8, i32* %9)
%20 = icmp eq i32 %19, 6
br i1 %20, label %42, label %21
21: ; preds = %2
%22 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %5, i32* %4, i32* %7, i32* %8, i32* %9)
%23 = icmp eq i32 %22, 6
br i1 %23, label %42, label %24
24: ; preds = %21
%25 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %1, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32* %6, i8* %18, i32* %4, i32* %7, i32* %8, i32* %9)
%26 = icmp eq i32 %25, 6
br i1 %26, label %42, label %27
27: ; preds = %24
%28 = call i64 @strtomonth(i32* %5, i8* %18)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %42
30: ; preds = %27
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%31 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %6, i32* %5, i32* %4)
%32 = icmp eq i32 %31, 3
br i1 %32, label %42, label %33
33: ; preds = %30
%34 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %6, i32* %5, i32* %4)
%35 = icmp eq i32 %34, 3
br i1 %35, label %42, label %36
36: ; preds = %33
%37 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32* %6, i8* %18, i32* %4)
%38 = icmp eq i32 %37, 3
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = call i64 @strtomonth(i32* %5, i8* %18)
%41 = icmp eq i64 %40, 0
br i1 %41, label %58, label %42
42: ; preds = %21, %30, %36, %39, %33, %27, %24, %2
%43 = load i32, i32* %9
%44 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
store i32 %43, i32* %44
%45 = load i32, i32* %8
%46 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 1
store i32 %45, i32* %46
%47 = load i32, i32* %7
%48 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 2
store i32 %47, i32* %48
%49 = load i32, i32* %4
%50 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 3
store i32 %49, i32* %50
%51 = load i32, i32* %5
%52 = add nsw i32 %51, -1
%53 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 4
store i32 %52, i32* %53
%54 = load i32, i32* %6
%55 = add nsw i32 %54, -1900
%56 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 5
store i32 %55, i32* %56
%57 = call i32 @mktime(%struct.tm* %3)
store i32 %57, i32* %0
br label %58
58: ; preds = %39, %42
%59 = phi i32 [ 1, %42 ], [ 0, %39 ]
ret i32 %59
}