#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int isfexists(char *filename) {
  FILE *fp = (((filename) == NULL ? 1 : (*(filename) == '\000' ? 1 : 0))
                  ? NULL
                  : fopen(filename, "r"));
  int status = 0;
  if (fp != NULL) {
    status = 1;
    fclose(fp);
  }
  return (status);
}


x86 assembly (clang, -O0):
<isfexists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1146 <isfexists+0x26>
mov    $0x1,%al
test   $0x1,%al
jne    1174 <isfexists+0x54>
jmp    117f <isfexists+0x5f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1165 <isfexists+0x45>
mov    $0x1,%al
test   $0x1,%al
jne    1174 <isfexists+0x54>
jmp    117f <isfexists+0x5f>
xor    %eax,%eax
test   $0x1,%al
jne    1174 <isfexists+0x54>
jmp    117f <isfexists+0x5f>
xor    %eax,%eax
mov    %rax,-0x20(%rbp)
jmp    1193 <isfexists+0x73>
mov    -0x8(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11bd <isfexists+0x9d>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isfexists>:
push   %rbx
xor    %ebx,%ebx
test   %rdi,%rdi
je     114b <isfexists+0x2b>
cmpb   $0x0,(%rdi)
je     114b <isfexists+0x2b>
lea    0xecc(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     114b <isfexists+0x2b>
mov    %rax,%rdi
call   1030 <fclose@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @isfexists(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
br i1 true, label %15, label %16
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %8
br i1 true, label %15, label %16
14: ; preds = %8
br i1 false, label %15, label %16
15: ; preds = %14, %13, %7
br label %19
16: ; preds = %14, %13, %7
%17 = load i8*, i8** %2
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %16, %15
%20 = phi i32* [ null, %15 ], [ %18, %16 ]
store i32* %20, i32** %3
store i32 0, i32* %4
%21 = load i32*, i32** %3
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %19
store i32 1, i32* %4
%24 = load i32*, i32** %3
%25 = call i32 @fclose(i32* %24)
br label %26
26: ; preds = %23, %19
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @isfexists(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @fclose(i32* %7)
br label %11
11: ; preds = %1, %3, %9, %6
%12 = phi i32 [ 1, %9 ], [ 0, %6 ], [ 0, %3 ], [ 0, %1 ]
ret i32 %12
}