#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_mday;
  int tm_mon;
  int tm_year;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
struct tm *calloc(int, int);
int /*<<< orphan*/ free(struct tm *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, int *, int *);
int /*<<< orphan*/ mktime(struct tm *);
time_t load_date(FILE *in) {
  int D, M, Y;
  fscanf(in, "%d %d %d\n", &D, &M, &Y);
  assert(1 <= D && D <= 31);
  assert(1 <= M && M <= 12);
  assert(1 <= Y && Y <= 3000);
  struct tm *temp = calloc(1, sizeof(*temp));
  temp->tm_mday = D;
  temp->tm_mon = M - 1;
  temp->tm_year = Y - 1900;
  time_t ret = mktime(temp);
  free(temp);
  return ret;
}


x86 assembly (clang, -O0):
<load_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1040 <fscanf@plt>
xor    %eax,%eax
mov    $0x1,%ecx
cmp    -0xc(%rbp),%ecx
mov    %al,-0x25(%rbp)
jg     1195 <load_date+0x45>
cmpl   $0x1f,-0xc(%rbp)
setle  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    $0x1,%ecx
cmp    -0x10(%rbp),%ecx
mov    %al,-0x26(%rbp)
jg     11bf <load_date+0x6f>
cmpl   $0xc,-0x10(%rbp)
setle  %al
mov    %al,-0x26(%rbp)
mov    -0x26(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    $0x1,%ecx
cmp    -0x14(%rbp),%ecx
mov    %al,-0x27(%rbp)
jg     11ec <load_date+0x9c>
cmpl   $0xbb8,-0x14(%rbp)
setle  %al
mov    %al,-0x27(%rbp)
mov    -0x27(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x1,%edi
mov    $0xc,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x14(%rbp),%ecx
sub    $0x76c,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x20(%rbp),%rdi
call   1070 <mktime@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_date>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xea3(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
call   1040 <fscanf@plt>
mov    0x14(%rsp),%eax
add    $0xffffffff,%eax
xor    %edi,%edi
cmp    $0x1f,%eax
setb   %dil
call   1060 <assert@plt>
mov    0x10(%rsp),%eax
add    $0xffffffff,%eax
xor    %edi,%edi
cmp    $0xc,%eax
setb   %dil
call   1060 <assert@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
xor    %edi,%edi
cmp    $0xbb8,%eax
setb   %dil
call   1060 <assert@plt>
mov    $0x1,%edi
mov    $0xc,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    0x14(%rsp),%eax
mov    %eax,(%rbx)
mov    0x10(%rsp),%eax
add    $0xffffffff,%eax
mov    %eax,0x4(%rbx)
mov    $0xfffff894,%eax
add    0xc(%rsp),%eax
mov    %eax,0x8(%rbx)
mov    %rbx,%rdi
call   1070 <mktime@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@.str = [10 x i8] c"%d %d %d\0A\00"
define i32 @load_date(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.tm*
%7 = alloca i32
store i32* %0, i32** %2
%8 = load i32*, i32** %2
%9 = call i32 @fscanf(i32* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%10 = load i32, i32* %3
%11 = icmp sle i32 1, %10
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i32, i32* %3
%14 = icmp sle i32 %13, 31
br label %15
15: ; preds = %12, %1
%16 = phi i1 [ false, %1 ], [ %14, %12 ]
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32, i32* %4
%20 = icmp sle i32 1, %19
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i32, i32* %4
%23 = icmp sle i32 %22, 12
br label %24
24: ; preds = %21, %15
%25 = phi i1 [ false, %15 ], [ %23, %21 ]
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i32, i32* %5
%29 = icmp sle i32 1, %28
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = load i32, i32* %5
%32 = icmp sle i32 %31, 3000
br label %33
33: ; preds = %30, %24
%34 = phi i1 [ false, %24 ], [ %32, %30 ]
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = call %struct.tm* @calloc(i32 1, i32 12)
store %struct.tm* %37, %struct.tm** %6
%38 = load i32, i32* %3
%39 = load %struct.tm*, %struct.tm** %6
%40 = getelementptr inbounds %struct.tm, %struct.tm* %39, i32 0, i32 0
store i32 %38, i32* %40
%41 = load i32, i32* %4
%42 = sub nsw i32 %41, 1
%43 = load %struct.tm*, %struct.tm** %6
%44 = getelementptr inbounds %struct.tm, %struct.tm* %43, i32 0, i32 1
store i32 %42, i32* %44
%45 = load i32, i32* %5
%46 = sub nsw i32 %45, 1900
%47 = load %struct.tm*, %struct.tm** %6
%48 = getelementptr inbounds %struct.tm, %struct.tm* %47, i32 0, i32 2
store i32 %46, i32* %48
%49 = load %struct.tm*, %struct.tm** %6
%50 = call i32 @mktime(%struct.tm* %49)
store i32 %50, i32* %7
%51 = load %struct.tm*, %struct.tm** %6
%52 = call i32 @free(%struct.tm* %51)
%53 = load i32, i32* %7
ret i32 %53
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@.str = [10 x i8] c"%d %d %d\0A\00"
define i32 @load_date(i32* nocapture %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%9 = load i32, i32* %2
%10 = add i32 %9, -1
%11 = icmp ult i32 %10, 31
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i32, i32* %3
%15 = add i32 %14, -1
%16 = icmp ult i32 %15, 12
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32, i32* %4
%20 = add i32 %19, -1
%21 = icmp ult i32 %20, 3000
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = call %struct.tm* @calloc(i32 1, i32 12)
%25 = load i32, i32* %2
%26 = getelementptr inbounds %struct.tm, %struct.tm* %24, i64 0, i32 0
store i32 %25, i32* %26
%27 = load i32, i32* %3
%28 = add nsw i32 %27, -1
%29 = getelementptr inbounds %struct.tm, %struct.tm* %24, i64 0, i32 1
store i32 %28, i32* %29
%30 = load i32, i32* %4
%31 = add nsw i32 %30, -1900
%32 = getelementptr inbounds %struct.tm, %struct.tm* %24, i64 0, i32 2
store i32 %31, i32* %32
%33 = call i32 @mktime(%struct.tm* %24)
%34 = call i32 @free(%struct.tm* %24)
ret i32 %33
}