#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 */
scalar_t__ EACCES;
scalar_t__ ENOENT;
int /*<<< orphan*/ F_OK;
int access(char *, int /*<<< orphan*/);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
unsigned int _errno(FILE *output) {
  char *path = "/etc/fstab";
  int val;
  val = access(path, F_OK);
  if (val == 0)
    fprintf(output, "%u", 1);
  else {
    if (errno == ENOENT)
      fprintf(output, "%d", 0);
    else {
      if (errno == EACCES)
        fprintf(output, "%u", 2);
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<_errno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e7e(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1170 <_errno+0x50>
mov    -0x8(%rbp),%rdi
lea    0xeaa(%rip),%rsi
mov    $0x1,%edx
call   1030 <fprintf@plt>
jmp    11da <_errno+0xba>
mov    0x2e61(%rip),%rax
mov    (%rax),%rax
mov    0x2e47(%rip),%rcx
cmp    (%rcx),%rax
jne    11a1 <_errno+0x81>
mov    -0x8(%rbp),%rdi
lea    0xe79(%rip),%rsi
xor    %edx,%edx
call   1030 <fprintf@plt>
jmp    11d5 <_errno+0xb5>
mov    0x2e30(%rip),%rax
mov    (%rax),%rax
mov    0x2e36(%rip),%rcx
cmp    (%rcx),%rax
jne    11d0 <_errno+0xb0>
mov    -0x8(%rbp),%rdi
lea    0xe45(%rip),%rsi
mov    $0x2,%edx
call   1030 <fprintf@plt>
jmp    11d5 <_errno+0xb5>
jmp    11da <_errno+0xba>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_errno>:
push   %rbx
mov    %rdi,%rbx
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
lea    0xecc(%rip),%rdi
call   1040 <access@plt>
test   %eax,%eax
je     1161 <_errno+0x41>
mov    0x2e94(%rip),%rax
mov    (%rax),%rax
mov    0x2e7a(%rip),%rcx
cmp    (%rcx),%rax
jne    1172 <_errno+0x52>
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
jmp    118d <_errno+0x6d>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
jmp    118d <_errno+0x6d>
mov    0x2e6f(%rip),%rcx
cmp    (%rcx),%rax
jne    1192 <_errno+0x72>
lea    0xe86(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"/etc/fstab\00"
@F_OK = global i32 0
@.str.1 = [3 x i8] c"%u\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.2 = [3 x i8] c"%d\00"
@EACCES = global i64 0
define i32 @_errno(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32
store i32* %0, i32** %2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %3
%6 = load i32, i32* @F_OK
%7 = call i32 @access(i8* %5, i32 %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32*, i32** %2
%12 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %29
13: ; preds = %1
%14 = load i64, i64* @errno
%15 = load i64, i64* @ENOENT
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32*, i32** %2
%19 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 0)
br label %28
20: ; preds = %13
%21 = load i64, i64* @errno
%22 = load i64, i64* @EACCES
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32*, i32** %2
%26 = call i32 @fprintf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %27
27: ; preds = %24, %20
br label %28
28: ; preds = %27, %17
br label %29
29: ; preds = %28, %10
ret i32 1
}

LLVM IR (-O2):
@.str = [11 x i8] c"/etc/fstab\00"
@F_OK = global i32 0
@.str.1 = [3 x i8] c"%u\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.2 = [3 x i8] c"%d\00"
@EACCES = global i64 0
define i32 @_errno(i32* nocapture %0) {
%2 = load i32, i32* @F_OK
%3 = tail call i32 @access(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %18
7: ; preds = %1
%8 = load i64, i64* @errno
%9 = load i64, i64* @ENOENT
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 0)
br label %18
13: ; preds = %7
%14 = load i64, i64* @EACCES
%15 = icmp eq i64 %8, %14
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %18
18: ; preds = %11, %16, %13, %5
ret i32 1
}