#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;
};

/* Variables and functions */
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ mktime(struct tm *);
int sscanf(char *, char *, int *, int *, int *, int *, int *, int *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
time_t passed_date(struct tm old, const char *date) {
  char buf[20] = {0};
  int year, month, day;
  int hour, miniture, second;
  strncpy(buf, date, sizeof buf);
  int succ = sscanf(buf, "%4d%*c%2d%*c%2d%*c%2d%*c%2d%*c%2d", &year, &month,
                    &day, &hour, &miniture, &second);
  if (succ != 6)
    error("unreadable field\n");
  old.tm_year = year - 1900;
  old.tm_mon = month - 1;
  old.tm_mday = day;
  old.tm_hour = hour;
  old.tm_min = miniture;
  old.tm_sec = second;
  return mktime(&old);
}


x86 assembly (clang, -O0):
<passed_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    %rdi,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x14,%edx
call   1030 <strncpy@plt>
lea    -0x20(%rbp),%rdi
lea    0xe6f(%rip),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%r8
lea    -0x30(%rbp),%r9
lea    -0x34(%rbp),%r10
lea    -0x38(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <sscanf@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x6,-0x3c(%rbp)
je     11d0 <passed_date+0x80>
lea    0xe57(%rip),%rdi
call   1070 <error@plt>
mov    -0x48(%rbp),%rdi
mov    -0x24(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,(%rdi)
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
mov    %eax,0x4(%rdi)
mov    -0x2c(%rbp),%eax
mov    %eax,0x8(%rdi)
mov    -0x30(%rbp),%eax
mov    %eax,0xc(%rdi)
mov    -0x34(%rbp),%eax
mov    %eax,0x10(%rdi)
mov    -0x38(%rbp),%eax
mov    %eax,0x14(%rdi)
call   1060 <mktime@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<passed_date>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rsi
lea    0x50(%rsp),%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x30(%rsp)
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0x14,%edx
call   1030 <strncpy@plt>
lea    0x8(%rsp),%rax
lea    0xc(%rsp),%r10
lea    0xe7e(%rip),%rsi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x14(%rsp),%r8
lea    0x10(%rsp),%r9
mov    %r14,%rdi
push   %rax
push   %r10
call   1040 <sscanf@plt>
add    $0x10,%rsp
cmp    $0x6,%eax
je     11b6 <passed_date+0x76>
lea    0xe71(%rip),%rdi
call   1060 <error@plt>
mov    $0xfffff894,%eax
add    0x1c(%rsp),%eax
mov    %eax,(%rbx)
mov    0x18(%rsp),%eax
add    $0xffffffff,%eax
mov    %eax,0x4(%rbx)
mov    0x14(%rsp),%eax
mov    %eax,0x8(%rbx)
mov    0x10(%rsp),%eax
mov    %eax,0xc(%rbx)
mov    0xc(%rsp),%eax
mov    %eax,0x10(%rbx)
mov    0x8(%rsp),%eax
mov    %eax,0x14(%rbx)
mov    %rbx,%rdi
call   1050 <mktime@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [34 x i8] c"%4d%*c%2d%*c%2d%*c%2d%*c%2d%*c%2d\00"
@.str.1 = [18 x i8] c"unreadable field\0A\00"
define i32 @passed_date(%struct.tm* byval(%struct.tm) align 8 %0, i8* %1) {
%3 = alloca i8*
%4 = alloca [20 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %1, i8** %3
%12 = bitcast [20 x i8]* %4 to i8*
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%14 = load i8*, i8** %3
%15 = call i32 @strncpy(i8* %13, i8* %14, i32 20)
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10)
store i32 %17, i32* %11
%18 = load i32, i32* %11
%19 = icmp ne i32 %18, 6
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %2
%23 = load i32, i32* %5
%24 = sub nsw i32 %23, 1900
%25 = getelementptr inbounds %struct.tm, %struct.tm* %0, i32 0, i32 0
store i32 %24, i32* %25
%26 = load i32, i32* %6
%27 = sub nsw i32 %26, 1
%28 = getelementptr inbounds %struct.tm, %struct.tm* %0, i32 0, i32 1
store i32 %27, i32* %28
%29 = load i32, i32* %7
%30 = getelementptr inbounds %struct.tm, %struct.tm* %0, i32 0, i32 2
store i32 %29, i32* %30
%31 = load i32, i32* %8
%32 = getelementptr inbounds %struct.tm, %struct.tm* %0, i32 0, i32 3
store i32 %31, i32* %32
%33 = load i32, i32* %9
%34 = getelementptr inbounds %struct.tm, %struct.tm* %0, i32 0, i32 4
store i32 %33, i32* %34
%35 = load i32, i32* %10
%36 = getelementptr inbounds %struct.tm, %struct.tm* %0, i32 0, i32 5
store i32 %35, i32* %36
%37 = call i32 @mktime(%struct.tm* %0)
ret i32 %37
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [34 x i8] c"%4d%*c%2d%*c%2d%*c%2d%*c%2d%*c%2d\00"
@.str.1 = [18 x i8] c"unreadable field\0A\00"
define i32 @passed_date(%struct.tm* nocapture byval(%struct.tm) align 8 %0, i8* %1) {
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%11 = bitcast i32* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = bitcast i32* %8 to i8*
%16 = bitcast i32* %9 to i8*
%17 = call i32 @strncpy(i8* %10, i8* %1, i32 20)
%18 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9)
%19 = icmp eq i32 %18, 6
br i1 %19, label %22, label %20
20: ; preds = %2
%21 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %2
%23 = load i32, i32* %4
%24 = add nsw i32 %23, -1900
%25 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 0
store i32 %24, i32* %25
%26 = load i32, i32* %5
%27 = add nsw i32 %26, -1
%28 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 1
store i32 %27, i32* %28
%29 = load i32, i32* %6
%30 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 2
store i32 %29, i32* %30
%31 = load i32, i32* %7
%32 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 3
store i32 %31, i32* %32
%33 = load i32, i32* %8
%34 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 4
store i32 %33, i32* %34
%35 = load i32, i32* %9
%36 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 5
store i32 %35, i32* %36
%37 = call i32 @mktime(%struct.tm* %0)
ret i32 %37
}