#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 */
struct tm {
  int tm_mday;
  int tm_mon;
  int tm_year;
  scalar_t__ tm_hour;
  scalar_t__ tm_min;
  scalar_t__ tm_sec;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int mktime(struct tm *);
int /*<<< orphan*/ printf(char *, char *, char *);
int sscanf(char *, char *, int *, int *, int *);
int str2time(char *s) {
  struct tm tim;
  int d, m, y;
  if (sscanf(s, "%d.%d.%d", &d, &m, &y) != 3) {
    printf("%scant convert %s to date\n", "Content-type: text/html\n\n", s);
    exit(10);
  }
  if (y < 100)
    y = y + 2000;
  tim.tm_sec = tim.tm_min = tim.tm_hour = 0;
  tim.tm_mday = d;
  tim.tm_mon = m - 1;
  tim.tm_year = y - 1900;
  return mktime(&tim);
}


x86 assembly (clang, -O0):
<str2time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea9(%rip),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x3c(%rbp),%r8
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     1192 <str2time+0x52>
mov    -0x8(%rbp),%rdx
lea    0xe8d(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1030 <printf@plt>
mov    $0xa,%edi
call   1060 <exit@plt>
cmpl   $0x64,-0x3c(%rbp)
jge    11a7 <str2time+0x67>
mov    -0x3c(%rbp),%eax
add    $0x7d0,%eax
mov    %eax,-0x3c(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x38(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x3c(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x28(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <mktime@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str2time>:
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
lea    0xeb1(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
call   1040 <sscanf@plt>
cmp    $0x3,%eax
jne    11b7 <str2time+0x77>
mov    0xc(%rsp),%eax
cmp    $0x63,%eax
jg     117a <str2time+0x3a>
add    $0x7d0,%eax
mov    %eax,0xc(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x28(%rsp)
movq   $0x0,0x38(%rsp)
mov    0x14(%rsp),%ecx
mov    %ecx,0x18(%rsp)
mov    0x10(%rsp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,0x1c(%rsp)
add    $0xfffff894,%eax
mov    %eax,0x20(%rsp)
lea    0x18(%rsp),%rdi
call   1050 <mktime@plt>
add    $0x40,%rsp
pop    %rbx
ret
lea    0xe4b(%rip),%rdi
lea    0xe5f(%rip),%rsi
mov    %rbx,%rdx
call   1030 <printf@plt>
mov    $0xa,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i64, i64, i64 }
@.str = [9 x i8] c"%d.%d.%d\00"
@.str.1 = [27 x i8] c"%scant convert %s to date\0A\00"
@.str.2 = [26 x i8] c"Content-type: text/html\0A\0A\00"
define i32 @str2time(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.tm
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = call i32 @exit(i32 10)
unreachable
14: ; preds = %1
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 100
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 2000
store i32 %19, i32* %6
br label %20
20: ; preds = %17, %14
%21 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 3
store i64 0, i64* %21
%22 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 4
store i64 0, i64* %22
%23 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 5
store i64 0, i64* %23
%24 = load i32, i32* %4
%25 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 0
store i32 %24, i32* %25
%26 = load i32, i32* %5
%27 = sub nsw i32 %26, 1
%28 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 1
store i32 %27, i32* %28
%29 = load i32, i32* %6
%30 = sub nsw i32 %29, 1900
%31 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 2
store i32 %30, i32* %31
%32 = call i32 @mktime(%struct.tm* %3)
ret i32 %32
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i64, i64, i64 }
@.str = [9 x i8] c"%d.%d.%d\00"
@.str.1 = [27 x i8] c"%scant convert %s to date\0A\00"
@.str.2 = [26 x i8] c"Content-type: text/html\0A\0A\00"
define i32 @str2time(i8* %0) {
%2 = alloca %struct.tm
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast %struct.tm* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%11 = icmp eq i32 %10, 3
br i1 %11, label %15, label %12
12: ; preds = %1
%13 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%14 = call i32 @exit(i32 10)
unreachable
15: ; preds = %1
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 100
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = add nsw i32 %16, 2000
store i32 %19, i32* %5
br label %20
20: ; preds = %18, %15
%21 = phi i32 [ %19, %18 ], [ %16, %15 ]
%22 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 3
%23 = bitcast i64* %22 to i8*
%24 = load i32, i32* %3
%25 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
store i32 %24, i32* %25
%26 = load i32, i32* %4
%27 = add nsw i32 %26, -1
%28 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 1
store i32 %27, i32* %28
%29 = add nsw i32 %21, -1900
%30 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 2
store i32 %29, i32* %30
%31 = call i32 @mktime(%struct.tm* %2)
ret i32 %31
}