#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__ EEXIST;
int /*<<< orphan*/ assert(int);
scalar_t__ chdir(char *);
scalar_t__ errno;
int mkdir(char *, int /*<<< orphan*/);
scalar_t__ rmdir(char *);
int test_vfs_dot_dot_dir(void) {
  assert(chdir("/tmp") == 0);
  assert(mkdir("test", 0) == 0);
  assert(chdir("test") == 0);
  assert(mkdir("test2///", 0) == 0);
  assert(chdir("test2") == 0);
  assert(chdir("..") == 0);
  assert(chdir("test2") == 0);
  assert(chdir("../test2") == 0);
  assert(chdir("../../") == 0);
  assert(mkdir("test", 0) == -1 && errno == EEXIST);
  assert(chdir("test") == 0);
  assert(rmdir("../test/test2") == 0);
  assert(chdir("./..") == 0);
  assert(rmdir("test") == 0);
  return 0;
}


x86 assembly (clang, -O0):
<test_vfs_dot_dot_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe99(%rip),%rdi
xor    %esi,%esi
call   1030 <mkdir@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe7b(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe63(%rip),%rdi
xor    %esi,%esi
call   1030 <mkdir@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe51(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe51(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe17(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xdf7(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xde3(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xdaf(%rip),%rdi
xor    %esi,%esi
call   1030 <mkdir@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x1(%rbp)
jne    1287 <test_vfs_dot_dot_dir+0x147>
mov    0x2d64(%rip),%rax
mov    (%rax),%rax
mov    0x2d62(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x1(%rbp)
mov    -0x1(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xd6a(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xd6b(%rip),%rdi
call   1040 <rmdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xd5c(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xd13(%rip),%rdi
call   1040 <rmdir@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_vfs_dot_dot_dir>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
call   1050 <chdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
lea    0xea0(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <mkdir@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    %r14,%rdi
call   1050 <chdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
lea    0xe71(%rip),%rdi
xor    %esi,%esi
call   1030 <mkdir@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
lea    0xe62(%rip),%rbx
mov    %rbx,%rdi
call   1050 <chdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
lea    0xe62(%rip),%rdi
call   1050 <chdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1050 <chdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
lea    0xe12(%rip),%rdi
call   1050 <chdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
lea    0xe01(%rip),%rdi
call   1050 <chdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
sete   %al
mov    0x2d93(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2d91(%rip),%rdx
cmp    (%rdx),%rcx
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1060 <assert@plt>
mov    %r14,%rdi
call   1050 <chdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
lea    0xda7(%rip),%rdi
call   1040 <rmdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
lea    0xd9b(%rip),%rdi
call   1050 <chdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    %r14,%rdi
call   1040 <rmdir@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"/tmp\00"
@.str.1 = [5 x i8] c"test\00"
@.str.2 = [9 x i8] c"test2///\00"
@.str.3 = [6 x i8] c"test2\00"
@.str.4 = [3 x i8] c"..\00"
@.str.5 = [9 x i8] c"../test2\00"
@.str.6 = [7 x i8] c"../../\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.7 = [14 x i8] c"../test/test2\00"
@.str.8 = [5 x i8] c"./..\00"
define i32 @test_vfs_dot_dot_dir() {
%1 = call i64 @chdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = call i32 @assert(i32 %3)
%5 = call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 0)
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = call i64 @chdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i32 @mkdir(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 0)
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = call i64 @chdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i64 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = call i64 @chdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = call i64 @chdir(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = call i64 @chdir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 0)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %43
39: ; preds = %0
%40 = load i64, i64* @errno
%41 = load i64, i64* @EEXIST
%42 = icmp eq i64 %40, %41
br label %43
43: ; preds = %39, %0
%44 = phi i1 [ false, %0 ], [ %42, %39 ]
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
%47 = call i64 @chdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = call i64 @rmdir(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = call i64 @chdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
%59 = call i64 @rmdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"/tmp\00"
@.str.1 = [5 x i8] c"test\00"
@.str.2 = [9 x i8] c"test2///\00"
@.str.3 = [6 x i8] c"test2\00"
@.str.4 = [3 x i8] c"..\00"
@.str.5 = [9 x i8] c"../test2\00"
@.str.6 = [7 x i8] c"../../\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.7 = [14 x i8] c"../test/test2\00"
@.str.8 = [5 x i8] c"./..\00"
define i32 @test_vfs_dot_dot_dir() {
%1 = tail call i64 @chdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 0)
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = tail call i64 @chdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i32 @mkdir(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 0)
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = tail call i64 @chdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i64 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = tail call i64 @chdir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
%27 = zext i1 %26 to i32
%28 = tail call i32 @assert(i32 %27)
%29 = tail call i64 @chdir(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
%31 = zext i1 %30 to i32
%32 = tail call i32 @assert(i32 %31)
%33 = tail call i64 @chdir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
%35 = zext i1 %34 to i32
%36 = tail call i32 @assert(i32 %35)
%37 = tail call i32 @mkdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 0)
%38 = icmp eq i32 %37, -1
%39 = load i64, i64* @errno
%40 = load i64, i64* @EEXIST
%41 = icmp eq i64 %39, %40
%42 = select i1 %38, i1 %41, i1 false
%43 = zext i1 %42 to i32
%44 = tail call i32 @assert(i32 %43)
%45 = tail call i64 @chdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
%47 = zext i1 %46 to i32
%48 = tail call i32 @assert(i32 %47)
%49 = tail call i64 @rmdir(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
%51 = zext i1 %50 to i32
%52 = tail call i32 @assert(i32 %51)
%53 = tail call i64 @chdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
%55 = zext i1 %54 to i32
%56 = tail call i32 @assert(i32 %55)
%57 = tail call i64 @rmdir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
%59 = zext i1 %58 to i32
%60 = tail call i32 @assert(i32 %59)
ret i32 0
}