void filesys_test_connect_directory() {
  struct filesystem *fs = (void *)0X0;
  struct directory *dir;
  if (!(dir = filesys_open_directory(fs, "/a/b/c/d", 1))) {
    printf("failed to create directory\n");
    abort();
  }
  filesys_connect_directory(fs, "a/b/c/d");
  printf("dir: %s\n", filesys_working_directory(fs));
  assert(!strcmp("/a/b/c/d", filesys_working_directory(fs)));
  filesys_connect_directory(fs, ".");
  printf("dir: %s\n", filesys_working_directory(fs));
  assert(!strcmp("/a/b/c/d", filesys_working_directory(fs)));
  filesys_connect_directory(fs, "..");
  printf("dir: %s\n", filesys_working_directory(fs));
  assert(!strcmp("/a/b/c", filesys_working_directory(fs)));
  filesys_connect_directory(fs, "./");
  printf("dir: %s\n", filesys_working_directory(fs));
  assert(!strcmp("/a/b/c", filesys_working_directory(fs)));
  filesys_connect_directory(fs, "../");
  printf("dir: %s\n", filesys_working_directory(fs));
  assert(!strcmp("/a/b", filesys_working_directory(fs)));
  filesys_open_directory(fs, "/a/e/f", 1);
  filesys_connect_directory(fs, "../e/g/../f");
  printf("dir: %s\n", filesys_working_directory(fs));
  assert(!strcmp("/a/e/f", filesys_working_directory(fs)));
  filesys_open_directory(fs, "/a/e/f/k", 1);
  filesys_connect_directory(fs, "k/");
  printf("dir: %s\n", filesys_working_directory(fs));
  assert(!strcmp("/a/e/f/k", filesys_working_directory(fs)));
  filesys_connect_directory(fs, "../../../../../");
  printf("dir: %s\n", filesys_working_directory(fs));
  assert(!strcmp("/", filesys_working_directory(fs)));
  filesys_connect_directory(fs, "/a/e/f/k");
  filesys_connect_directory(fs, "../");
  printf("dir: %s\n", filesys_working_directory(fs));
  assert(!strcmp("/a/e/f", filesys_working_directory(fs)));
  struct directory *dir2 = filesys_open_directory(fs, "/a", 0);
  filesys_remove_directory(fs, dir2);
  filesys_open_directory(fs, "/1/2/3/4/5/6/", 1);
  filesys_connect_directory(fs, "/1/2/3/4/5/6");
  printf("dir: %s\n", filesys_working_directory(fs));
  assert(!strcmp("/1/2/3/4/5/6", filesys_working_directory(fs)));
  filesys_connect_directory(fs, "/");
  struct file *f = filesys_open_file(fs, "data/debussy-logo.png", 0);
  assert(f);
  unsigned char buf[100];
  assert(100 == file_read(f, 100, buf));
  filesys_free(fs), free(fs);
}


x86 assembly (clang, -O0):
<filesys_test_connect_directory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe22(%rip),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   10c0 <filesys_open_directory@plt>
cltq
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    120d <filesys_test_connect_directory+0x4d>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
call   1040 <abort@plt>
mov    -0x8(%rbp),%rdi
lea    0xde9(%rip),%rsi
mov    $0x0,%al
call   1050 <filesys_connect_directory@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
mov    %eax,%esi
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
lea    0xdb1(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   10b0 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xdbc(%rip),%rsi
mov    $0x0,%al
call   1050 <filesys_connect_directory@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
mov    %eax,%esi
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
lea    0xd56(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   10b0 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xd60(%rip),%rsi
mov    $0x0,%al
call   1050 <filesys_connect_directory@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
mov    %eax,%esi
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
lea    0xd2c(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   10b0 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xd40(%rip),%rsi
mov    $0x0,%al
call   1050 <filesys_connect_directory@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
mov    %eax,%esi
lea    0xce1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
lea    0xcd1(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   10b0 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xce4(%rip),%rsi
mov    $0x0,%al
call   1050 <filesys_connect_directory@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
mov    %eax,%esi
lea    0xc86(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
lea    0xc7d(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   10b0 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xc5e(%rip),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   10c0 <filesys_open_directory@plt>
mov    -0x8(%rbp),%rdi
lea    0xc4e(%rip),%rsi
mov    $0x0,%al
call   1050 <filesys_connect_directory@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
mov    %eax,%esi
lea    0xc14(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
lea    0xc10(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   10b0 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xbff(%rip),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   10c0 <filesys_open_directory@plt>
mov    -0x8(%rbp),%rdi
lea    0xbf1(%rip),%rsi
mov    $0x0,%al
call   1050 <filesys_connect_directory@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
mov    %eax,%esi
lea    0xba2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
lea    0xbb1(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   10b0 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xb99(%rip),%rsi
mov    $0x0,%al
call   1050 <filesys_connect_directory@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
mov    %eax,%esi
lea    0xb47(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
lea    0xb70(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   10b0 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xb32(%rip),%rsi
mov    $0x0,%al
call   1050 <filesys_connect_directory@plt>
mov    -0x8(%rbp),%rdi
lea    0xb38(%rip),%rsi
mov    $0x0,%al
call   1050 <filesys_connect_directory@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
mov    %eax,%esi
lea    0xada(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
lea    0xad6(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   10b0 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xae1(%rip),%rsi
xor    %edx,%edx
mov    $0x0,%al
call   10c0 <filesys_open_directory@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1070 <filesys_remove_directory@plt>
mov    -0x8(%rbp),%rdi
lea    0xabb(%rip),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   10c0 <filesys_open_directory@plt>
mov    -0x8(%rbp),%rdi
lea    0xab2(%rip),%rsi
mov    $0x0,%al
call   1050 <filesys_connect_directory@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
mov    %eax,%esi
lea    0xa3f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
lea    0xa7b(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   10b0 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xa44(%rip),%rsi
mov    $0x0,%al
call   1050 <filesys_connect_directory@plt>
mov    -0x8(%rbp),%rdi
lea    0xa52(%rip),%rsi
xor    %edx,%edx
mov    $0x0,%al
call   10a0 <filesys_open_file@plt>
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   10b0 <assert@plt>
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rdx
mov    $0x64,%esi
mov    $0x0,%al
call   10d0 <file_read@plt>
mov    %eax,%ecx
mov    $0x64,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   10b0 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   10e0 <filesys_free@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filesys_test_connect_directory>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x70,%rsp
lea    0xe2c(%rip),%rsi
xor    %edi,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   10c0 <filesys_open_directory@plt>
test   %eax,%eax
je     15af <filesys_test_connect_directory+0x3ef>
lea    0xe10(%rip),%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1050 <filesys_connect_directory@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
lea    0xdff(%rip),%r13
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
lea    0xdd7(%rip),%rbx
mov    %rbx,%rdi
call   1090 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   10b0 <assert@plt>
lea    0xdcc(%rip),%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1050 <filesys_connect_directory@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
mov    %rbx,%rdi
call   1090 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   10b0 <assert@plt>
lea    0xd83(%rip),%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1050 <filesys_connect_directory@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
lea    0xd55(%rip),%rbx
mov    %rbx,%rdi
call   1090 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   10b0 <assert@plt>
lea    0xd6f(%rip),%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1050 <filesys_connect_directory@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
mov    %rbx,%rdi
call   1090 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   10b0 <assert@plt>
lea    0xd26(%rip),%r14
xor    %edi,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <filesys_connect_directory@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
lea    0xcc2(%rip),%rdi
call   1090 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   10b0 <assert@plt>
lea    0xcac(%rip),%r15
xor    %edi,%edi
mov    %r15,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   10c0 <filesys_open_directory@plt>
lea    0xc9b(%rip),%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1050 <filesys_connect_directory@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
mov    %r15,%rdi
call   1090 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   10b0 <assert@plt>
lea    0xc5f(%rip),%rbx
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   10c0 <filesys_open_directory@plt>
lea    0xc50(%rip),%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1050 <filesys_connect_directory@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
mov    %rbx,%rdi
call   1090 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   10b0 <assert@plt>
lea    0xc0b(%rip),%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1050 <filesys_connect_directory@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
lea    0xbe8(%rip),%r12
mov    %r12,%rdi
call   1090 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   10b0 <assert@plt>
xor    %edi,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <filesys_connect_directory@plt>
xor    %edi,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <filesys_connect_directory@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
mov    %r15,%rdi
call   1090 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   10b0 <assert@plt>
lea    0xb7c(%rip),%rsi
xor    %edi,%edi
xor    %edx,%edx
xor    %eax,%eax
call   10c0 <filesys_open_directory@plt>
movslq %eax,%rsi
xor    %edi,%edi
xor    %eax,%eax
call   1070 <filesys_remove_directory@plt>
lea    0xb61(%rip),%rsi
xor    %edi,%edi
mov    $0x1,%edx
xor    %eax,%eax
call   10c0 <filesys_open_directory@plt>
lea    0xb5a(%rip),%rbx
xor    %edi,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <filesys_connect_directory@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <filesys_working_directory@plt>
movslq %eax,%rsi
mov    %rbx,%rdi
call   1090 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
xor    %eax,%eax
call   10b0 <assert@plt>
xor    %edi,%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <filesys_connect_directory@plt>
lea    0xb10(%rip),%rsi
xor    %edi,%edi
xor    %edx,%edx
xor    %eax,%eax
call   10a0 <filesys_open_file@plt>
movslq %eax,%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   10b0 <assert@plt>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   10d0 <file_read@plt>
xor    %edi,%edi
cmp    $0x64,%eax
sete   %dil
xor    %eax,%eax
call   10b0 <assert@plt>
xor    %edi,%edi
xor    %eax,%eax
call   10e0 <filesys_free@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xace(%rip),%rdi
call   1040 <puts@plt>
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.filesystem = type opaque
%struct.directory = type opaque
%struct.file = type opaque
@.str = [9 x i8] c"/a/b/c/d\00"
@.str.1 = [28 x i8] c"failed to create directory\0A\00"
@.str.2 = [8 x i8] c"a/b/c/d\00"
@.str.3 = [9 x i8] c"dir: %s\0A\00"
@.str.4 = [2 x i8] c".\00"
@.str.5 = [3 x i8] c"..\00"
@.str.6 = [7 x i8] c"/a/b/c\00"
@.str.7 = [3 x i8] c"./\00"
@.str.8 = [4 x i8] c"../\00"
@.str.9 = [5 x i8] c"/a/b\00"
@.str.10 = [7 x i8] c"/a/e/f\00"
@.str.11 = [12 x i8] c"../e/g/../f\00"
@.str.12 = [9 x i8] c"/a/e/f/k\00"
@.str.13 = [3 x i8] c"k/\00"
@.str.14 = [16 x i8] c"../../../../../\00"
@.str.15 = [2 x i8] c"/\00"
@.str.16 = [3 x i8] c"/a\00"
@.str.17 = [14 x i8] c"/1/2/3/4/5/6/\00"
@.str.18 = [13 x i8] c"/1/2/3/4/5/6\00"
@.str.19 = [22 x i8] c"data/debussy-logo.png\00"
define void @filesys_test_connect_directory() {
%1 = alloca %struct.filesystem*
%2 = alloca %struct.directory*
%3 = alloca %struct.directory*
%4 = alloca %struct.file*
%5 = alloca [100 x i8]
store %struct.filesystem* null, %struct.filesystem** %1
%6 = load %struct.filesystem*, %struct.filesystem** %1
%7 = call i32 (%struct.filesystem*, i8*, i32, ...) bitcast (i32 (...)* @filesys_open_directory to i32 (%struct.filesystem*, i8*, i32, ...)*)(%struct.filesystem* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1)
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to %struct.directory*
store %struct.directory* %9, %struct.directory** %2
%10 = icmp ne %struct.directory* %9, null
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
unreachable
13: ; preds = %0
%14 = load %struct.filesystem*, %struct.filesystem** %1
%15 = call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%16 = load %struct.filesystem*, %struct.filesystem** %1
%17 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = load %struct.filesystem*, %struct.filesystem** %1
%20 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %19)
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i8*
%23 = call i32 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
%26 = zext i1 %25 to i32
%27 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %26)
%28 = load %struct.filesystem*, %struct.filesystem** %1
%29 = call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%30 = load %struct.filesystem*, %struct.filesystem** %1
%31 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%33 = load %struct.filesystem*, %struct.filesystem** %1
%34 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %33)
%35 = sext i32 %34 to i64
%36 = inttoptr i64 %35 to i8*
%37 = call i32 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %36)
%38 = icmp ne i32 %37, 0
%39 = xor i1 %38, true
%40 = zext i1 %39 to i32
%41 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %40)
%42 = load %struct.filesystem*, %struct.filesystem** %1
%43 = call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%44 = load %struct.filesystem*, %struct.filesystem** %1
%45 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%47 = load %struct.filesystem*, %struct.filesystem** %1
%48 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %47)
%49 = sext i32 %48 to i64
%50 = inttoptr i64 %49 to i8*
%51 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %50)
%52 = icmp ne i32 %51, 0
%53 = xor i1 %52, true
%54 = zext i1 %53 to i32
%55 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %54)
%56 = load %struct.filesystem*, %struct.filesystem** %1
%57 = call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%58 = load %struct.filesystem*, %struct.filesystem** %1
%59 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %58)
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %59)
%61 = load %struct.filesystem*, %struct.filesystem** %1
%62 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %61)
%63 = sext i32 %62 to i64
%64 = inttoptr i64 %63 to i8*
%65 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %64)
%66 = icmp ne i32 %65, 0
%67 = xor i1 %66, true
%68 = zext i1 %67 to i32
%69 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %68)
%70 = load %struct.filesystem*, %struct.filesystem** %1
%71 = call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* %70, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%72 = load %struct.filesystem*, %struct.filesystem** %1
%73 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %72)
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %73)
%75 = load %struct.filesystem*, %struct.filesystem** %1
%76 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %75)
%77 = sext i32 %76 to i64
%78 = inttoptr i64 %77 to i8*
%79 = call i32 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %78)
%80 = icmp ne i32 %79, 0
%81 = xor i1 %80, true
%82 = zext i1 %81 to i32
%83 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %82)
%84 = load %struct.filesystem*, %struct.filesystem** %1
%85 = call i32 (%struct.filesystem*, i8*, i32, ...) bitcast (i32 (...)* @filesys_open_directory to i32 (%struct.filesystem*, i8*, i32, ...)*)(%struct.filesystem* %84, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 1)
%86 = load %struct.filesystem*, %struct.filesystem** %1
%87 = call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* %86, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%88 = load %struct.filesystem*, %struct.filesystem** %1
%89 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %88)
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %89)
%91 = load %struct.filesystem*, %struct.filesystem** %1
%92 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %91)
%93 = sext i32 %92 to i64
%94 = inttoptr i64 %93 to i8*
%95 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* %94)
%96 = icmp ne i32 %95, 0
%97 = xor i1 %96, true
%98 = zext i1 %97 to i32
%99 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %98)
%100 = load %struct.filesystem*, %struct.filesystem** %1
%101 = call i32 (%struct.filesystem*, i8*, i32, ...) bitcast (i32 (...)* @filesys_open_directory to i32 (%struct.filesystem*, i8*, i32, ...)*)(%struct.filesystem* %100, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 1)
%102 = load %struct.filesystem*, %struct.filesystem** %1
%103 = call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* %102, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%104 = load %struct.filesystem*, %struct.filesystem** %1
%105 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %104)
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %105)
%107 = load %struct.filesystem*, %struct.filesystem** %1
%108 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %107)
%109 = sext i32 %108 to i64
%110 = inttoptr i64 %109 to i8*
%111 = call i32 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i8* %110)
%112 = icmp ne i32 %111, 0
%113 = xor i1 %112, true
%114 = zext i1 %113 to i32
%115 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %114)
%116 = load %struct.filesystem*, %struct.filesystem** %1
%117 = call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* %116, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0))
%118 = load %struct.filesystem*, %struct.filesystem** %1
%119 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %118)
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %119)
%121 = load %struct.filesystem*, %struct.filesystem** %1
%122 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %121)
%123 = sext i32 %122 to i64
%124 = inttoptr i64 %123 to i8*
%125 = call i32 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0), i8* %124)
%126 = icmp ne i32 %125, 0
%127 = xor i1 %126, true
%128 = zext i1 %127 to i32
%129 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %128)
%130 = load %struct.filesystem*, %struct.filesystem** %1
%131 = call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* %130, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
%132 = load %struct.filesystem*, %struct.filesystem** %1
%133 = call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* %132, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%134 = load %struct.filesystem*, %struct.filesystem** %1
%135 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %134)
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %135)
%137 = load %struct.filesystem*, %struct.filesystem** %1
%138 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %137)
%139 = sext i32 %138 to i64
%140 = inttoptr i64 %139 to i8*
%141 = call i32 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* %140)
%142 = icmp ne i32 %141, 0
%143 = xor i1 %142, true
%144 = zext i1 %143 to i32
%145 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %144)
%146 = load %struct.filesystem*, %struct.filesystem** %1
%147 = call i32 (%struct.filesystem*, i8*, i32, ...) bitcast (i32 (...)* @filesys_open_directory to i32 (%struct.filesystem*, i8*, i32, ...)*)(%struct.filesystem* %146, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32 0)
%148 = sext i32 %147 to i64
%149 = inttoptr i64 %148 to %struct.directory*
store %struct.directory* %149, %struct.directory** %3
%150 = load %struct.filesystem*, %struct.filesystem** %1
%151 = load %struct.directory*, %struct.directory** %3
%152 = call i32 (%struct.filesystem*, %struct.directory*, ...) bitcast (i32 (...)* @filesys_remove_directory to i32 (%struct.filesystem*, %struct.directory*, ...)*)(%struct.filesystem* %150, %struct.directory* %151)
%153 = load %struct.filesystem*, %struct.filesystem** %1
%154 = call i32 (%struct.filesystem*, i8*, i32, ...) bitcast (i32 (...)* @filesys_open_directory to i32 (%struct.filesystem*, i8*, i32, ...)*)(%struct.filesystem* %153, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), i32 1)
%155 = load %struct.filesystem*, %struct.filesystem** %1
%156 = call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* %155, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i64 0, i64 0))
%157 = load %struct.filesystem*, %struct.filesystem** %1
%158 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %157)
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %158)
%160 = load %struct.filesystem*, %struct.filesystem** %1
%161 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %160)
%162 = sext i32 %161 to i64
%163 = inttoptr i64 %162 to i8*
%164 = call i32 @strcmp(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i64 0, i64 0), i8* %163)
%165 = icmp ne i32 %164, 0
%166 = xor i1 %165, true
%167 = zext i1 %166 to i32
%168 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %167)
%169 = load %struct.filesystem*, %struct.filesystem** %1
%170 = call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* %169, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%171 = load %struct.filesystem*, %struct.filesystem** %1
%172 = call i32 (%struct.filesystem*, i8*, i32, ...) bitcast (i32 (...)* @filesys_open_file to i32 (%struct.filesystem*, i8*, i32, ...)*)(%struct.filesystem* %171, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.19, i64 0, i64 0), i32 0)
%173 = sext i32 %172 to i64
%174 = inttoptr i64 %173 to %struct.file*
store %struct.file* %174, %struct.file** %4
%175 = load %struct.file*, %struct.file** %4
%176 = call i32 (%struct.file*, ...) bitcast (i32 (...)* @assert to i32 (%struct.file*, ...)*)(%struct.file* %175)
%177 = load %struct.file*, %struct.file** %4
%178 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%179 = call i32 (%struct.file*, i32, i8*, ...) bitcast (i32 (...)* @file_read to i32 (%struct.file*, i32, i8*, ...)*)(%struct.file* %177, i32 100, i8* %178)
%180 = icmp eq i32 100, %179
%181 = zext i1 %180 to i32
%182 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %181)
%183 = load %struct.filesystem*, %struct.filesystem** %1
%184 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_free to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* %183)
%185 = load %struct.filesystem*, %struct.filesystem** %1
%186 = bitcast %struct.filesystem* %185 to i8*
ret void
}

LLVM IR (-O2):
%struct.filesystem = type opaque
%struct.directory = type opaque
%struct.file = type opaque
@.str = [9 x i8] c"/a/b/c/d\00"
@.str.2 = [8 x i8] c"a/b/c/d\00"
@.str.3 = [9 x i8] c"dir: %s\0A\00"
@.str.4 = [2 x i8] c".\00"
@.str.5 = [3 x i8] c"..\00"
@.str.6 = [7 x i8] c"/a/b/c\00"
@.str.7 = [3 x i8] c"./\00"
@.str.8 = [4 x i8] c"../\00"
@.str.9 = [5 x i8] c"/a/b\00"
@.str.10 = [7 x i8] c"/a/e/f\00"
@.str.11 = [12 x i8] c"../e/g/../f\00"
@.str.12 = [9 x i8] c"/a/e/f/k\00"
@.str.13 = [3 x i8] c"k/\00"
@.str.14 = [16 x i8] c"../../../../../\00"
@.str.15 = [2 x i8] c"/\00"
@.str.16 = [3 x i8] c"/a\00"
@.str.17 = [14 x i8] c"/1/2/3/4/5/6/\00"
@.str.18 = [13 x i8] c"/1/2/3/4/5/6\00"
@.str.19 = [22 x i8] c"data/debussy-logo.png\00"
@str = [27 x i8] c"failed to create directory\00"
define void @filesys_test_connect_directory() {
%1 = alloca [100 x i8]
%2 = tail call i32 (%struct.filesystem*, i8*, i32, ...) bitcast (i32 (...)* @filesys_open_directory to i32 (%struct.filesystem*, i8*, i32, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
tail call void @abort()
unreachable
6: ; preds = %0
%7 = tail call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%10 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i8*
%13 = tail call i32 @strcmp(i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %12)
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
%16 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %15)
%17 = tail call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%18 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i8*
%23 = tail call i32 @strcmp(i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %22)
%24 = icmp eq i32 %23, 0
%25 = zext i1 %24 to i32
%26 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %25)
%27 = tail call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%28 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i8*
%33 = tail call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* dereferenceable(1) %32)
%34 = icmp eq i32 %33, 0
%35 = zext i1 %34 to i32
%36 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %35)
%37 = tail call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%38 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%41 = sext i32 %40 to i64
%42 = inttoptr i64 %41 to i8*
%43 = tail call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* dereferenceable(1) %42)
%44 = icmp eq i32 %43, 0
%45 = zext i1 %44 to i32
%46 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %45)
%47 = tail call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%48 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%51 = sext i32 %50 to i64
%52 = inttoptr i64 %51 to i8*
%53 = tail call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* dereferenceable(1) %52)
%54 = icmp eq i32 %53, 0
%55 = zext i1 %54 to i32
%56 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %55)
%57 = tail call i32 (%struct.filesystem*, i8*, i32, ...) bitcast (i32 (...)* @filesys_open_directory to i32 (%struct.filesystem*, i8*, i32, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i32 1)
%58 = tail call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%59 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %59)
%61 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%62 = sext i32 %61 to i64
%63 = inttoptr i64 %62 to i8*
%64 = tail call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* dereferenceable(1) %63)
%65 = icmp eq i32 %64, 0
%66 = zext i1 %65 to i32
%67 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %66)
%68 = tail call i32 (%struct.filesystem*, i8*, i32, ...) bitcast (i32 (...)* @filesys_open_directory to i32 (%struct.filesystem*, i8*, i32, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i32 1)
%69 = tail call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%70 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %70)
%72 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%73 = sext i32 %72 to i64
%74 = inttoptr i64 %73 to i8*
%75 = tail call i32 @strcmp(i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0), i8* dereferenceable(1) %74)
%76 = icmp eq i32 %75, 0
%77 = zext i1 %76 to i32
%78 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %77)
%79 = tail call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0))
%80 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %80)
%82 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%83 = sext i32 %82 to i64
%84 = inttoptr i64 %83 to i8*
%85 = tail call i32 @strcmp(i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0), i8* dereferenceable(1) %84)
%86 = icmp eq i32 %85, 0
%87 = zext i1 %86 to i32
%88 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %87)
%89 = tail call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
%90 = tail call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%91 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%92 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %91)
%93 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%94 = sext i32 %93 to i64
%95 = inttoptr i64 %94 to i8*
%96 = tail call i32 @strcmp(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* dereferenceable(1) %95)
%97 = icmp eq i32 %96, 0
%98 = zext i1 %97 to i32
%99 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %98)
%100 = tail call i32 (%struct.filesystem*, i8*, i32, ...) bitcast (i32 (...)* @filesys_open_directory to i32 (%struct.filesystem*, i8*, i32, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i32 0)
%101 = sext i32 %100 to i64
%102 = inttoptr i64 %101 to %struct.directory*
%103 = tail call i32 (%struct.filesystem*, %struct.directory*, ...) bitcast (i32 (...)* @filesys_remove_directory to i32 (%struct.filesystem*, %struct.directory*, ...)*)(%struct.filesystem* null, %struct.directory* %102)
%104 = tail call i32 (%struct.filesystem*, i8*, i32, ...) bitcast (i32 (...)* @filesys_open_directory to i32 (%struct.filesystem*, i8*, i32, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), i32 1)
%105 = tail call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i64 0, i64 0))
%106 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%107 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %106)
%108 = tail call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_working_directory to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
%109 = sext i32 %108 to i64
%110 = inttoptr i64 %109 to i8*
%111 = tail call i32 @strcmp(i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i64 0, i64 0), i8* dereferenceable(1) %110)
%112 = icmp eq i32 %111, 0
%113 = zext i1 %112 to i32
%114 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %113)
%115 = tail call i32 (%struct.filesystem*, i8*, ...) bitcast (i32 (...)* @filesys_connect_directory to i32 (%struct.filesystem*, i8*, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%116 = tail call i32 (%struct.filesystem*, i8*, i32, ...) bitcast (i32 (...)* @filesys_open_file to i32 (%struct.filesystem*, i8*, i32, ...)*)(%struct.filesystem* null, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.19, i64 0, i64 0), i32 0)
%117 = sext i32 %116 to i64
%118 = inttoptr i64 %117 to %struct.file*
%119 = tail call i32 (%struct.file*, ...) bitcast (i32 (...)* @assert to i32 (%struct.file*, ...)*)(%struct.file* %118)
%120 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%121 = call i32 (%struct.file*, i32, i8*, ...) bitcast (i32 (...)* @file_read to i32 (%struct.file*, i32, i8*, ...)*)(%struct.file* %118, i32 100, i8* %120)
%122 = icmp eq i32 %121, 100
%123 = zext i1 %122 to i32
%124 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %123)
%125 = call i32 (%struct.filesystem*, ...) bitcast (i32 (...)* @filesys_free to i32 (%struct.filesystem*, ...)*)(%struct.filesystem* null)
ret void
}