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

/* Variables and functions */
scalar_t__ ENOENT;
scalar_t__ ENOTDIR;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(int /*<<< orphan*/ *);
int main() {
  int fd;
  fd = open("/bin/true", O_RDONLY);
  if (fd < 0) {
    perror(NULL);
    exit(EXIT_FAILURE);
  }
  close(fd);
  fd = open("/bin/true/", O_RDONLY);
  if (fd >= 0 || errno != ENOTDIR) {
    perror(NULL);
    exit(EXIT_FAILURE);
  }
  close(fd);
  fd = open("/bin/true/.", O_RDONLY);
  if (fd >= 0 || errno != ENOTDIR) {
    perror(NULL);
    exit(EXIT_FAILURE);
  }
  close(fd);
  fd = open("/bin/true/..", O_RDONLY);
  if (fd >= 0 || errno != ENOTDIR) {
    perror(NULL);
    exit(EXIT_FAILURE);
  }
  close(fd);
  fd = open("/6a05942f08d5a72de56483487963deec", O_RDONLY);
  if (fd >= 0 || errno != ENOENT) {
    perror(NULL);
    exit(EXIT_FAILURE);
  }
  close(fd);
  fd = open("/6a05942f08d5a72de56483487963deec/", O_RDONLY);
  if (fd >= 0 || errno != ENOENT) {
    perror(NULL);
    exit(EXIT_FAILURE);
  }
  close(fd);
  fd = open("/6a05942f08d5a72de56483487963deec/.", O_RDONLY);
  if (fd >= 0 || errno != ENOENT) {
    perror(NULL);
    exit(EXIT_FAILURE);
  }
  close(fd);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
lea    0xea1(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1188 <main+0x48>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <perror@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%esi
lea    0xe6a(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11cc <main+0x8c>
mov    0x2e17(%rip),%rax
mov    (%rax),%rax
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%rax
je     11e3 <main+0xa3>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <perror@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%esi
lea    0xe1a(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1227 <main+0xe7>
mov    0x2dbc(%rip),%rax
mov    (%rax),%rax
mov    0x2dda(%rip),%rcx
cmp    (%rcx),%rax
je     123e <main+0xfe>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <perror@plt>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%esi
lea    0xdcb(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1282 <main+0x142>
mov    0x2d61(%rip),%rax
mov    (%rax),%rax
mov    0x2d7f(%rip),%rcx
cmp    (%rcx),%rax
je     1299 <main+0x159>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <perror@plt>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    0x2d38(%rip),%rax
mov    (%rax),%esi
lea    0xd7d(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    12dd <main+0x19d>
mov    0x2d06(%rip),%rax
mov    (%rax),%rax
mov    0x2cdc(%rip),%rcx
cmp    (%rcx),%rax
je     12f4 <main+0x1b4>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <perror@plt>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    0x2cdd(%rip),%rax
mov    (%rax),%esi
lea    0xd44(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1338 <main+0x1f8>
mov    0x2cab(%rip),%rax
mov    (%rax),%rax
mov    0x2c81(%rip),%rcx
cmp    (%rcx),%rax
je     134f <main+0x20f>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <perror@plt>
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    0x2c82(%rip),%rax
mov    (%rax),%esi
lea    0xd0c(%rip),%rdi
call   1040 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1393 <main+0x253>
mov    0x2c50(%rip),%rax
mov    (%rax),%rax
mov    0x2c26(%rip),%rcx
cmp    (%rcx),%rax
je     13aa <main+0x26a>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <perror@plt>
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%edi
call   1030 <close@plt>
mov    0x2c07(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2e94(%rip),%rbx
mov    (%rbx),%esi
lea    0xeab(%rip),%rdi
call   1040 <open@plt>
test   %eax,%eax
js     1266 <main+0x126>
mov    %eax,%edi
call   1030 <close@plt>
mov    (%rbx),%esi
lea    0xe98(%rip),%rdi
call   1040 <open@plt>
test   %eax,%eax
jns    1266 <main+0x126>
mov    0x2e4a(%rip),%r14
mov    (%r14),%rcx
mov    0x2e68(%rip),%r15
cmp    (%r15),%rcx
jne    1266 <main+0x126>
mov    %eax,%edi
call   1030 <close@plt>
mov    (%rbx),%esi
lea    0xe6c(%rip),%rdi
call   1040 <open@plt>
test   %eax,%eax
jns    1266 <main+0x126>
mov    (%r14),%rcx
cmp    (%r15),%rcx
jne    1266 <main+0x126>
mov    %eax,%edi
call   1030 <close@plt>
mov    (%rbx),%esi
lea    0xe4f(%rip),%rdi
call   1040 <open@plt>
test   %eax,%eax
jns    1266 <main+0x126>
mov    (%r14),%rcx
cmp    (%r15),%rcx
jne    1266 <main+0x126>
mov    %eax,%edi
call   1030 <close@plt>
mov    (%rbx),%esi
lea    0xe37(%rip),%rdi
call   1040 <open@plt>
test   %eax,%eax
jns    1266 <main+0x126>
mov    (%r14),%rcx
mov    0x2da6(%rip),%r15
cmp    (%r15),%rcx
jne    1266 <main+0x126>
mov    %eax,%edi
call   1030 <close@plt>
mov    (%rbx),%esi
lea    0xe31(%rip),%rdi
call   1040 <open@plt>
test   %eax,%eax
jns    1266 <main+0x126>
mov    (%r14),%rcx
cmp    (%r15),%rcx
jne    1266 <main+0x126>
mov    %eax,%edi
call   1030 <close@plt>
mov    (%rbx),%esi
lea    0xe33(%rip),%rdi
call   1040 <open@plt>
test   %eax,%eax
jns    1266 <main+0x126>
mov    (%r14),%rcx
cmp    (%r15),%rcx
jne    1266 <main+0x126>
mov    %eax,%edi
call   1030 <close@plt>
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
xor    %edi,%edi
call   1050 <perror@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"/bin/true\00"
@O_RDONLY = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [11 x i8] c"/bin/true/\00"
@errno = global i64 0
@ENOTDIR = global i64 0
@.str.2 = [12 x i8] c"/bin/true/.\00"
@.str.3 = [13 x i8] c"/bin/true/..\00"
@.str.4 = [34 x i8] c"/6a05942f08d5a72de56483487963deec\00"
@ENOENT = global i64 0
@.str.5 = [35 x i8] c"/6a05942f08d5a72de56483487963deec/\00"
@.str.6 = [36 x i8] c"/6a05942f08d5a72de56483487963deec/.\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @O_RDONLY
%4 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %3)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = call i32 @perror(i32* null)
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %0
%12 = load i32, i32* %2
%13 = call i32 @close(i32 %12)
%14 = load i32, i32* @O_RDONLY
%15 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %14)
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = icmp sge i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %11
%19 = load i64, i64* @errno
%20 = load i64, i64* @ENOTDIR
%21 = icmp ne i64 %19, %20
br i1 %21, label %22, label %26
22: ; preds = %18, %11
%23 = call i32 @perror(i32* null)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %18
%27 = load i32, i32* %2
%28 = call i32 @close(i32 %27)
%29 = load i32, i32* @O_RDONLY
%30 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %29)
store i32 %30, i32* %2
%31 = load i32, i32* %2
%32 = icmp sge i32 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %26
%34 = load i64, i64* @errno
%35 = load i64, i64* @ENOTDIR
%36 = icmp ne i64 %34, %35
br i1 %36, label %37, label %41
37: ; preds = %33, %26
%38 = call i32 @perror(i32* null)
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %33
%42 = load i32, i32* %2
%43 = call i32 @close(i32 %42)
%44 = load i32, i32* @O_RDONLY
%45 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %44)
store i32 %45, i32* %2
%46 = load i32, i32* %2
%47 = icmp sge i32 %46, 0
br i1 %47, label %52, label %48
48: ; preds = %41
%49 = load i64, i64* @errno
%50 = load i64, i64* @ENOTDIR
%51 = icmp ne i64 %49, %50
br i1 %51, label %52, label %56
52: ; preds = %48, %41
%53 = call i32 @perror(i32* null)
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %48
%57 = load i32, i32* %2
%58 = call i32 @close(i32 %57)
%59 = load i32, i32* @O_RDONLY
%60 = call i32 @open(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %59)
store i32 %60, i32* %2
%61 = load i32, i32* %2
%62 = icmp sge i32 %61, 0
br i1 %62, label %67, label %63
63: ; preds = %56
%64 = load i64, i64* @errno
%65 = load i64, i64* @ENOENT
%66 = icmp ne i64 %64, %65
br i1 %66, label %67, label %71
67: ; preds = %63, %56
%68 = call i32 @perror(i32* null)
%69 = load i32, i32* @EXIT_FAILURE
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %63
%72 = load i32, i32* %2
%73 = call i32 @close(i32 %72)
%74 = load i32, i32* @O_RDONLY
%75 = call i32 @open(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %74)
store i32 %75, i32* %2
%76 = load i32, i32* %2
%77 = icmp sge i32 %76, 0
br i1 %77, label %82, label %78
78: ; preds = %71
%79 = load i64, i64* @errno
%80 = load i64, i64* @ENOENT
%81 = icmp ne i64 %79, %80
br i1 %81, label %82, label %86
82: ; preds = %78, %71
%83 = call i32 @perror(i32* null)
%84 = load i32, i32* @EXIT_FAILURE
%85 = call i32 @exit(i32 %84)
unreachable
86: ; preds = %78
%87 = load i32, i32* %2
%88 = call i32 @close(i32 %87)
%89 = load i32, i32* @O_RDONLY
%90 = call i32 @open(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i32 %89)
store i32 %90, i32* %2
%91 = load i32, i32* %2
%92 = icmp sge i32 %91, 0
br i1 %92, label %97, label %93
93: ; preds = %86
%94 = load i64, i64* @errno
%95 = load i64, i64* @ENOENT
%96 = icmp ne i64 %94, %95
br i1 %96, label %97, label %101
97: ; preds = %93, %86
%98 = call i32 @perror(i32* null)
%99 = load i32, i32* @EXIT_FAILURE
%100 = call i32 @exit(i32 %99)
unreachable
101: ; preds = %93
%102 = load i32, i32* %2
%103 = call i32 @close(i32 %102)
%104 = load i32, i32* @EXIT_SUCCESS
%105 = call i32 @exit(i32 %104)
unreachable
}

LLVM IR (-O2):
@.str = [10 x i8] c"/bin/true\00"
@O_RDONLY = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [11 x i8] c"/bin/true/\00"
@errno = global i64 0
@ENOTDIR = global i64 0
@.str.2 = [12 x i8] c"/bin/true/.\00"
@.str.3 = [13 x i8] c"/bin/true/..\00"
@.str.4 = [34 x i8] c"/6a05942f08d5a72de56483487963deec\00"
@ENOENT = global i64 0
@.str.5 = [35 x i8] c"/6a05942f08d5a72de56483487963deec/\00"
@.str.6 = [36 x i8] c"/6a05942f08d5a72de56483487963deec/.\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = load i32, i32* @O_RDONLY
%2 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp slt i32 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = tail call i32 @perror(i32* null)
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %0
%9 = tail call i32 @close(i32 %2)
%10 = load i32, i32* @O_RDONLY
%11 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = icmp sgt i32 %11, -1
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = load i64, i64* @errno
%15 = load i64, i64* @ENOTDIR
%16 = icmp eq i64 %14, %15
br i1 %16, label %21, label %17
17: ; preds = %13, %8
%18 = tail call i32 @perror(i32* null)
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %13
%22 = tail call i32 @close(i32 %11)
%23 = load i32, i32* @O_RDONLY
%24 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = icmp sgt i32 %24, -1
br i1 %25, label %30, label %26
26: ; preds = %21
%27 = load i64, i64* @errno
%28 = load i64, i64* @ENOTDIR
%29 = icmp eq i64 %27, %28
br i1 %29, label %34, label %30
30: ; preds = %26, %21
%31 = tail call i32 @perror(i32* null)
%32 = load i32, i32* @EXIT_FAILURE
%33 = tail call i32 @exit(i32 %32)
unreachable
34: ; preds = %26
%35 = tail call i32 @close(i32 %24)
%36 = load i32, i32* @O_RDONLY
%37 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = icmp sgt i32 %37, -1
br i1 %38, label %43, label %39
39: ; preds = %34
%40 = load i64, i64* @errno
%41 = load i64, i64* @ENOTDIR
%42 = icmp eq i64 %40, %41
br i1 %42, label %47, label %43
43: ; preds = %39, %34
%44 = tail call i32 @perror(i32* null)
%45 = load i32, i32* @EXIT_FAILURE
%46 = tail call i32 @exit(i32 %45)
unreachable
47: ; preds = %39
%48 = tail call i32 @close(i32 %37)
%49 = load i32, i32* @O_RDONLY
%50 = tail call i32 @open(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %49)
%51 = icmp sgt i32 %50, -1
br i1 %51, label %56, label %52
52: ; preds = %47
%53 = load i64, i64* @errno
%54 = load i64, i64* @ENOENT
%55 = icmp eq i64 %53, %54
br i1 %55, label %60, label %56
56: ; preds = %52, %47
%57 = tail call i32 @perror(i32* null)
%58 = load i32, i32* @EXIT_FAILURE
%59 = tail call i32 @exit(i32 %58)
unreachable
60: ; preds = %52
%61 = tail call i32 @close(i32 %50)
%62 = load i32, i32* @O_RDONLY
%63 = tail call i32 @open(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %62)
%64 = icmp sgt i32 %63, -1
br i1 %64, label %69, label %65
65: ; preds = %60
%66 = load i64, i64* @errno
%67 = load i64, i64* @ENOENT
%68 = icmp eq i64 %66, %67
br i1 %68, label %73, label %69
69: ; preds = %65, %60
%70 = tail call i32 @perror(i32* null)
%71 = load i32, i32* @EXIT_FAILURE
%72 = tail call i32 @exit(i32 %71)
unreachable
73: ; preds = %65
%74 = tail call i32 @close(i32 %63)
%75 = load i32, i32* @O_RDONLY
%76 = tail call i32 @open(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i32 %75)
%77 = icmp sgt i32 %76, -1
br i1 %77, label %82, label %78
78: ; preds = %73
%79 = load i64, i64* @errno
%80 = load i64, i64* @ENOENT
%81 = icmp eq i64 %79, %80
br i1 %81, label %86, label %82
82: ; preds = %78, %73
%83 = tail call i32 @perror(i32* null)
%84 = load i32, i32* @EXIT_FAILURE
%85 = tail call i32 @exit(i32 %84)
unreachable
86: ; preds = %78
%87 = tail call i32 @close(i32 %76)
%88 = load i32, i32* @EXIT_SUCCESS
%89 = tail call i32 @exit(i32 %88)
unreachable
}