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

/* Variables and functions */
double difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mktime(struct tm *);
int /*<<< orphan*/ strptime(char *, char *, struct tm *);
int compareTime(char *date1, char *date2) {
  struct tm datestruct1, datestruct2;
  time_t time1, time2;
  memset(&datestruct1, 0, sizeof(struct tm));
  memset(&datestruct2, 0, sizeof(struct tm));
  strptime(date1, "%d %b %Y %H:%M:%S", &datestruct1);
  strptime(date2, "%d %b %Y %H:%M:%S", &datestruct2);
  time1 = mktime(&datestruct1);
  time2 = mktime(&datestruct2);
  double diff;
  diff = difftime(time1, time2);
  if (diff == 0.0)
    return 0;
  else if (diff > 0)
    return 1;
  else
    return -1;
}


x86 assembly (clang, -O0):
<compareTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1060 <strptime@plt>
mov    -0x18(%rbp),%rdi
lea    0xe71(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1060 <strptime@plt>
lea    -0x20(%rbp),%rdi
call   1050 <mktime@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x28(%rbp),%rdi
call   1050 <mktime@plt>
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1030 <difftime@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11e4 <compareTime+0xa4>
jp     11e4 <compareTime+0xa4>
movl   $0x0,-0x4(%rbp)
jmp    1209 <compareTime+0xc9>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1202 <compareTime+0xc2>
movl   $0x1,-0x4(%rbp)
jmp    1209 <compareTime+0xc9>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compareTime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x10(%rsp),%r12
xor    %ebx,%ebx
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    0x8(%rsp),%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    0xe7b(%rip),%rbp
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
call   1060 <strptime@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
call   1060 <strptime@plt>
mov    %r12,%rdi
call   1050 <mktime@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   1050 <mktime@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1030 <difftime@plt>
xorpd  %xmm1,%xmm1
xor    %eax,%eax
ucomisd %xmm1,%xmm0
seta   %al
lea    -0x1(%rax,%rax,1),%eax
cmovne %eax,%ebx
cmovp  %eax,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%d %b %Y %H:%M:%S\00"
define i32 @compareTime(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.tm
%7 = alloca %struct.tm
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store i8* %0, i8** %4
store i8* %1, i8** %5
%11 = call i32 @memset(%struct.tm* %6, i32 0, i32 4)
%12 = call i32 @memset(%struct.tm* %7, i32 0, i32 4)
%13 = load i8*, i8** %4
%14 = call i32 @strptime(i8* %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %6)
%15 = load i8*, i8** %5
%16 = call i32 @strptime(i8* %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %7)
%17 = call i32 @mktime(%struct.tm* %6)
store i32 %17, i32* %8
%18 = call i32 @mktime(%struct.tm* %7)
store i32 %18, i32* %9
%19 = load i32, i32* %8
%20 = load i32, i32* %9
%21 = call double @difftime(i32 %19, i32 %20)
store double %21, double* %10
%22 = load double, double* %10
%23 = fcmp oeq double %22, 0.000000e+00
br i1 %23, label %24, label %25
24: ; preds = %2
store i32 0, i32* %3
br label %30
25: ; preds = %2
%26 = load double, double* %10
%27 = fcmp ogt double %26, 0.000000e+00
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 1, i32* %3
br label %30
29: ; preds = %25
store i32 -1, i32* %3
br label %30
30: ; preds = %29, %28, %24
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%d %b %Y %H:%M:%S\00"
define i32 @compareTime(i8* %0, i8* %1) {
%3 = alloca %struct.tm
%4 = alloca %struct.tm
%5 = bitcast %struct.tm* %3 to i8*
%6 = bitcast %struct.tm* %4 to i8*
%7 = call i32 @memset(%struct.tm* %3, i32 0, i32 4)
%8 = call i32 @memset(%struct.tm* %4, i32 0, i32 4)
%9 = call i32 @strptime(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %3)
%10 = call i32 @strptime(i8* %1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
%11 = call i32 @mktime(%struct.tm* %3)
%12 = call i32 @mktime(%struct.tm* %4)
%13 = call double @difftime(i32 %11, i32 %12)
%14 = fcmp oeq double %13, 0.000000e+00
%15 = fcmp ogt double %13, 0.000000e+00
%16 = select i1 %15, i32 1, i32 -1
%17 = select i1 %14, i32 0, i32 %16
ret i32 %17
}