#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 {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ set_error(int *, int /*<<< orphan*/ *, int);
scalar_t__ stat(char const *, struct stat *);
int _zip_file_exists(const char *fn, unsigned int flags, int *zep) {
  struct stat st;
  if (fn == NULL) {
    set_error(zep, NULL, 18);
    return -1;
  }
  if (stat(fn, &st) != 0) {
    if (flags & 1)
      return 0;
    else {
      set_error(zep, NULL, 11);
      return -1;
    }
  } else if ((flags & 2)) {
    set_error(zep, NULL, 10);
    return -1;
  }
  return 1;
}


x86 assembly (clang, -O0):
<_zip_file_exists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115c <_zip_file_exists+0x3c>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x12,%edx
call   1030 <set_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e5 <_zip_file_exists+0xc5>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0x0,%rax
je     11ac <_zip_file_exists+0x8c>
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     118e <_zip_file_exists+0x6e>
movl   $0x0,-0x4(%rbp)
jmp    11e5 <_zip_file_exists+0xc5>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xb,%edx
call   1030 <set_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e5 <_zip_file_exists+0xc5>
mov    -0x14(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     11d9 <_zip_file_exists+0xb9>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1030 <set_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e5 <_zip_file_exists+0xc5>
jmp    11de <_zip_file_exists+0xbe>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_zip_file_exists>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rbx
test   %rdi,%rdi
je     114e <_zip_file_exists+0x2e>
mov    %esi,%ebp
mov    %rsp,%rsi
call   1040 <stat@plt>
test   %rax,%rax
je     115a <_zip_file_exists+0x3a>
xor    %eax,%eax
test   $0x1,%bpl
jne    1179 <_zip_file_exists+0x59>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xb,%edx
jmp    116f <_zip_file_exists+0x4f>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x12,%edx
jmp    116f <_zip_file_exists+0x4f>
mov    $0x1,%eax
test   $0x2,%bpl
je     1179 <_zip_file_exists+0x59>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <set_error@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
define i32 @_zip_file_exists(i8* %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca %struct.stat
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%9 = load i8*, i8** %5
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i32*, i32** %7
%13 = call i32 @set_error(i32* %12, i32* null, i32 18)
store i32 -1, i32* %4
br label %35
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = call i64 @stat(i8* %15, %struct.stat* %8)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i32, i32* %6
%20 = and i32 %19, 1
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 0, i32* %4
br label %35
23: ; preds = %18
%24 = load i32*, i32** %7
%25 = call i32 @set_error(i32* %24, i32* null, i32 11)
store i32 -1, i32* %4
br label %35
26: ; preds = %14
%27 = load i32, i32* %6
%28 = and i32 %27, 2
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32*, i32** %7
%32 = call i32 @set_error(i32* %31, i32* null, i32 10)
store i32 -1, i32* %4
br label %35
33: ; preds = %26
br label %34
34: ; preds = %33
store i32 1, i32* %4
br label %35
35: ; preds = %34, %30, %23, %22, %11
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
%struct.stat = type { i32 }
define i32 @_zip_file_exists(i8* %0, i32 %1, i32* %2) {
%4 = alloca %struct.stat
%5 = bitcast %struct.stat* %4 to i8*
%6 = icmp eq i8* %0, null
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @set_error(i32* %2, i32* null, i32 18)
br label %22
9: ; preds = %3
%10 = call i64 @stat(i8* %0, %struct.stat* %4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %9
%13 = and i32 %1, 1
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = call i32 @set_error(i32* %2, i32* null, i32 11)
br label %22
17: ; preds = %9
%18 = and i32 %1, 2
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = call i32 @set_error(i32* %2, i32* null, i32 10)
br label %22
22: ; preds = %17, %12, %20, %15, %7
%23 = phi i32 [ -1, %7 ], [ -1, %15 ], [ -1, %20 ], [ 0, %12 ], [ 1, %17 ]
ret i32 %23
}