void create_non_empty_nested_dir(const char root_dir[], const char nested_dir[],
                                 const char file[]) {
  create_empty_dir(root_dir);
  do {
    seatest_assert_int_equal(0, chdir(root_dir), __FUNCTION__, 38);
  } while (0);
  {
    create_empty_dir(nested_dir);
    do {
      seatest_assert_int_equal(0, chdir(nested_dir), __FUNCTION__, 42);
    } while (0);
    create_empty_file(file);
    do {
      seatest_assert_int_equal(0, chdir(".."), __FUNCTION__, 44);
    } while (0);
  }
  do {
    seatest_assert_int_equal(0, chdir(".."), __FUNCTION__, 46);
  } while (0);
}


x86 assembly (clang, -O0):
<create_non_empty_nested_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1040 <create_empty_dir@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <chdir@plt>
mov    %eax,%esi
xor    %edi,%edi
lea    0xe8b(%rip),%rdx
mov    $0x26,%ecx
mov    $0x0,%al
call   1050 <seatest_assert_int_equal@plt>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1040 <create_empty_dir@plt>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1030 <chdir@plt>
mov    %eax,%esi
xor    %edi,%edi
lea    0xe5e(%rip),%rdx
mov    $0x2a,%ecx
mov    $0x0,%al
call   1050 <seatest_assert_int_equal@plt>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1060 <create_empty_file@plt>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <chdir@plt>
mov    %eax,%esi
xor    %edi,%edi
lea    0xe2e(%rip),%rdx
mov    $0x2c,%ecx
mov    $0x0,%al
call   1050 <seatest_assert_int_equal@plt>
jmp    11e3 <create_non_empty_nested_dir+0xa3>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <chdir@plt>
mov    %eax,%esi
xor    %edi,%edi
lea    0xe04(%rip),%rdx
mov    $0x2e,%ecx
mov    $0x0,%al
call   1050 <seatest_assert_int_equal@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_non_empty_nested_dir>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <create_empty_dir@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <chdir@plt>
lea    0xe97(%rip),%r15
xor    %edi,%edi
mov    %eax,%esi
mov    %r15,%rdx
mov    $0x26,%ecx
xor    %eax,%eax
call   1050 <seatest_assert_int_equal@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <create_empty_dir@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <chdir@plt>
xor    %edi,%edi
mov    %eax,%esi
mov    %r15,%rdx
mov    $0x2a,%ecx
xor    %eax,%eax
call   1050 <seatest_assert_int_equal@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <create_empty_file@plt>
lea    0xe68(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <chdir@plt>
xor    %edi,%edi
mov    %eax,%esi
mov    %r15,%rdx
mov    $0x2c,%ecx
xor    %eax,%eax
call   1050 <seatest_assert_int_equal@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <chdir@plt>
xor    %edi,%edi
mov    %eax,%esi
mov    %r15,%rdx
mov    $0x2e,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <seatest_assert_int_equal@plt>

LLVM IR (-O0):
@__FUNCTION__.create_non_empty_nested_dir = [28 x i8] c"create_non_empty_nested_dir\00"
@.str = [3 x i8] c"..\00"
define void @create_non_empty_nested_dir(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %4
%8 = call i32 (i8*, ...) bitcast (i32 (...)* @create_empty_dir to i32 (i8*, ...)*)(i8* %7)
br label %9
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @chdir to i32 (i8*, ...)*)(i8* %10)
%12 = call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__FUNCTION__.create_non_empty_nested_dir, i64 0, i64 0), i32 38)
br label %13
13: ; preds = %9
%14 = load i8*, i8** %5
%15 = call i32 (i8*, ...) bitcast (i32 (...)* @create_empty_dir to i32 (i8*, ...)*)(i8* %14)
br label %16
16: ; preds = %13
%17 = load i8*, i8** %5
%18 = call i32 (i8*, ...) bitcast (i32 (...)* @chdir to i32 (i8*, ...)*)(i8* %17)
%19 = call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %18, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__FUNCTION__.create_non_empty_nested_dir, i64 0, i64 0), i32 42)
br label %20
20: ; preds = %16
%21 = load i8*, i8** %6
%22 = call i32 (i8*, ...) bitcast (i32 (...)* @create_empty_file to i32 (i8*, ...)*)(i8* %21)
br label %23
23: ; preds = %20
%24 = call i32 (i8*, ...) bitcast (i32 (...)* @chdir to i32 (i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%25 = call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %24, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__FUNCTION__.create_non_empty_nested_dir, i64 0, i64 0), i32 44)
br label %26
26: ; preds = %23
br label %27
27: ; preds = %26
%28 = call i32 (i8*, ...) bitcast (i32 (...)* @chdir to i32 (i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%29 = call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %28, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__FUNCTION__.create_non_empty_nested_dir, i64 0, i64 0), i32 46)
br label %30
30: ; preds = %27
ret void
}

LLVM IR (-O2):
@__FUNCTION__.create_non_empty_nested_dir = [28 x i8] c"create_non_empty_nested_dir\00"
@.str = [3 x i8] c"..\00"
define void @create_non_empty_nested_dir(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @create_empty_dir to i32 (i8*, ...)*)(i8* %0)
%5 = tail call i32 (i8*, ...) bitcast (i32 (...)* @chdir to i32 (i8*, ...)*)(i8* %0)
%6 = tail call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %5, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__FUNCTION__.create_non_empty_nested_dir, i64 0, i64 0), i32 38)
%7 = tail call i32 (i8*, ...) bitcast (i32 (...)* @create_empty_dir to i32 (i8*, ...)*)(i8* %1)
%8 = tail call i32 (i8*, ...) bitcast (i32 (...)* @chdir to i32 (i8*, ...)*)(i8* %1)
%9 = tail call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %8, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__FUNCTION__.create_non_empty_nested_dir, i64 0, i64 0), i32 42)
%10 = tail call i32 (i8*, ...) bitcast (i32 (...)* @create_empty_file to i32 (i8*, ...)*)(i8* %2)
%11 = tail call i32 (i8*, ...) bitcast (i32 (...)* @chdir to i32 (i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__FUNCTION__.create_non_empty_nested_dir, i64 0, i64 0), i32 44)
%13 = tail call i32 (i8*, ...) bitcast (i32 (...)* @chdir to i32 (i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__FUNCTION__.create_non_empty_nested_dir, i64 0, i64 0), i32 46)
ret void
}