#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;

/* Variables and functions */
int EXIT_FAILURE;
scalar_t__ EXIT_SUCCESS;
int /*<<< orphan*/ F_OK;
int access(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ logmsg(int, char *, char const *);
scalar_t__ tfs_getldt(char const *, scalar_t__ *, int /*<<< orphan*/ *,
                      int /*<<< orphan*/ *);
int tfs_validate2(const char *cache_fn, time_t last_ddl_time) {
  time_t cached_time = 0;
  if (access(cache_fn, F_OK) == -1) {
    logmsg(7, "tfs_validate - cache file [%s] does not (yet) exist.", cache_fn);
    return EXIT_FAILURE;
  }
  if (tfs_getldt(cache_fn, &cached_time, NULL, NULL) != EXIT_SUCCESS) {
    logmsg(1, "tfs_validate - unable to read cached last_ddl_time for [%s]!",
           cache_fn);
    return EXIT_FAILURE;
  }
  if (cached_time == last_ddl_time) {
    logmsg(7, "tfs_validate - cache file [%s] is already up2date.", cache_fn);
    return EXIT_SUCCESS;
  }
  logmsg(7, "tfs_validate - cache file [%s] is outdated.", cache_fn);
  return EXIT_FAILURE;
}


x86 assembly (clang, -O0):
<tfs_validate2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e75(%rip),%rax
mov    (%rax),%esi
call   1050 <access@plt>
cmp    $0xffffffff,%eax
jne    1189 <tfs_validate2+0x59>
mov    -0x10(%rbp),%rdx
mov    $0x7,%edi
lea    0xe8d(%rip),%rsi
call   1040 <logmsg@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1229 <tfs_validate2+0xf9>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1030 <tfs_getldt@plt>
mov    0x2e34(%rip),%rcx
cmp    (%rcx),%rax
je     11d3 <tfs_validate2+0xa3>
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
lea    0xe78(%rip),%rsi
call   1040 <logmsg@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1229 <tfs_validate2+0xf9>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    1208 <tfs_validate2+0xd8>
mov    -0x10(%rbp),%rdx
mov    $0x7,%edi
lea    0xe81(%rip),%rsi
call   1040 <logmsg@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    1229 <tfs_validate2+0xf9>
mov    -0x10(%rbp),%rdx
mov    $0x7,%edi
lea    0xe8d(%rip),%rsi
call   1040 <logmsg@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tfs_validate2>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
call   1050 <access@plt>
cmp    $0xffffffff,%eax
je     1198 <tfs_validate2+0x68>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <tfs_getldt@plt>
mov    0x2e65(%rip),%r15
cmp    (%r15),%rax
jne    11a1 <tfs_validate2+0x71>
cmp    %r14,0x8(%rsp)
jne    11af <tfs_validate2+0x7f>
lea    0xeec(%rip),%rsi
mov    $0x7,%edi
mov    %rbx,%rdx
call   1040 <logmsg@plt>
mov    (%r15),%eax
jmp    11cc <tfs_validate2+0x9c>
lea    0xe61(%rip),%rsi
jmp    11b6 <tfs_validate2+0x86>
lea    0xe8d(%rip),%rsi
mov    $0x1,%edi
jmp    11bb <tfs_validate2+0x8b>
lea    0xeef(%rip),%rsi
mov    $0x7,%edi
mov    %rbx,%rdx
call   1040 <logmsg@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@F_OK = global i32 0
@.str = [53 x i8] c"tfs_validate - cache file [%s] does not (yet) exist.\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i64 0
@.str.1 = [61 x i8] c"tfs_validate - unable to read cached last_ddl_time for [%s]!\00"
@.str.2 = [51 x i8] c"tfs_validate - cache file [%s] is already up2date.\00"
@.str.3 = [44 x i8] c"tfs_validate - cache file [%s] is outdated.\00"
define i32 @tfs_validate2(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 0, i64* %6
%7 = load i8*, i8** %4
%8 = load i32, i32* @F_OK
%9 = call i32 @access(i8* %7, i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call i32 @logmsg(i32 7, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @EXIT_FAILURE
store i32 %14, i32* %3
br label %37
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = call i64 @tfs_getldt(i8* %16, i64* %6, i32* null, i32* null)
%18 = load i64, i64* @EXIT_SUCCESS
%19 = icmp ne i64 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = call i32 @logmsg(i32 1, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %3
br label %37
24: ; preds = %15
%25 = load i64, i64* %6
%26 = load i64, i64* %5
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load i8*, i8** %4
%30 = call i32 @logmsg(i32 7, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = load i64, i64* @EXIT_SUCCESS
%32 = trunc i64 %31 to i32
store i32 %32, i32* %3
br label %37
33: ; preds = %24
%34 = load i8*, i8** %4
%35 = call i32 @logmsg(i32 7, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @EXIT_FAILURE
store i32 %36, i32* %3
br label %37
37: ; preds = %33, %28, %20, %11
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@F_OK = global i32 0
@.str = [53 x i8] c"tfs_validate - cache file [%s] does not (yet) exist.\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i64 0
@.str.1 = [61 x i8] c"tfs_validate - unable to read cached last_ddl_time for [%s]!\00"
@.str.2 = [51 x i8] c"tfs_validate - cache file [%s] is already up2date.\00"
@.str.3 = [44 x i8] c"tfs_validate - cache file [%s] is outdated.\00"
define i32 @tfs_validate2(i8* %0, i64 %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%5 = load i32, i32* @F_OK
%6 = tail call i32 @access(i8* %0, i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 @logmsg(i32 7, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %0)
%10 = load i32, i32* @EXIT_FAILURE
br label %28
11: ; preds = %2
%12 = call i64 @tfs_getldt(i8* %0, i64* %3, i32* null, i32* null)
%13 = load i64, i64* @EXIT_SUCCESS
%14 = icmp eq i64 %12, %13
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = call i32 @logmsg(i32 1, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%17 = load i32, i32* @EXIT_FAILURE
br label %28
18: ; preds = %11
%19 = load i64, i64* %3
%20 = icmp eq i64 %19, %1
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = call i32 @logmsg(i32 7, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%23 = load i64, i64* @EXIT_SUCCESS
%24 = trunc i64 %23 to i32
br label %28
25: ; preds = %18
%26 = call i32 @logmsg(i32 7, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%27 = load i32, i32* @EXIT_FAILURE
br label %28
28: ; preds = %25, %21, %15, %8
%29 = phi i32 [ %10, %8 ], [ %17, %15 ], [ %24, %21 ], [ %27, %25 ]
ret i32 %29
}