#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 time_t;
struct tm {
  int tm_sec;
  int tm_min;
  int tm_hour;
  int tm_mon;
  scalar_t__ tm_isdst;
  scalar_t__ tm_yday;
  scalar_t__ tm_wday;
  void *tm_year;
  void *tm_mday;
};

/* Variables and functions */
void *atoi(char *);
int mktime(struct tm *);
int montoi(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int, char *, char *);
int /*<<< orphan*/ sscanf(char const *, char *, ...);
int scan_hldate(const char *date, char *sdate) {
  char y[128], m[128], d[128], hms[128];
  int H, M, S;
  struct tm tm;
  time_t udate;
  y[0] = m[0] = d[0] = hms[0] = 0;
  sscanf(date, "%[^/]/%[^/]/%[^:]:%[^ ]]", d, m, y, hms);
  sprintf(sdate, "%s/%02d/%s-%s", y, montoi(m), d, hms);
  H = M = S = 0;
  sscanf(hms, "%d:%d:%d", &H, &M, &S);
  tm.tm_sec = S;
  tm.tm_min = M;
  tm.tm_hour = H;
  tm.tm_mday = atoi(d);
  tm.tm_mon = montoi(m) - 1;
  tm.tm_year = atoi(y) - 1900;
  tm.tm_wday = 0;
  tm.tm_yday = 0;
  tm.tm_isdst = 0;
  udate = mktime(&tm);
  return udate;
}


x86 assembly (clang, -O0):
<scan_hldate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x210(%rbp)
movb   $0x0,-0x190(%rbp)
movb   $0x0,-0x110(%rbp)
movb   $0x0,-0x90(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x190(%rbp),%rdx
lea    -0x110(%rbp),%rcx
lea    -0x90(%rbp),%r8
lea    -0x210(%rbp),%r9
lea    0xe5a(%rip),%rsi
mov    $0x0,%al
call   1030 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x270(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0x268(%rbp)
lea    -0x110(%rbp),%rdi
call   1060 <montoi@plt>
mov    -0x270(%rbp),%rdi
mov    -0x268(%rbp),%rdx
mov    %eax,%ecx
lea    -0x190(%rbp),%r8
lea    -0x210(%rbp),%r9
lea    0xe22(%rip),%rsi
call   1070 <sprintf@plt>
movl   $0x0,-0x21c(%rbp)
movl   $0x0,-0x218(%rbp)
movl   $0x0,-0x214(%rbp)
lea    -0x210(%rbp),%rdi
lea    0xdff(%rip),%rsi
lea    -0x214(%rbp),%rdx
lea    -0x218(%rbp),%rcx
lea    -0x21c(%rbp),%r8
mov    $0x0,%al
call   1030 <sscanf@plt>
mov    -0x21c(%rbp),%eax
mov    %eax,-0x258(%rbp)
mov    -0x218(%rbp),%eax
mov    %eax,-0x254(%rbp)
mov    -0x214(%rbp),%eax
mov    %eax,-0x250(%rbp)
lea    -0x190(%rbp),%rdi
call   1050 <atoi@plt>
mov    %rax,-0x228(%rbp)
lea    -0x110(%rbp),%rdi
call   1060 <montoi@plt>
sub    $0x1,%eax
mov    %eax,-0x24c(%rbp)
lea    -0x90(%rbp),%rdi
call   1050 <atoi@plt>
add    $0xfffffffffffff894,%rax
mov    %rax,-0x230(%rbp)
movq   $0x0,-0x238(%rbp)
movq   $0x0,-0x240(%rbp)
movq   $0x0,-0x248(%rbp)
lea    -0x258(%rbp),%rdi
call   1040 <mktime@plt>
mov    %eax,-0x25c(%rbp)
mov    -0x25c(%rbp),%eax
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan_hldate>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x250,%rsp
mov    %rsi,%rbx
movb   $0x0,0x50(%rsp)
movb   $0x0,0xd0(%rsp)
movb   $0x0,0x150(%rsp)
movb   $0x0,0x1d0(%rsp)
lea    0xe79(%rip),%rsi
lea    0xd0(%rsp),%r12
lea    0x150(%rsp),%r15
lea    0x1d0(%rsp),%r14
lea    0x50(%rsp),%r13
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
mov    %r13,%r9
xor    %eax,%eax
call   1030 <sscanf@plt>
mov    %r15,%rdi
call   1060 <montoi@plt>
lea    0xe53(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %eax,%ecx
mov    %r12,%r8
mov    %r13,%r9
call   1070 <sprintf@plt>
movl   $0x0,0xc(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x14(%rsp)
lea    0xe2f(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <sscanf@plt>
mov    0xc(%rsp),%eax
mov    %eax,0x18(%rsp)
mov    0x10(%rsp),%eax
mov    %eax,0x1c(%rsp)
mov    0x14(%rsp),%eax
mov    %eax,0x20(%rsp)
mov    %r12,%rdi
call   1050 <atoi@plt>
mov    %rax,0x48(%rsp)
mov    %r15,%rdi
call   1060 <montoi@plt>
add    $0xffffffff,%eax
mov    %eax,0x24(%rsp)
mov    %r14,%rdi
call   1050 <atoi@plt>
add    $0xfffffffffffff894,%rax
mov    %rax,0x40(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x28(%rsp)
movq   $0x0,0x38(%rsp)
lea    0x18(%rsp),%rdi
call   1040 <mktime@plt>
add    $0x250,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i64, i64, i64, i8*, i8* }
@.str = [25 x i8] c"%[^/]/%[^/]/%[^:]:%[^ ]]\00"
@.str.1 = [14 x i8] c"%s/%02d/%s-%s\00"
@.str.2 = [9 x i8] c"%d:%d:%d\00"
define i32 @scan_hldate(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [128 x i8]
%6 = alloca [128 x i8]
%7 = alloca [128 x i8]
%8 = alloca [128 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.tm
%13 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
store i8 0, i8* %14
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
store i8 0, i8* %15
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
store i8 0, i8* %16
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
store i8 0, i8* %17
%18 = load i8*, i8** %3
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%23 = call i32 (i8*, i8*, ...) @sscanf(i8* %18, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20, i8* %21, i8* %22)
%24 = load i8*, i8** %4
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%27 = call i32 @montoi(i8* %26)
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%30 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %25, i32 %27, i8* %28, i8* %29)
store i32 0, i32* %11
store i32 0, i32* %10
store i32 0, i32* %9
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%32 = call i32 (i8*, i8*, ...) @sscanf(i8* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %9, i32* %10, i32* %11)
%33 = load i32, i32* %11
%34 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 0
store i32 %33, i32* %34
%35 = load i32, i32* %10
%36 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 1
store i32 %35, i32* %36
%37 = load i32, i32* %9
%38 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 2
store i32 %37, i32* %38
%39 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%40 = call i8* @atoi(i8* %39)
%41 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 8
store i8* %40, i8** %41
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%43 = call i32 @montoi(i8* %42)
%44 = sub nsw i32 %43, 1
%45 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 3
store i32 %44, i32* %45
%46 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%47 = call i8* @atoi(i8* %46)
%48 = getelementptr i8, i8* %47, i64 -1900
%49 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 7
store i8* %48, i8** %49
%50 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 6
store i64 0, i64* %50
%51 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 5
store i64 0, i64* %51
%52 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 4
store i64 0, i64* %52
%53 = call i32 @mktime(%struct.tm* %12)
store i32 %53, i32* %13
%54 = load i32, i32* %13
ret i32 %54
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i64, i64, i64, i8*, i8* }
@.str = [25 x i8] c"%[^/]/%[^/]/%[^:]:%[^ ]]\00"
@.str.1 = [14 x i8] c"%s/%02d/%s-%s\00"
@.str.2 = [9 x i8] c"%d:%d:%d\00"
define i32 @scan_hldate(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = alloca [128 x i8]
%6 = alloca [128 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.tm
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%15 = bitcast i32* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = bitcast i32* %9 to i8*
%18 = bitcast %struct.tm* %10 to i8*
store i8 0, i8* %14
store i8 0, i8* %13
store i8 0, i8* %12
store i8 0, i8* %11
%19 = call i32 (i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %12, i8* %11, i8* %14)
%20 = call i32 @montoi(i8* %12)
%21 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %20, i8* %13, i8* %14)
store i32 0, i32* %9
store i32 0, i32* %8
store i32 0, i32* %7
%22 = call i32 (i8*, i8*, ...) @sscanf(i8* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %7, i32* %8, i32* %9)
%23 = load i32, i32* %9
%24 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 0
store i32 %23, i32* %24
%25 = load i32, i32* %8
%26 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 1
store i32 %25, i32* %26
%27 = load i32, i32* %7
%28 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 2
store i32 %27, i32* %28
%29 = call i8* @atoi(i8* %13)
%30 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 8
store i8* %29, i8** %30
%31 = call i32 @montoi(i8* %12)
%32 = add nsw i32 %31, -1
%33 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 3
store i32 %32, i32* %33
%34 = call i8* @atoi(i8* %11)
%35 = getelementptr i8, i8* %34, i64 -1900
%36 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 7
store i8* %35, i8** %36
%37 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 4
%38 = bitcast i64* %37 to i8*
%39 = call i32 @mktime(%struct.tm* %10)
ret i32 %39
}