#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 scalar_t__ time_t;
struct stat {
  scalar_t__ st_mtime;
};

/* Variables and functions */
int stat(char const *, struct stat *);
int compareTime(const char *file1, const char *file2) {
  struct stat s1, s2;
  time_t t1, t2;
  int res1, res2;
  res1 = stat(file1, &s1);
  t1 = res1 ? 0 : s1.st_mtime;
  res2 = stat(file2, &s2);
  t2 = res2 ? 0 : s2.st_mtime;
  if (t1 == t2) {
    return 0;
  }
  return t1 - t2;
}


x86 assembly (clang, -O0):
<compareTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <stat@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     1145 <compareTime+0x35>
xor    %eax,%eax
mov    %rax,-0x48(%rbp)
jmp    114d <compareTime+0x3d>
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <stat@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
je     117a <compareTime+0x6a>
xor    %eax,%eax
mov    %rax,-0x50(%rbp)
jmp    1182 <compareTime+0x72>
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x38(%rbp),%rax
jne    11a4 <compareTime+0x94>
movl   $0x0,-0x4(%rbp)
jmp    11af <compareTime+0x9f>
mov    -0x30(%rbp),%rax
sub    -0x38(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compareTime>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
lea    0x10(%rsp),%rsi
call   1030 <stat@plt>
xor    %r14d,%r14d
mov    $0x0,%ebp
mov    $0x0,%ebx
test   %eax,%eax
jne    113d <compareTime+0x2d>
mov    0x10(%rsp),%rbx
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
call   1030 <stat@plt>
test   %eax,%eax
jne    1153 <compareTime+0x43>
mov    0x8(%rsp),%rbp
mov    %ebx,%eax
sub    %ebp,%eax
cmp    %rbp,%rbx
cmove  %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
define i32 @compareTime(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.stat
%7 = alloca %struct.stat
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%12 = load i8*, i8** %4
%13 = call i32 @stat(i8* %12, %struct.stat* %6)
store i32 %13, i32* %10
%14 = load i32, i32* %10
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %2
br label %20
17: ; preds = %2
%18 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%19 = load i64, i64* %18
br label %20
20: ; preds = %17, %16
%21 = phi i64 [ 0, %16 ], [ %19, %17 ]
store i64 %21, i64* %8
%22 = load i8*, i8** %5
%23 = call i32 @stat(i8* %22, %struct.stat* %7)
store i32 %23, i32* %11
%24 = load i32, i32* %11
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
br label %30
27: ; preds = %20
%28 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%29 = load i64, i64* %28
br label %30
30: ; preds = %27, %26
%31 = phi i64 [ 0, %26 ], [ %29, %27 ]
store i64 %31, i64* %9
%32 = load i64, i64* %8
%33 = load i64, i64* %9
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 0, i32* %3
br label %41
36: ; preds = %30
%37 = load i64, i64* %8
%38 = load i64, i64* %9
%39 = sub nsw i64 %37, %38
%40 = trunc i64 %39 to i32
store i32 %40, i32* %3
br label %41
41: ; preds = %36, %35
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
%struct.stat = type { i64 }
define i32 @compareTime(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = bitcast %struct.stat* %3 to i8*
%6 = bitcast %struct.stat* %4 to i8*
%7 = call i32 @stat(i8* %0, %struct.stat* %3)
%8 = icmp eq i32 %7, 0
%9 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%10 = load i64, i64* %9
%11 = select i1 %8, i64 %10, i64 0
%12 = call i32 @stat(i8* %1, %struct.stat* %4)
%13 = icmp eq i32 %12, 0
%14 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%15 = load i64, i64* %14
%16 = select i1 %13, i64 %15, i64 0
%17 = icmp eq i64 %11, %16
%18 = sub nsw i64 %11, %16
%19 = trunc i64 %18 to i32
%20 = select i1 %17, i32 0, i32 %19
ret i32 %20
}