#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  scalar_t__ tv_sec;
  scalar_t__ tv_nsec;
};
struct stat {
  TYPE_1__ st_mtim;
};

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *, char const *const);
int stat(char const *const, struct stat *);
int timestamp_cmp(char const *const s, char const *const d) {
  struct stat ss, ds;
  if (stat(s, &ss) == -1) {
    error(2, errno, "stat(\"%s\")", s);
  }
  if (stat(d, &ds) == -1) {
    error(2, errno, "stat(\"%s\")", d);
  }
  return ss.st_mtim.tv_sec < ds.st_mtim.tv_sec     ? -1
         : ss.st_mtim.tv_sec > ds.st_mtim.tv_sec   ? 1
         : ss.st_mtim.tv_nsec < ds.st_mtim.tv_nsec ? -1
         : ss.st_mtim.tv_nsec > ds.st_mtim.tv_nsec ? 1
                                                   : 0;
}


x86 assembly (clang, -O0):
<timestamp_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <stat@plt>
cmp    $0xffffffff,%eax
jne    1164 <timestamp_cmp+0x44>
mov    0x2e93(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rcx
mov    $0x2,%edi
lea    0xea1(%rip),%rdx
call   1040 <error@plt>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <stat@plt>
cmp    $0xffffffff,%eax
jne    1198 <timestamp_cmp+0x78>
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rcx
mov    $0x2,%edi
lea    0xe6d(%rip),%rdx
call   1040 <error@plt>
mov    -0x20(%rbp),%rax
cmp    -0x30(%rbp),%rax
jge    11b3 <timestamp_cmp+0x93>
mov    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    120d <timestamp_cmp+0xed>
mov    -0x20(%rbp),%rax
cmp    -0x30(%rbp),%rax
jle    11ce <timestamp_cmp+0xae>
mov    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1207 <timestamp_cmp+0xe7>
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    11e9 <timestamp_cmp+0xc9>
mov    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    1201 <timestamp_cmp+0xe1>
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %rsi,%rdx
cmovg  %ecx,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timestamp_cmp>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x18(%rsp),%rsi
call   1030 <stat@plt>
cmp    $0xffffffff,%eax
jne    1159 <timestamp_cmp+0x39>
mov    0x2e9d(%rip),%rax
mov    (%rax),%esi
lea    0xeb4(%rip),%rdx
mov    $0x2,%edi
mov    %rbx,%rcx
call   1040 <error@plt>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1030 <stat@plt>
cmp    $0xffffffff,%eax
jne    1188 <timestamp_cmp+0x68>
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
lea    0xe85(%rip),%rdx
mov    $0x2,%edi
mov    %r14,%rcx
call   1040 <error@plt>
mov    0x8(%rsp),%rcx
mov    $0xffffffff,%eax
cmp    %rcx,0x18(%rsp)
jl     11b7 <timestamp_cmp+0x97>
mov    $0x1,%eax
jg     11b7 <timestamp_cmp+0x97>
mov    0x10(%rsp),%rcx
mov    $0xffffffff,%eax
cmp    %rcx,0x20(%rsp)
jl     11b7 <timestamp_cmp+0x97>
setg   %al
movzbl %al,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stat = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64, i64 }
@errno = global i32 0
@.str = [11 x i8] c"stat(\22%s\22)\00"
define i32 @timestamp_cmp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.stat
%6 = alloca %struct.stat
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @stat(i8* %7, %struct.stat* %5)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @errno
%12 = load i8*, i8** %3
%13 = call i32 @error(i32 2, i32 %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %10, %2
%15 = load i8*, i8** %4
%16 = call i32 @stat(i8* %15, %struct.stat* %6)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i32, i32* @errno
%20 = load i8*, i8** %4
%21 = call i32 @error(i32 2, i32 %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %18, %14
%23 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%24 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %23, i32 0, i32 0
%25 = load i64, i64* %24
%26 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%27 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %26, i32 0, i32 0
%28 = load i64, i64* %27
%29 = icmp slt i64 %25, %28
br i1 %29, label %30, label %31
30: ; preds = %22
br label %63
31: ; preds = %22
%32 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%33 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %32, i32 0, i32 0
%34 = load i64, i64* %33
%35 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%36 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %35, i32 0, i32 0
%37 = load i64, i64* %36
%38 = icmp sgt i64 %34, %37
br i1 %38, label %39, label %40
39: ; preds = %31
br label %61
40: ; preds = %31
%41 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%42 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %41, i32 0, i32 1
%43 = load i64, i64* %42
%44 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%45 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %44, i32 0, i32 1
%46 = load i64, i64* %45
%47 = icmp slt i64 %43, %46
br i1 %47, label %48, label %49
48: ; preds = %40
br label %59
49: ; preds = %40
%50 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%51 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %50, i32 0, i32 1
%52 = load i64, i64* %51
%53 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%54 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %53, i32 0, i32 1
%55 = load i64, i64* %54
%56 = icmp sgt i64 %52, %55
%57 = zext i1 %56 to i64
%58 = select i1 %56, i32 1, i32 0
br label %59
59: ; preds = %49, %48
%60 = phi i32 [ -1, %48 ], [ %58, %49 ]
br label %61
61: ; preds = %59, %39
%62 = phi i32 [ 1, %39 ], [ %60, %59 ]
br label %63
63: ; preds = %61, %30
%64 = phi i32 [ -1, %30 ], [ %62, %61 ]
ret i32 %64
}

LLVM IR (-O2):
%struct.stat = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64, i64 }
@errno = global i32 0
@.str = [11 x i8] c"stat(\22%s\22)\00"
define i32 @timestamp_cmp(i8* %0, i8* %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, -1
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @errno
%11 = tail call i32 @error(i32 2, i32 %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %12
12: ; preds = %9, %2
%13 = call i32 @stat(i8* %1, %struct.stat* %4)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* @errno
%17 = tail call i32 @error(i32 2, i32 %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %18
18: ; preds = %15, %12
%19 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0, i32 0
%20 = load i64, i64* %19
%21 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0, i32 0
%22 = load i64, i64* %21
%23 = icmp slt i64 %20, %22
br i1 %23, label %35, label %24
24: ; preds = %18
%25 = icmp sgt i64 %20, %22
br i1 %25, label %35, label %26
26: ; preds = %24
%27 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0, i32 1
%28 = load i64, i64* %27
%29 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0, i32 1
%30 = load i64, i64* %29
%31 = icmp slt i64 %28, %30
br i1 %31, label %35, label %32
32: ; preds = %26
%33 = icmp sgt i64 %28, %30
%34 = zext i1 %33 to i32
br label %35
35: ; preds = %24, %26, %32, %18
%36 = phi i32 [ -1, %18 ], [ 1, %24 ], [ %34, %32 ], [ -1, %26 ]
ret i32 %36
}