#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 {
  void *tm_sec;
  void *tm_min;
  void *tm_hour;
  void *tm_mday;
  void *tm_mon;
  void *tm_year;
};

/* Variables and functions */
void *atoi(char *);
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mktime(struct tm *);
int strlen(char *);
time_t date_to_epoch(char *txtdate) {
  struct tm date;
  if (strlen(txtdate) < 19)
    return 0;
  memset(&date, 0, sizeof(struct tm));
  date.tm_year = atoi(&txtdate[0]) - 1900;
  date.tm_mon = atoi(&txtdate[5]) - 1;
  date.tm_mday = atoi(&txtdate[8]);
  date.tm_hour = atoi(&txtdate[11]);
  date.tm_min = atoi(&txtdate[14]);
  date.tm_sec = atoi(&txtdate[17]);
  time_t rawtime;
  rawtime = mktime(&date);
  return (rawtime);
}


x86 assembly (clang, -O0):
<date_to_epoch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x13,%eax
jge    116a <date_to_epoch+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11f8 <date_to_epoch+0xb8>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
call   1060 <atoi@plt>
add    $0xfffffffffffff894,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x5,%rdi
call   1060 <atoi@plt>
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
call   1060 <atoi@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
add    $0xb,%rdi
call   1060 <atoi@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
add    $0xe,%rdi
call   1060 <atoi@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x11,%rdi
call   1060 <atoi@plt>
mov    %rax,-0x40(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <mktime@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<date_to_epoch>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x13,%ecx
jl     11d4 <date_to_epoch+0x94>
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
call   1060 <atoi@plt>
add    $0xfffffffffffff894,%rax
mov    %rax,0x30(%rsp)
lea    0x5(%rbx),%rdi
call   1060 <atoi@plt>
add    $0xffffffffffffffff,%rax
mov    %rax,0x28(%rsp)
lea    0x8(%rbx),%rdi
call   1060 <atoi@plt>
mov    %rax,0x20(%rsp)
lea    0xb(%rbx),%rdi
call   1060 <atoi@plt>
mov    %rax,0x18(%rsp)
lea    0xe(%rbx),%rdi
call   1060 <atoi@plt>
mov    %rax,0x10(%rsp)
add    $0x11,%rbx
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %rax,0x8(%rsp)
mov    %r14,%rdi
call   1050 <mktime@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i8*, i8*, i8*, i8*, i8*, i8* }
define i32 @date_to_epoch(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.tm
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = icmp slt i32 %7, 19
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %40
10: ; preds = %1
%11 = call i32 @memset(%struct.tm* %4, i32 0, i32 48)
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = call i8* @atoi(i8* %13)
%15 = getelementptr i8, i8* %14, i64 -1900
%16 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 5
store i8* %15, i8** %16
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 5
%19 = call i8* @atoi(i8* %18)
%20 = getelementptr i8, i8* %19, i64 -1
%21 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 4
store i8* %20, i8** %21
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 8
%24 = call i8* @atoi(i8* %23)
%25 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 3
store i8* %24, i8** %25
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 11
%28 = call i8* @atoi(i8* %27)
%29 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 2
store i8* %28, i8** %29
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 14
%32 = call i8* @atoi(i8* %31)
%33 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 1
store i8* %32, i8** %33
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i64 17
%36 = call i8* @atoi(i8* %35)
%37 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
store i8* %36, i8** %37
%38 = call i32 @mktime(%struct.tm* %4)
store i32 %38, i32* %5
%39 = load i32, i32* %5
store i32 %39, i32* %2
br label %40
40: ; preds = %10, %9
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
%struct.tm = type { i8*, i8*, i8*, i8*, i8*, i8* }
define i32 @date_to_epoch(i8* %0) {
%2 = alloca %struct.tm
%3 = bitcast %struct.tm* %2 to i8*
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp slt i32 %4, 19
br i1 %5, label %28, label %6
6: ; preds = %1
%7 = call i32 @memset(%struct.tm* %2, i32 0, i32 48)
%8 = call i8* @atoi(i8* %0)
%9 = getelementptr i8, i8* %8, i64 -1900
%10 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 5
store i8* %9, i8** %10
%11 = getelementptr inbounds i8, i8* %0, i64 5
%12 = call i8* @atoi(i8* %11)
%13 = getelementptr i8, i8* %12, i64 -1
%14 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 4
store i8* %13, i8** %14
%15 = getelementptr inbounds i8, i8* %0, i64 8
%16 = call i8* @atoi(i8* %15)
%17 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 3
store i8* %16, i8** %17
%18 = getelementptr inbounds i8, i8* %0, i64 11
%19 = call i8* @atoi(i8* %18)
%20 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 2
store i8* %19, i8** %20
%21 = getelementptr inbounds i8, i8* %0, i64 14
%22 = call i8* @atoi(i8* %21)
%23 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 1
store i8* %22, i8** %23
%24 = getelementptr inbounds i8, i8* %0, i64 17
%25 = call i8* @atoi(i8* %24)
%26 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
store i8* %25, i8** %26
%27 = call i32 @mktime(%struct.tm* %2)
br label %28
28: ; preds = %1, %6
%29 = phi i32 [ %27, %6 ], [ 0, %1 ]
ret i32 %29
}