#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 {
  unsigned int tm_year;
  unsigned int tm_mon;
  unsigned int tm_mday;
  unsigned int tm_hour;
  unsigned int tm_min;
  unsigned int tm_sec;
  int tm_isdst;
};

/* Variables and functions */
int mktime(struct tm *);
int /*<<< orphan*/ time(int *);
short GetStateOfTime(unsigned Hr, unsigned Min, unsigned Sec, unsigned Month,
                     unsigned Day, unsigned Year) {
  time_t CurrentTime, PassedTime;
  struct tm PassedTimeS;
  time(&CurrentTime);
  PassedTimeS.tm_year = Year - 1900;
  PassedTimeS.tm_mon = Month - 1;
  PassedTimeS.tm_mday = Day;
  PassedTimeS.tm_hour = Hr;
  PassedTimeS.tm_min = Min;
  PassedTimeS.tm_sec = Sec;
  PassedTimeS.tm_isdst = -1;
  if ((PassedTime = mktime(&PassedTimeS)) == -1) {
    return -1;
  }
  if (PassedTime < CurrentTime) {
    return 2;
  } else if (PassedTime == CurrentTime) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<GetStateOfTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <time@plt>
mov    -0x1c(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movl   $0xffffffff,-0x28(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <mktime@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    1198 <GetStateOfTime+0x78>
movw   $0xffff,-0x2(%rbp)
jmp    11cc <GetStateOfTime+0xac>
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11af <GetStateOfTime+0x8f>
movw   $0x2,-0x2(%rbp)
jmp    11cc <GetStateOfTime+0xac>
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    11c6 <GetStateOfTime+0xa6>
movw   $0x1,-0x2(%rbp)
jmp    11cc <GetStateOfTime+0xac>
movw   $0x0,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetStateOfTime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%ebx
mov    %r8d,%r14d
mov    %ecx,%ebp
mov    %edx,%r15d
mov    %esi,%r12d
mov    %edi,%r13d
lea    0x4(%rsp),%rdi
call   1030 <time@plt>
add    $0xfffff894,%ebx
mov    %ebx,0x8(%rsp)
add    $0xffffffff,%ebp
mov    %ebp,0xc(%rsp)
mov    %r14d,0x10(%rsp)
mov    %r13d,0x14(%rsp)
mov    %r12d,0x18(%rsp)
mov    %r15d,0x1c(%rsp)
movl   $0xffffffff,0x20(%rsp)
ff
lea    0x8(%rsp),%rdi
call   1040 <mktime@plt>
cmp    $0xffffffff,%eax
je     1199 <GetStateOfTime+0x79>
mov    %eax,%ecx
mov    $0x2,%ax
cmp    0x4(%rsp),%ecx
jl     119d <GetStateOfTime+0x7d>
sete   %al
movzbl %al,%eax
jmp    119d <GetStateOfTime+0x7d>
mov    $0xffff,%ax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
define signext i16 @GetStateOfTime(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i16
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca %struct.tm
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
%17 = call i32 @time(i32* %14)
%18 = load i32, i32* %13
%19 = sub i32 %18, 1900
%20 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 0
store i32 %19, i32* %20
%21 = load i32, i32* %11
%22 = sub i32 %21, 1
%23 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 1
store i32 %22, i32* %23
%24 = load i32, i32* %12
%25 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 2
store i32 %24, i32* %25
%26 = load i32, i32* %8
%27 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 3
store i32 %26, i32* %27
%28 = load i32, i32* %9
%29 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 4
store i32 %28, i32* %29
%30 = load i32, i32* %10
%31 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 5
store i32 %30, i32* %31
%32 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 6
store i32 -1, i32* %32
%33 = call i32 @mktime(%struct.tm* %16)
store i32 %33, i32* %15
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %36
35: ; preds = %6
store i16 -1, i16* %7
br label %47
36: ; preds = %6
%37 = load i32, i32* %15
%38 = load i32, i32* %14
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %41
40: ; preds = %36
store i16 2, i16* %7
br label %47
41: ; preds = %36
%42 = load i32, i32* %15
%43 = load i32, i32* %14
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %46
45: ; preds = %41
store i16 1, i16* %7
br label %47
46: ; preds = %41
store i16 0, i16* %7
br label %47
47: ; preds = %46, %45, %40, %35
%48 = load i16, i16* %7
ret i16 %48
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
define signext i16 @GetStateOfTime(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca %struct.tm
%9 = bitcast i32* %7 to i8*
%10 = bitcast %struct.tm* %8 to i8*
%11 = call i32 @time(i32* %7)
%12 = add i32 %5, -1900
%13 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 0
store i32 %12, i32* %13
%14 = add i32 %3, -1
%15 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 1
store i32 %14, i32* %15
%16 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 2
store i32 %4, i32* %16
%17 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 3
store i32 %0, i32* %17
%18 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 4
store i32 %1, i32* %18
%19 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 5
store i32 %2, i32* %19
%20 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 6
store i32 -1, i32* %20
%21 = call i32 @mktime(%struct.tm* %8)
%22 = icmp eq i32 %21, -1
br i1 %22, label %29, label %23
23: ; preds = %6
%24 = load i32, i32* %7
%25 = icmp slt i32 %21, %24
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = icmp eq i32 %21, %24
%28 = zext i1 %27 to i16
br label %29
29: ; preds = %26, %23, %6
%30 = phi i16 [ -1, %6 ], [ 2, %23 ], [ %28, %26 ]
ret i16 %30
}