#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 */
struct stat {
  int /*<<< orphan*/ st_mtime;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
double difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
scalar_t__ stat(char const *, struct stat *);
double compare_mtime(const char *path1, const char *path2) {
  struct stat info1;
  struct stat info2;
  double seconds;
  if (stat(path1, &info1) != 0)
    do {
      perror("stat");
      exit(EXIT_FAILURE);
    } while (0);
  ;
  if (stat(path2, &info2) != 0)
    do {
      perror("stat");
      exit(EXIT_FAILURE);
    } while (0);
  ;
  seconds = difftime(info1.st_mtime, info2.st_mtime);
  return seconds;
}


x86 assembly (clang, -O0):
<compare_mtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0x0,%rax
je     1186 <compare_mtime+0x46>
jmp    116c <compare_mtime+0x2c>
lea    0xe8d(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0x0,%rax
je     11bc <compare_mtime+0x7c>
jmp    11a2 <compare_mtime+0x62>
lea    0xe57(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <difftime@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_mtime>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0x8(%rsp),%rsi
call   1040 <stat@plt>
test   %rax,%rax
jne    1179 <compare_mtime+0x39>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <stat@plt>
test   %rax,%rax
jne    1179 <compare_mtime+0x39>
mov    0x8(%rsp),%edi
mov    (%rsp),%esi
call   1030 <difftime@plt>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe80(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [5 x i8] c"stat\00"
@EXIT_FAILURE = global i32 0
define double @compare_mtime(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.stat
%6 = alloca %struct.stat
%7 = alloca double
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i64 @stat(i8* %8, %struct.stat* %5)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %2
br label %12
12: ; preds = %11
%13 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; No predecessors!
br label %17
17: ; preds = %16, %2
%18 = load i8*, i8** %4
%19 = call i64 @stat(i8* %18, %struct.stat* %6)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %17
br label %22
22: ; preds = %21
%23 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; No predecessors!
br label %27
27: ; preds = %26, %17
%28 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%31 = load i32, i32* %30
%32 = call double @difftime(i32 %29, i32 %31)
store double %32, double* %7
%33 = load double, double* %7
ret double %33
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [5 x i8] c"stat\00"
@EXIT_FAILURE = global i32 0
define double @compare_mtime(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 i64 @stat(i8* %0, %struct.stat* %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
%14 = call i64 @stat(i8* %1, %struct.stat* %4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %13
%21 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%24 = load i32, i32* %23
%25 = call double @difftime(i32 %22, i32 %24)
ret double %25
}