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

/* Variables and functions */
int stat(char const *, struct stat *);
scalar_t__ time(int /*<<< orphan*/ *);
int expired(const char *fname, int age) {
  struct stat st;
  int rc = stat(fname, &st);
  if (rc != 0) {
    return 1;
  }
  if (st.st_mtime + age < time(NULL)) {
    return 2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<expired>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <stat@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1155 <expired+0x35>
movl   $0x1,-0x4(%rbp)
jmp    1190 <expired+0x70>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jge    1189 <expired+0x69>
movl   $0x2,-0x4(%rbp)
jmp    1190 <expired+0x70>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expired>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
lea    0x8(%rsp),%rsi
call   1030 <stat@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    1158 <expired+0x38>
movslq %ebx,%rbx
add    0x8(%rsp),%rbx
xor    %edi,%edi
call   1040 <time@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rbx
setl   %al
add    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
define i32 @expired(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.stat
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i8*, i8** %4
%9 = call i32 @stat(i8* %8, %struct.stat* %6)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 1, i32* %3
br label %23
13: ; preds = %2
%14 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%15 = load i64, i64* %14
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = add nsw i64 %15, %17
%19 = call i64 @time(i32* null)
%20 = icmp slt i64 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %13
store i32 2, i32* %3
br label %23
22: ; preds = %13
store i32 0, i32* %3
br label %23
23: ; preds = %22, %21, %12
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
%struct.stat = type { i64 }
define i32 @expired(i8* nocapture %0, i32 %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = call i32 @stat(i8* %0, %struct.stat* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %2
%8 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%9 = load i64, i64* %8
%10 = sext i32 %1 to i64
%11 = add nsw i64 %9, %10
%12 = tail call i64 @time(i32* null)
%13 = icmp slt i64 %11, %12
%14 = select i1 %13, i32 2, i32 0
br label %15
15: ; preds = %7, %2
%16 = phi i32 [ 1, %2 ], [ %14, %7 ]
ret i32 %16
}