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

/* Variables and functions */
scalar_t__ ENOENT;
int /*<<< orphan*/ S_ISREG(int /*<<< orphan*/);
scalar_t__ errno;
scalar_t__ stat(char *, struct stat *);
bool ltr_int_test_file(char *fname, time_t *ts) {
  struct stat finfo;
  if (stat(fname, &finfo) != 0) {
    *ts = 0;
    if (errno == ENOENT) {
      return true;
    }
  }
  if (!S_ISREG(finfo.st_mode)) {
    *ts = 0;
    return false;
  }
  *ts = finfo.st_mtime;
  return false;
}


x86 assembly (clang, -O0):
<ltr_int_test_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <stat@plt>
cmp    $0x0,%rax
je     117c <ltr_int_test_file+0x5c>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    0x2e88(%rip),%rax
mov    (%rax),%rax
mov    0x2e6e(%rip),%rcx
cmp    (%rcx),%rax
jne    1177 <ltr_int_test_file+0x57>
movl   $0x1,-0x4(%rbp)
jmp    11b3 <ltr_int_test_file+0x93>
jmp    117c <ltr_int_test_file+0x5c>
mov    -0x1c(%rbp),%edi
call   1040 <S_ISREG@plt>
cmp    $0x0,%eax
jne    11a3 <ltr_int_test_file+0x83>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11b3 <ltr_int_test_file+0x93>
mov    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ltr_int_test_file>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0x8(%rsp),%rsi
call   1030 <stat@plt>
test   %rax,%rax
je     1158 <ltr_int_test_file+0x38>
movl   $0x0,(%rbx)
mov    0x2e9c(%rip),%rax
mov    (%rax),%rcx
mov    0x2e82(%rip),%rdx
mov    $0x1,%eax
cmp    (%rdx),%rcx
je     116d <ltr_int_test_file+0x4d>
mov    0xc(%rsp),%edi
call   1040 <S_ISREG@plt>
test   %eax,%eax
je     1169 <ltr_int_test_file+0x49>
mov    0x8(%rsp),%eax
mov    %eax,(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32 }
@errno = global i64 0
@ENOENT = global i64 0
define i32 @ltr_int_test_file(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca %struct.stat
store i8* %0, i8** %4
store i32* %1, i32** %5
%7 = load i8*, i8** %4
%8 = call i64 @stat(i8* %7, %struct.stat* %6)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i32*, i32** %5
store i32 0, i32* %11
%12 = load i64, i64* @errno
%13 = load i64, i64* @ENOENT
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %10
store i32 1, i32* %3
br label %28
16: ; preds = %10
br label %17
17: ; preds = %16, %2
%18 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%19 = load i32, i32* %18
%20 = call i32 @S_ISREG(i32 %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = load i32*, i32** %5
store i32 0, i32* %23
store i32 0, i32* %3
br label %28
24: ; preds = %17
%25 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%26 = load i32, i32* %25
%27 = load i32*, i32** %5
store i32 %26, i32* %27
store i32 0, i32* %3
br label %28
28: ; preds = %24, %22, %15
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
@errno = global i64 0
@ENOENT = global i64 0
define i32 @ltr_int_test_file(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = call i64 @stat(i8* %0, %struct.stat* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %2
store i32 0, i32* %1
%8 = load i64, i64* @errno
%9 = load i64, i64* @ENOENT
%10 = icmp eq i64 %8, %9
br i1 %10, label %19, label %11
11: ; preds = %7, %2
%12 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%13 = load i32, i32* %12
%14 = call i32 @S_ISREG(i32 %13)
%15 = icmp eq i32 %14, 0
%16 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%17 = load i32, i32* %16
%18 = select i1 %15, i32 0, i32 %17
store i32 %18, i32* %1
br label %19
19: ; preds = %11, %7
%20 = phi i32 [ 1, %7 ], [ 0, %11 ]
ret i32 %20
}