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

/* Variables and functions */
int /*<<< orphan*/ lookarch(char *);
scalar_t__ stat(char *, struct stat *);
time_t exists(char *filename) {
  struct stat buf;
  char *s;
  for (s = filename; *s != '\0' && *s != '(' && *s != ')'; ++s)
    ;
  if (*s != '\0')
    return lookarch(filename);
  if (stat(filename, &buf) < 0)
    return 0;
  else
    return buf.st_mtime;
}


x86 assembly (clang, -O0):
<exists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     116e <exists+0x4e>
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x28,%ecx
mov    %al,-0x21(%rbp)
je     116e <exists+0x4e>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x29,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    117e <exists+0x5e>
jmp    1194 <exists+0x74>
jmp    1183 <exists+0x63>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1134 <exists+0x14>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b5 <exists+0x95>
mov    -0x10(%rbp),%rdi
call   1040 <lookarch@plt>
mov    %eax,-0x4(%rbp)
jmp    11de <exists+0xbe>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <stat@plt>
cmp    $0x0,%rax
jge    11d8 <exists+0xb8>
movl   $0x0,-0x4(%rbp)
jmp    11de <exists+0xbe>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exists>:
push   %rax
mov    %rdi,%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rax),%ecx
lea    -0x28(%rcx),%edx
cmp    $0x2,%dl
jb     1145 <exists+0x25>
test   %cl,%cl
je     114b <exists+0x2b>
add    $0x1,%rax
jmp    1130 <exists+0x10>
pop    %rax
jmp    1040 <lookarch@plt>
mov    %rsp,%rsi
call   1030 <stat@plt>
test   %rax,%rax
js     115d <exists+0x3d>
mov    (%rsp),%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
define i32 @exists(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.stat
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
store i8* %6, i8** %5
br label %7
7: ; preds = %25, %1
%8 = load i8*, i8** %5
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %7
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 40
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 41
br label %22
22: ; preds = %17, %12, %7
%23 = phi i1 [ false, %12 ], [ false, %7 ], [ %21, %17 ]
br i1 %23, label %24, label %28
24: ; preds = %22
br label %25
25: ; preds = %24
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %5
br label %7
28: ; preds = %22
%29 = load i8*, i8** %5
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = load i8*, i8** %3
%35 = call i32 @lookarch(i8* %34)
store i32 %35, i32* %2
br label %44
36: ; preds = %28
%37 = load i8*, i8** %3
%38 = call i64 @stat(i8* %37, %struct.stat* %4)
%39 = icmp slt i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %36
store i32 0, i32* %2
br label %44
41: ; preds = %36
%42 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%43 = load i32, i32* %42
store i32 %43, i32* %2
br label %44
44: ; preds = %41, %40, %33
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
%struct.stat = type { i32 }
define i32 @exists(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
br label %4
4: ; preds = %7, %1
%5 = phi i8* [ %0, %1 ], [ %8, %7 ]
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 0, label %11
i8 40, label %9
i8 41, label %9
]
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %5, i64 1
br label %4
9: ; preds = %4, %4
%10 = tail call i32 @lookarch(i8* %0)
br label %17
11: ; preds = %4
%12 = call i64 @stat(i8* %0, %struct.stat* %2)
%13 = icmp slt i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%16 = load i32, i32* %15
br label %17
17: ; preds = %11, %14, %9
%18 = phi i32 [ %10, %9 ], [ %16, %14 ], [ 0, %11 ]
ret i32 %18
}