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

/* Variables and functions */
char *__imlib_FileRealFile(char const *);
scalar_t__ __imlib_IsRealFile(char const *);
int /*<<< orphan*/ free(char *);
scalar_t__ stat(char *, struct stat *);
char *strdup(char const *);
time_t __imlib_FileModDate(const char *s) {
  struct stat st;
  char *fl;
  if ((!s) || (!*s))
    return 0;
  if (__imlib_IsRealFile(s))
    fl = strdup(s);
  else
    fl = __imlib_FileRealFile(s);
  if (!fl)
    return 0;
  if (stat(fl, &st) < 0) {
    free(fl);
    return 0;
  }
  if (st.st_mtime > st.st_ctime) {
    free(fl);
    return st.st_mtime;
  }
  free(fl);
  return st.st_ctime;
}


x86 assembly (clang, -O0):
<__imlib_FileModDate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1174 <__imlib_FileModDate+0x24>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1181 <__imlib_FileModDate+0x31>
movq   $0x0,-0x8(%rbp)
jmp    122d <__imlib_FileModDate+0xdd>
mov    -0x10(%rbp),%rdi
call   1060 <__imlib_IsRealFile@plt>
cmp    $0x0,%rax
je     11a6 <__imlib_FileModDate+0x56>
mov    -0x10(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x28(%rbp)
jmp    11b3 <__imlib_FileModDate+0x63>
mov    -0x10(%rbp),%rdi
call   1040 <__imlib_FileRealFile@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11cb <__imlib_FileModDate+0x7b>
movq   $0x0,-0x8(%rbp)
jmp    122d <__imlib_FileModDate+0xdd>
mov    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jge    11f8 <__imlib_FileModDate+0xa8>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    122d <__imlib_FileModDate+0xdd>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jle    121c <__imlib_FileModDate+0xcc>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    122d <__imlib_FileModDate+0xdd>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__imlib_FileModDate>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     11b6 <__imlib_FileModDate+0x66>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     11b6 <__imlib_FileModDate+0x66>
mov    %rbx,%rdi
call   1060 <__imlib_IsRealFile@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     117d <__imlib_FileModDate+0x2d>
call   1070 <strdup@plt>
jmp    1182 <__imlib_FileModDate+0x32>
call   1040 <__imlib_FileRealFile@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11b6 <__imlib_FileModDate+0x66>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <stat@plt>
test   %rax,%rax
js     11c2 <__imlib_FileModDate+0x72>
mov    (%rsp),%r14
mov    0x8(%rsp),%r15
mov    %rbx,%rdi
call   1030 <free@plt>
cmp    %r15,%r14
jle    11ce <__imlib_FileModDate+0x7e>
mov    (%rsp),%rax
jmp    11b8 <__imlib_FileModDate+0x68>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    11b8 <__imlib_FileModDate+0x68>
mov    0x8(%rsp),%rax
jmp    11b8 <__imlib_FileModDate+0x68>

LLVM IR (-O0):
%struct.stat = type { i64, i64 }
define i64 @__imlib_FileModDate(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca %struct.stat
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8, %1
store i64 0, i64* %2
br label %50
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i64 @__imlib_IsRealFile(i8* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = call i8* @strdup(i8* %18)
store i8* %19, i8** %5
br label %23
20: ; preds = %13
%21 = load i8*, i8** %3
%22 = call i8* @__imlib_FileRealFile(i8* %21)
store i8* %22, i8** %5
br label %23
23: ; preds = %20, %17
%24 = load i8*, i8** %5
%25 = icmp ne i8* %24, null
br i1 %25, label %27, label %26
26: ; preds = %23
store i64 0, i64* %2
br label %50
27: ; preds = %23
%28 = load i8*, i8** %5
%29 = call i64 @stat(i8* %28, %struct.stat* %4)
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i8*, i8** %5
%33 = call i32 @free(i8* %32)
store i64 0, i64* %2
br label %50
34: ; preds = %27
%35 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%36 = load i64, i64* %35
%37 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 1
%38 = load i64, i64* %37
%39 = icmp sgt i64 %36, %38
br i1 %39, label %40, label %45
40: ; preds = %34
%41 = load i8*, i8** %5
%42 = call i32 @free(i8* %41)
%43 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%44 = load i64, i64* %43
store i64 %44, i64* %2
br label %50
45: ; preds = %34
%46 = load i8*, i8** %5
%47 = call i32 @free(i8* %46)
%48 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 1
%49 = load i64, i64* %48
store i64 %49, i64* %2
br label %50
50: ; preds = %45, %40, %31, %26, %12
%51 = load i64, i64* %2
ret i64 %51
}

LLVM IR (-O2):
%struct.stat = type { i64, i64 }
define i64 @__imlib_FileModDate(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = icmp eq i8* %0, null
br i1 %4, label %34, label %5
5: ; preds = %1
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 0
br i1 %7, label %34, label %8
8: ; preds = %5
%9 = tail call i64 @__imlib_IsRealFile(i8* %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i8* @strdup(i8* %0)
br label %15
13: ; preds = %8
%14 = tail call i8* @__imlib_FileRealFile(i8* %0)
br label %15
15: ; preds = %13, %11
%16 = phi i8* [ %12, %11 ], [ %14, %13 ]
%17 = icmp eq i8* %16, null
br i1 %17, label %34, label %18
18: ; preds = %15
%19 = call i64 @stat(i8* %16, %struct.stat* %2)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 @free(i8* %16)
br label %34
23: ; preds = %18
%24 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%25 = load i64, i64* %24
%26 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%27 = load i64, i64* %26
%28 = icmp sgt i64 %25, %27
%29 = call i32 @free(i8* %16)
br i1 %28, label %30, label %32
30: ; preds = %23
%31 = load i64, i64* %24
br label %34
32: ; preds = %23
%33 = load i64, i64* %26
br label %34
34: ; preds = %15, %1, %5, %32, %30, %21
%35 = phi i64 [ 0, %21 ], [ %31, %30 ], [ %33, %32 ], [ 0, %5 ], [ 0, %1 ], [ 0, %15 ]
ret i64 %35
}