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

/* Variables and functions */
scalar_t__ EACCES;
scalar_t__ EBUSY;
scalar_t__ EISDIR;
scalar_t__ ENOENT;
scalar_t__ ENOTDIR;
scalar_t__ ENOTEMPTY;
int /*<<< orphan*/ F_OK;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ assert(int);
scalar_t__ errno;
int /*<<< orphan*/ getcwd(char *, int);
int /*<<< orphan*/ puts(char *);
int rmdir(char *);
int unlink(char *);
void test() {
  int err;
  char buffer[512];
  err = unlink("noexist");
  assert(err == -1);
  assert(errno == ENOENT);
  err = unlink("dir-readonly");
  assert(err == -1);
  assert(errno == EISDIR);
  err = unlink("dir-readonly/anotherfile");
  assert(err == -1);
  assert(errno == EACCES);
  err = unlink("file1-link");
  assert(!err);
  err = access("file1", F_OK);
  assert(!err);
  err = access("file1-link", F_OK);
  assert(err == -1);
  err = unlink("file");
  assert(!err);
  err = access("file", F_OK);
  assert(err == -1);
  err = rmdir("noexist");
  assert(err == -1);
  assert(errno == ENOENT);
  err = rmdir("file1");
  assert(err == -1);
  assert(errno == ENOTDIR);
  err = rmdir("dir-readonly/anotherdir");
  assert(err == -1);
  assert(errno == EACCES);
  err = rmdir("dir-full");
  assert(err == -1);
  assert(errno == ENOTEMPTY);
  getcwd(buffer, sizeof(buffer));
  err = rmdir(buffer);
  assert(err == -1);
  assert(errno == EBUSY);
  err = rmdir("/");
  assert(err == -1);
  assert(errno == EBUSY);
  err = rmdir("dir-empty-link");
  assert(err == -1);
  assert(errno == ENOTDIR);
  err = rmdir("dir-empty");
  assert(!err);
  err = access("dir-empty", F_OK);
  assert(err == -1);
  puts("success");
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
lea    0xe8e(%rip),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%rax
mov    0x2e14(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xe55(%rip),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%rax
mov    0x2e03(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xe21(%rip),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%rax
mov    0x2dba(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xdf9(%rip),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%esi
lea    0xdd9(%rip),%rdi
call   1080 <access@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2d1e(%rip),%rax
mov    (%rax),%esi
lea    0xda3(%rip),%rdi
call   1080 <access@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xd7e(%rip),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2cd3(%rip),%rax
mov    (%rax),%esi
lea    0xd53(%rip),%rdi
call   1080 <access@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xd0a(%rip),%rdi
call   1050 <rmdir@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2cb2(%rip),%rax
mov    (%rax),%rax
mov    0x2c90(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xd02(%rip),%rdi
call   1050 <rmdir@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2c71(%rip),%rax
mov    (%rax),%rax
mov    0x2c97(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xcc7(%rip),%rdi
call   1050 <rmdir@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2c30(%rip),%rax
mov    (%rax),%rax
mov    0x2c36(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xc9e(%rip),%rdi
call   1050 <rmdir@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2bef(%rip),%rax
mov    (%rax),%rax
mov    0x2bc5(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x210(%rbp),%rdi
mov    $0x200,%esi
call   1060 <getcwd@plt>
lea    -0x210(%rbp),%rdi
call   1050 <rmdir@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2b9d(%rip),%rax
mov    (%rax),%rax
mov    0x2b8b(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xc14(%rip),%rdi
call   1050 <rmdir@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2b5c(%rip),%rax
mov    (%rax),%rax
mov    0x2b4a(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xbd5(%rip),%rdi
call   1050 <rmdir@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2b1b(%rip),%rax
mov    (%rax),%rax
mov    0x2b41(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xba3(%rip),%rdi
call   1050 <rmdir@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2ab0(%rip),%rax
mov    (%rax),%esi
lea    0xb78(%rip),%rdi
call   1080 <access@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xb62(%rip),%rdi
call   1040 <puts@plt>
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
lea    0xe88(%rip),%rbp
mov    %rbp,%rdi
call   1030 <unlink@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
mov    0x2e33(%rip),%r12
mov    (%r12),%rax
mov    0x2e10(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
sete   %dil
call   1070 <assert@plt>
lea    0xe53(%rip),%rdi
call   1030 <unlink@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
mov    (%r12),%rax
mov    0x2e0d(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
sete   %dil
call   1070 <assert@plt>
lea    0xe2d(%rip),%rdi
call   1030 <unlink@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
mov    (%r12),%rax
mov    0x2dd2(%rip),%r14
xor    %edi,%edi
cmp    (%r14),%rax
sete   %dil
call   1070 <assert@plt>
lea    0xe13(%rip),%rbx
mov    %rbx,%rdi
call   1030 <unlink@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
mov    0x2d69(%rip),%r13
mov    0x0(%r13),%esi
lea    0xdf7(%rip),%r15
mov    %r15,%rdi
call   1080 <access@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
mov    0x0(%r13),%esi
mov    %rbx,%rdi
call   1080 <access@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
lea    0xdb1(%rip),%rbx
mov    %rbx,%rdi
call   1030 <unlink@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
mov    0x0(%r13),%esi
mov    %rbx,%rdi
call   1080 <access@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
mov    %rbp,%rdi
call   1050 <rmdir@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
mov    (%r12),%rax
xor    %edi,%edi
mov    0x2ce6(%rip),%rcx
cmp    (%rcx),%rax
sete   %dil
call   1070 <assert@plt>
mov    %r15,%rdi
call   1050 <rmdir@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
mov    (%r12),%rax
mov    0x2d01(%rip),%rbp
xor    %edi,%edi
cmp    0x0(%rbp),%rax
sete   %dil
call   1070 <assert@plt>
lea    0xd32(%rip),%rdi
call   1050 <rmdir@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
mov    (%r12),%rax
xor    %edi,%edi
cmp    (%r14),%rax
sete   %dil
call   1070 <assert@plt>
lea    0xd1e(%rip),%rdi
call   1050 <rmdir@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
mov    (%r12),%rax
mov    0x2c51(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
sete   %dil
call   1070 <assert@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1060 <getcwd@plt>
mov    %rbx,%rdi
call   1050 <rmdir@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
mov    (%r12),%rax
mov    0x2c2a(%rip),%rbx
xor    %edi,%edi
cmp    (%rbx),%rax
sete   %dil
call   1070 <assert@plt>
lea    0xcb5(%rip),%rdi
call   1050 <rmdir@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
mov    (%r12),%rax
xor    %edi,%edi
cmp    (%rbx),%rax
sete   %dil
call   1070 <assert@plt>
lea    0xc8b(%rip),%rdi
call   1050 <rmdir@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
mov    (%r12),%rax
xor    %edi,%edi
cmp    0x0(%rbp),%rax
sete   %dil
call   1070 <assert@plt>
lea    0xc6d(%rip),%rbx
mov    %rbx,%rdi
call   1050 <rmdir@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
mov    0x0(%r13),%esi
mov    %rbx,%rdi
call   1080 <access@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1070 <assert@plt>
lea    0xc41(%rip),%rdi
call   1040 <puts@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"noexist\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [13 x i8] c"dir-readonly\00"
@EISDIR = global i64 0
@.str.2 = [25 x i8] c"dir-readonly/anotherfile\00"
@EACCES = global i64 0
@.str.3 = [11 x i8] c"file1-link\00"
@.str.4 = [6 x i8] c"file1\00"
@F_OK = global i32 0
@.str.5 = [5 x i8] c"file\00"
@ENOTDIR = global i64 0
@.str.6 = [24 x i8] c"dir-readonly/anotherdir\00"
@.str.7 = [9 x i8] c"dir-full\00"
@ENOTEMPTY = global i64 0
@EBUSY = global i64 0
@.str.8 = [2 x i8] c"/\00"
@.str.9 = [15 x i8] c"dir-empty-link\00"
@.str.10 = [10 x i8] c"dir-empty\00"
@.str.11 = [8 x i8] c"success\00"
define void @test() {
%1 = alloca i32
%2 = alloca [512 x i8]
%3 = call i32 @unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, -1
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = load i64, i64* @errno
%9 = load i64, i64* @ENOENT
%10 = icmp eq i64 %8, %9
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i32 @unlink(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 %13, i32* %1
%14 = load i32, i32* %1
%15 = icmp eq i32 %14, -1
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i64, i64* @errno
%19 = load i64, i64* @EISDIR
%20 = icmp eq i64 %18, %19
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = call i32 @unlink(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i32 %23, i32* %1
%24 = load i32, i32* %1
%25 = icmp eq i32 %24, -1
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i64, i64* @errno
%29 = load i64, i64* @EACCES
%30 = icmp eq i64 %28, %29
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = call i32 @unlink(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
store i32 %33, i32* %1
%34 = load i32, i32* %1
%35 = icmp ne i32 %34, 0
%36 = xor i1 %35, true
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i32, i32* @F_OK
%40 = call i32 @access(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %39)
store i32 %40, i32* %1
%41 = load i32, i32* %1
%42 = icmp ne i32 %41, 0
%43 = xor i1 %42, true
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = load i32, i32* @F_OK
%47 = call i32 @access(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %46)
store i32 %47, i32* %1
%48 = load i32, i32* %1
%49 = icmp eq i32 %48, -1
%50 = zext i1 %49 to i32
%51 = call i32 @assert(i32 %50)
%52 = call i32 @unlink(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
store i32 %52, i32* %1
%53 = load i32, i32* %1
%54 = icmp ne i32 %53, 0
%55 = xor i1 %54, true
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
%58 = load i32, i32* @F_OK
%59 = call i32 @access(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %58)
store i32 %59, i32* %1
%60 = load i32, i32* %1
%61 = icmp eq i32 %60, -1
%62 = zext i1 %61 to i32
%63 = call i32 @assert(i32 %62)
%64 = call i32 @rmdir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %64, i32* %1
%65 = load i32, i32* %1
%66 = icmp eq i32 %65, -1
%67 = zext i1 %66 to i32
%68 = call i32 @assert(i32 %67)
%69 = load i64, i64* @errno
%70 = load i64, i64* @ENOENT
%71 = icmp eq i64 %69, %70
%72 = zext i1 %71 to i32
%73 = call i32 @assert(i32 %72)
%74 = call i32 @rmdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
store i32 %74, i32* %1
%75 = load i32, i32* %1
%76 = icmp eq i32 %75, -1
%77 = zext i1 %76 to i32
%78 = call i32 @assert(i32 %77)
%79 = load i64, i64* @errno
%80 = load i64, i64* @ENOTDIR
%81 = icmp eq i64 %79, %80
%82 = zext i1 %81 to i32
%83 = call i32 @assert(i32 %82)
%84 = call i32 @rmdir(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
store i32 %84, i32* %1
%85 = load i32, i32* %1
%86 = icmp eq i32 %85, -1
%87 = zext i1 %86 to i32
%88 = call i32 @assert(i32 %87)
%89 = load i64, i64* @errno
%90 = load i64, i64* @EACCES
%91 = icmp eq i64 %89, %90
%92 = zext i1 %91 to i32
%93 = call i32 @assert(i32 %92)
%94 = call i32 @rmdir(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
store i32 %94, i32* %1
%95 = load i32, i32* %1
%96 = icmp eq i32 %95, -1
%97 = zext i1 %96 to i32
%98 = call i32 @assert(i32 %97)
%99 = load i64, i64* @errno
%100 = load i64, i64* @ENOTEMPTY
%101 = icmp eq i64 %99, %100
%102 = zext i1 %101 to i32
%103 = call i32 @assert(i32 %102)
%104 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%105 = call i32 @getcwd(i8* %104, i32 512)
%106 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%107 = call i32 @rmdir(i8* %106)
store i32 %107, i32* %1
%108 = load i32, i32* %1
%109 = icmp eq i32 %108, -1
%110 = zext i1 %109 to i32
%111 = call i32 @assert(i32 %110)
%112 = load i64, i64* @errno
%113 = load i64, i64* @EBUSY
%114 = icmp eq i64 %112, %113
%115 = zext i1 %114 to i32
%116 = call i32 @assert(i32 %115)
%117 = call i32 @rmdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32 %117, i32* %1
%118 = load i32, i32* %1
%119 = icmp eq i32 %118, -1
%120 = zext i1 %119 to i32
%121 = call i32 @assert(i32 %120)
%122 = load i64, i64* @errno
%123 = load i64, i64* @EBUSY
%124 = icmp eq i64 %122, %123
%125 = zext i1 %124 to i32
%126 = call i32 @assert(i32 %125)
%127 = call i32 @rmdir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
store i32 %127, i32* %1
%128 = load i32, i32* %1
%129 = icmp eq i32 %128, -1
%130 = zext i1 %129 to i32
%131 = call i32 @assert(i32 %130)
%132 = load i64, i64* @errno
%133 = load i64, i64* @ENOTDIR
%134 = icmp eq i64 %132, %133
%135 = zext i1 %134 to i32
%136 = call i32 @assert(i32 %135)
%137 = call i32 @rmdir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
store i32 %137, i32* %1
%138 = load i32, i32* %1
%139 = icmp ne i32 %138, 0
%140 = xor i1 %139, true
%141 = zext i1 %140 to i32
%142 = call i32 @assert(i32 %141)
%143 = load i32, i32* @F_OK
%144 = call i32 @access(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %143)
store i32 %144, i32* %1
%145 = load i32, i32* %1
%146 = icmp eq i32 %145, -1
%147 = zext i1 %146 to i32
%148 = call i32 @assert(i32 %147)
%149 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"noexist\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [13 x i8] c"dir-readonly\00"
@EISDIR = global i64 0
@.str.2 = [25 x i8] c"dir-readonly/anotherfile\00"
@EACCES = global i64 0
@.str.3 = [11 x i8] c"file1-link\00"
@.str.4 = [6 x i8] c"file1\00"
@F_OK = global i32 0
@.str.5 = [5 x i8] c"file\00"
@ENOTDIR = global i64 0
@.str.6 = [24 x i8] c"dir-readonly/anotherdir\00"
@.str.7 = [9 x i8] c"dir-full\00"
@ENOTEMPTY = global i64 0
@EBUSY = global i64 0
@.str.8 = [2 x i8] c"/\00"
@.str.9 = [15 x i8] c"dir-empty-link\00"
@.str.10 = [10 x i8] c"dir-empty\00"
@.str.11 = [8 x i8] c"success\00"
define void @test() {
%1 = alloca [512 x i8]
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, -1
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = load i64, i64* @errno
%8 = load i64, i64* @ENOENT
%9 = icmp eq i64 %7, %8
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = tail call i32 @unlink(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32 %12, -1
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = load i64, i64* @errno
%17 = load i64, i64* @EISDIR
%18 = icmp eq i64 %16, %17
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i32 @unlink(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32 %21, -1
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = load i64, i64* @errno
%26 = load i64, i64* @EACCES
%27 = icmp eq i64 %25, %26
%28 = zext i1 %27 to i32
%29 = tail call i32 @assert(i32 %28)
%30 = tail call i32 @unlink(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i32 %30, 0
%32 = zext i1 %31 to i32
%33 = tail call i32 @assert(i32 %32)
%34 = load i32, i32* @F_OK
%35 = tail call i32 @access(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%36 = icmp eq i32 %35, 0
%37 = zext i1 %36 to i32
%38 = tail call i32 @assert(i32 %37)
%39 = load i32, i32* @F_OK
%40 = tail call i32 @access(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = icmp eq i32 %40, -1
%42 = zext i1 %41 to i32
%43 = tail call i32 @assert(i32 %42)
%44 = tail call i32 @unlink(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%45 = icmp eq i32 %44, 0
%46 = zext i1 %45 to i32
%47 = tail call i32 @assert(i32 %46)
%48 = load i32, i32* @F_OK
%49 = tail call i32 @access(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %48)
%50 = icmp eq i32 %49, -1
%51 = zext i1 %50 to i32
%52 = tail call i32 @assert(i32 %51)
%53 = tail call i32 @rmdir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%54 = icmp eq i32 %53, -1
%55 = zext i1 %54 to i32
%56 = tail call i32 @assert(i32 %55)
%57 = load i64, i64* @errno
%58 = load i64, i64* @ENOENT
%59 = icmp eq i64 %57, %58
%60 = zext i1 %59 to i32
%61 = tail call i32 @assert(i32 %60)
%62 = tail call i32 @rmdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%63 = icmp eq i32 %62, -1
%64 = zext i1 %63 to i32
%65 = tail call i32 @assert(i32 %64)
%66 = load i64, i64* @errno
%67 = load i64, i64* @ENOTDIR
%68 = icmp eq i64 %66, %67
%69 = zext i1 %68 to i32
%70 = tail call i32 @assert(i32 %69)
%71 = tail call i32 @rmdir(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%72 = icmp eq i32 %71, -1
%73 = zext i1 %72 to i32
%74 = tail call i32 @assert(i32 %73)
%75 = load i64, i64* @errno
%76 = load i64, i64* @EACCES
%77 = icmp eq i64 %75, %76
%78 = zext i1 %77 to i32
%79 = tail call i32 @assert(i32 %78)
%80 = tail call i32 @rmdir(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%81 = icmp eq i32 %80, -1
%82 = zext i1 %81 to i32
%83 = tail call i32 @assert(i32 %82)
%84 = load i64, i64* @errno
%85 = load i64, i64* @ENOTEMPTY
%86 = icmp eq i64 %84, %85
%87 = zext i1 %86 to i32
%88 = tail call i32 @assert(i32 %87)
%89 = call i32 @getcwd(i8* %2, i32 512)
%90 = call i32 @rmdir(i8* %2)
%91 = icmp eq i32 %90, -1
%92 = zext i1 %91 to i32
%93 = call i32 @assert(i32 %92)
%94 = load i64, i64* @errno
%95 = load i64, i64* @EBUSY
%96 = icmp eq i64 %94, %95
%97 = zext i1 %96 to i32
%98 = call i32 @assert(i32 %97)
%99 = call i32 @rmdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%100 = icmp eq i32 %99, -1
%101 = zext i1 %100 to i32
%102 = call i32 @assert(i32 %101)
%103 = load i64, i64* @errno
%104 = load i64, i64* @EBUSY
%105 = icmp eq i64 %103, %104
%106 = zext i1 %105 to i32
%107 = call i32 @assert(i32 %106)
%108 = call i32 @rmdir(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%109 = icmp eq i32 %108, -1
%110 = zext i1 %109 to i32
%111 = call i32 @assert(i32 %110)
%112 = load i64, i64* @errno
%113 = load i64, i64* @ENOTDIR
%114 = icmp eq i64 %112, %113
%115 = zext i1 %114 to i32
%116 = call i32 @assert(i32 %115)
%117 = call i32 @rmdir(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%118 = icmp eq i32 %117, 0
%119 = zext i1 %118 to i32
%120 = call i32 @assert(i32 %119)
%121 = load i32, i32* @F_OK
%122 = call i32 @access(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0), i32 %121)
%123 = icmp eq i32 %122, -1
%124 = zext i1 %123 to i32
%125 = call i32 @assert(i32 %124)
%126 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
ret void
}