#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_mday;
  void *tm_mon;
  void *tm_year;
};

/* Variables and functions */
void *atoi(char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mktime(struct tm *);
time_t string2tm(char *dt, struct tm *tm) {
  char s[20];
  memset((void *)tm, 0, sizeof(struct tm));
  memcpy(s, dt, 4);
  s[4] = '\0';
  tm->tm_year = atoi(s) - 1900;
  s[0] = *(dt + 5);
  s[1] = *(dt + 6);
  s[2] = '\0';
  tm->tm_mon = atoi(s) - 1;
  s[0] = *(dt + 8);
  s[1] = *(dt + 9);
  s[2] = '\0';
  tm->tm_mday = atoi(s);
  return mktime(tm);
}


x86 assembly (clang, -O0):
<string2tm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
movb   $0x0,-0x2c(%rbp)
lea    -0x30(%rbp),%rdi
call   1060 <atoi@plt>
mov    %rax,%rcx
add    $0xfffffffffffff894,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x8(%rbp),%rax
mov    0x5(%rax),%al
mov    %al,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    0x6(%rax),%al
mov    %al,-0x2f(%rbp)
movb   $0x0,-0x2e(%rbp)
lea    -0x30(%rbp),%rdi
call   1060 <atoi@plt>
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%al
mov    %al,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    0x9(%rax),%al
mov    %al,-0x2f(%rbp)
movb   $0x0,-0x2e(%rbp)
lea    -0x30(%rbp),%rdi
call   1060 <atoi@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rdi
call   1050 <mktime@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string2tm>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
movb   $0x0,0x4(%rsp)
mov    %r15,%rdi
call   1060 <atoi@plt>
add    $0xfffffffffffff894,%rax
mov    %rax,0x10(%r14)
mov    0x5(%rbx),%al
mov    %al,(%rsp)
mov    0x6(%rbx),%al
mov    %al,0x1(%rsp)
movb   $0x0,0x2(%rsp)
mov    %r15,%rdi
call   1060 <atoi@plt>
add    $0xffffffffffffffff,%rax
mov    %rax,0x8(%r14)
mov    0x8(%rbx),%al
mov    %al,(%rsp)
mov    0x9(%rbx),%al
mov    %al,0x1(%rsp)
movb   $0x0,0x2(%rsp)
mov    %r15,%rdi
call   1060 <atoi@plt>
mov    %rax,(%r14)
mov    %r14,%rdi
call   1050 <mktime@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i8*, i8*, i8* }
define i32 @string2tm(i8* %0, %struct.tm* %1) {
%3 = alloca i8*
%4 = alloca %struct.tm*
%5 = alloca [20 x i8]
store i8* %0, i8** %3
store %struct.tm* %1, %struct.tm** %4
%6 = load %struct.tm*, %struct.tm** %4
%7 = bitcast %struct.tm* %6 to i8*
%8 = call i32 @memset(i8* %7, i32 0, i32 24)
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%10 = load i8*, i8** %3
%11 = call i32 @memcpy(i8* %9, i8* %10, i32 4)
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 4
store i8 0, i8* %12
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%14 = call i8* @atoi(i8* %13)
%15 = getelementptr i8, i8* %14, i64 -1900
%16 = load %struct.tm*, %struct.tm** %4
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 2
store i8* %15, i8** %17
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 5
%20 = load i8, i8* %19
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
store i8 %20, i8* %21
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 6
%24 = load i8, i8* %23
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 1
store i8 %24, i8* %25
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 2
store i8 0, i8* %26
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%28 = call i8* @atoi(i8* %27)
%29 = getelementptr i8, i8* %28, i64 -1
%30 = load %struct.tm*, %struct.tm** %4
%31 = getelementptr inbounds %struct.tm, %struct.tm* %30, i32 0, i32 1
store i8* %29, i8** %31
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 8
%34 = load i8, i8* %33
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
store i8 %34, i8* %35
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i64 9
%38 = load i8, i8* %37
%39 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 1
store i8 %38, i8* %39
%40 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 2
store i8 0, i8* %40
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%42 = call i8* @atoi(i8* %41)
%43 = load %struct.tm*, %struct.tm** %4
%44 = getelementptr inbounds %struct.tm, %struct.tm* %43, i32 0, i32 0
store i8* %42, i8** %44
%45 = load %struct.tm*, %struct.tm** %4
%46 = call i32 @mktime(%struct.tm* %45)
ret i32 %46
}

LLVM IR (-O2):
%struct.tm = type { i8*, i8*, i8* }
define i32 @string2tm(i8* %0, %struct.tm* %1) {
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%5 = bitcast %struct.tm* %1 to i8*
%6 = tail call i32 @memset(i8* %5, i32 0, i32 24)
%7 = call i32 @memcpy(i8* %4, i8* %0, i32 4)
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 4
store i8 0, i8* %8
%9 = call i8* @atoi(i8* %4)
%10 = getelementptr i8, i8* %9, i64 -1900
%11 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 2
store i8* %10, i8** %11
%12 = getelementptr inbounds i8, i8* %0, i64 5
%13 = load i8, i8* %12
store i8 %13, i8* %4
%14 = getelementptr inbounds i8, i8* %0, i64 6
%15 = load i8, i8* %14
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 1
store i8 %15, i8* %16
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 2
store i8 0, i8* %17
%18 = call i8* @atoi(i8* %4)
%19 = getelementptr i8, i8* %18, i64 -1
%20 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 1
store i8* %19, i8** %20
%21 = getelementptr inbounds i8, i8* %0, i64 8
%22 = load i8, i8* %21
store i8 %22, i8* %4
%23 = getelementptr inbounds i8, i8* %0, i64 9
%24 = load i8, i8* %23
store i8 %24, i8* %16
store i8 0, i8* %17
%25 = call i8* @atoi(i8* %4)
%26 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 0
store i8* %25, i8** %26
%27 = call i32 @mktime(%struct.tm* %1)
ret i32 %27
}