#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 /*<<< orphan*/ free(char *);
char *fst_dllpath_to_infopath(char *);
int /*<<< orphan*/ fst_error(char *, char *);
scalar_t__ stat(char *, struct stat *);
int fst_info_file_is_valid(char *dllpath) {
  struct stat dllstat, fststat;
  char *fstpath = fst_dllpath_to_infopath(dllpath);
  if (!fstpath)
    return 0;
  if (stat(dllpath, &dllstat)) {
    fst_error("dll path %s invalid\n", dllpath);
    return !0;
  }
  if (stat(fstpath, &fststat))
    return 0;
  free(fstpath);
  if (dllstat.st_mtime > fststat.st_mtime)
    return 0;
  else
    return !0;
}


x86 assembly (clang, -O0):
<fst_info_file_is_valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fst_dllpath_to_infopath@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1170 <fst_info_file_is_valid+0x30>
movl   $0x0,-0x4(%rbp)
jmp    11f0 <fst_info_file_is_valid+0xb0>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
je     11a3 <fst_info_file_is_valid+0x63>
mov    -0x10(%rbp),%rsi
lea    0xe6e(%rip),%rdi
call   1060 <fst_error@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f0 <fst_info_file_is_valid+0xb0>
mov    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
je     11c6 <fst_info_file_is_valid+0x86>
movl   $0x0,-0x4(%rbp)
jmp    11f0 <fst_info_file_is_valid+0xb0>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jle    11e9 <fst_info_file_is_valid+0xa9>
movl   $0x0,-0x4(%rbp)
jmp    11f0 <fst_info_file_is_valid+0xb0>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fst_info_file_is_valid>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbp
call   1040 <fst_dllpath_to_infopath@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     11ac <fst_info_file_is_valid+0x6c>
mov    %rax,%rbx
lea    0x8(%rsp),%rsi
mov    %rbp,%rdi
call   1050 <stat@plt>
test   %rax,%rax
je     1184 <fst_info_file_is_valid+0x44>
lea    0xe8c(%rip),%rdi
mov    %rbp,%rsi
call   1060 <fst_error@plt>
mov    $0x1,%r14d
jmp    11ac <fst_info_file_is_valid+0x6c>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <stat@plt>
test   %rax,%rax
jne    11ac <fst_info_file_is_valid+0x6c>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rax
xor    %r14d,%r14d
cmp    (%rsp),%rax
setle  %r14b
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [21 x i8] c"dll path %s invalid\0A\00"
define i32 @fst_info_file_is_valid(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.stat
%5 = alloca %struct.stat
%6 = alloca i8*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i8* @fst_dllpath_to_infopath(i8* %7)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %1
store i32 0, i32* %2
br label %34
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i64 @stat(i8* %13, %struct.stat* %4)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = call i32 @fst_error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 1, i32* %2
br label %34
19: ; preds = %12
%20 = load i8*, i8** %6
%21 = call i64 @stat(i8* %20, %struct.stat* %5)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 0, i32* %2
br label %34
24: ; preds = %19
%25 = load i8*, i8** %6
%26 = call i32 @free(i8* %25)
%27 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%28 = load i64, i64* %27
%29 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%30 = load i64, i64* %29
%31 = icmp sgt i64 %28, %30
br i1 %31, label %32, label %33
32: ; preds = %24
store i32 0, i32* %2
br label %34
33: ; preds = %24
store i32 1, i32* %2
br label %34
34: ; preds = %33, %32, %23, %16, %11
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@.str = [21 x i8] c"dll path %s invalid\0A\00"
define i32 @fst_info_file_is_valid(i8* %0) {
%2 = alloca %struct.stat
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %2 to i8*
%5 = bitcast %struct.stat* %3 to i8*
%6 = tail call i8* @fst_dllpath_to_infopath(i8* %0)
%7 = icmp eq i8* %6, null
br i1 %7, label %24, label %8
8: ; preds = %1
%9 = call i64 @stat(i8* %0, %struct.stat* %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = call i32 @fst_error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %24
13: ; preds = %8
%14 = call i64 @stat(i8* %6, %struct.stat* %3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = call i32 @free(i8* %6)
%18 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%19 = load i64, i64* %18
%20 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%21 = load i64, i64* %20
%22 = icmp sle i64 %19, %21
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %16, %13, %1, %11
%25 = phi i32 [ 1, %11 ], [ 0, %1 ], [ 0, %13 ], [ %23, %16 ]
ret i32 %25
}