#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_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
  int tm_isdst;
};

/* Variables and functions */
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mktime(struct tm *);
scalar_t__ strtol(char *, char **, int);
time_t strtoepoch(char *time) {
  char *endptr;
  struct tm ltm;
  memset(&ltm, 0, sizeof(struct tm));
  ltm.tm_year = (int)strtol(time, &endptr, 10) - 1900;
  ltm.tm_mon = (int)strtol(&endptr[1], &endptr, 10) - 1;
  ltm.tm_mday = (int)strtol(&endptr[1], &endptr, 10);
  ltm.tm_hour = (int)strtol(&endptr[1], &endptr, 10);
  ltm.tm_min = (int)strtol(&endptr[1], &endptr, 10);
  ltm.tm_sec = (int)strtol(&endptr[1], &endptr, 10);
  ltm.tm_isdst = -1;
  return mktime(&ltm);
}


x86 assembly (clang, -O0):
<strtoepoch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x1c,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
sub    $0x76c,%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
lea    -0x10(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x1c(%rbp)
movl   $0xffffffff,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <mktime@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtoepoch>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1c,%edx
call   1030 <memset@plt>
lea    0x8(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
add    $0xfffff894,%eax
mov    %eax,0x10(%rsp)
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
add    $0xffffffff,%eax
mov    %eax,0x14(%rsp)
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,0x18(%rsp)
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,0x1c(%rsp)
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,0x20(%rsp)
mov    0x8(%rsp),%rdi
add    $0x1,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,0x24(%rsp)
movl   $0xffffffff,0x28(%rsp)
ff
mov    %r14,%rdi
call   1050 <mktime@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
define i32 @strtoepoch(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca %struct.tm
store i8* %0, i8** %2
%5 = call i32 @memset(%struct.tm* %4, i32 0, i32 28)
%6 = load i8*, i8** %2
%7 = call i64 @strtol(i8* %6, i8** %3, i32 10)
%8 = trunc i64 %7 to i32
%9 = sub nsw i32 %8, 1900
%10 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
store i32 %9, i32* %10
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = call i64 @strtol(i8* %12, i8** %3, i32 10)
%14 = trunc i64 %13 to i32
%15 = sub nsw i32 %14, 1
%16 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 1
store i32 %15, i32* %16
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = call i64 @strtol(i8* %18, i8** %3, i32 10)
%20 = trunc i64 %19 to i32
%21 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 2
store i32 %20, i32* %21
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = call i64 @strtol(i8* %23, i8** %3, i32 10)
%25 = trunc i64 %24 to i32
%26 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 3
store i32 %25, i32* %26
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = call i64 @strtol(i8* %28, i8** %3, i32 10)
%30 = trunc i64 %29 to i32
%31 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 4
store i32 %30, i32* %31
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = call i64 @strtol(i8* %33, i8** %3, i32 10)
%35 = trunc i64 %34 to i32
%36 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 5
store i32 %35, i32* %36
%37 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 6
store i32 -1, i32* %37
%38 = call i32 @mktime(%struct.tm* %4)
ret i32 %38
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
define i32 @strtoepoch(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.tm
%4 = bitcast i8** %2 to i8*
%5 = bitcast %struct.tm* %3 to i8*
%6 = call i32 @memset(%struct.tm* %3, i32 0, i32 28)
%7 = call i64 @strtol(i8* %0, i8** %2, i32 10)
%8 = trunc i64 %7 to i32
%9 = add nsw i32 %8, -1900
%10 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
store i32 %9, i32* %10
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = call i64 @strtol(i8* %12, i8** %2, i32 10)
%14 = trunc i64 %13 to i32
%15 = add nsw i32 %14, -1
%16 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 1
store i32 %15, i32* %16
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = call i64 @strtol(i8* %18, i8** %2, i32 10)
%20 = trunc i64 %19 to i32
%21 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 2
store i32 %20, i32* %21
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = call i64 @strtol(i8* %23, i8** %2, i32 10)
%25 = trunc i64 %24 to i32
%26 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 3
store i32 %25, i32* %26
%27 = load i8*, i8** %2
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = call i64 @strtol(i8* %28, i8** %2, i32 10)
%30 = trunc i64 %29 to i32
%31 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 4
store i32 %30, i32* %31
%32 = load i8*, i8** %2
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = call i64 @strtol(i8* %33, i8** %2, i32 10)
%35 = trunc i64 %34 to i32
%36 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 5
store i32 %35, i32* %36
%37 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 6
store i32 -1, i32* %37
%38 = call i32 @mktime(%struct.tm* %3)
ret i32 %38
}