void tests() {
  int floors = 2;
  char **actual = towerBuilder(floors);
  int i;
  for (i = 0; i < floors; ++i)
    printf("%s\n", actual[i]);
  floors = 3;
  printf("\n");
  actual = towerBuilder(floors);
  for (i = 0; i < floors; ++i)
    printf("%s\n", actual[i]);
  for (i = 0; i < floors; ++i)
    free(actual[i]);
  free(actual);
}


x86 assembly (clang, -O0):
<tests>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1050 <towerBuilder@plt>
cltq
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    118a <tests+0x5a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <tests+0x26>
movl   $0x3,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1050 <towerBuilder@plt>
cltq
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ea <tests+0xba>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b6 <tests+0x86>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    121c <tests+0xec>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f1 <tests+0xc1>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tests>:
push   %rbx
mov    $0x2,%edi
xor    %eax,%eax
call   1060 <towerBuilder@plt>
movslq %eax,%rbx
mov    (%rbx),%rdi
call   1050 <puts@plt>
mov    0x8(%rbx),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    $0x3,%edi
xor    %eax,%eax
call   1060 <towerBuilder@plt>
movslq %eax,%rbx
mov    (%rbx),%rdi
call   1050 <puts@plt>
mov    0x8(%rbx),%rdi
call   1050 <puts@plt>
mov    0x10(%rbx),%rdi
call   1050 <puts@plt>
mov    (%rbx),%rdi
call   1030 <free@plt>
mov    0x8(%rbx),%rdi
call   1030 <free@plt>
mov    0x10(%rbx),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @tests() {
%1 = alloca i32
%2 = alloca i8**
%3 = alloca i32
store i32 2, i32* %1
%4 = load i32, i32* %1
%5 = call i32 (i32, ...) bitcast (i32 (...)* @towerBuilder to i32 (i32, ...)*)(i32 %4)
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i8**
store i8** %7, i8*** %2
store i32 0, i32* %3
br label %8
8: ; preds = %19, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %1
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = load i8**, i8*** %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %12
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %8
22: ; preds = %8
store i32 3, i32* %1
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* %1
%25 = call i32 (i32, ...) bitcast (i32 (...)* @towerBuilder to i32 (i32, ...)*)(i32 %24)
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i8**
store i8** %27, i8*** %2
store i32 0, i32* %3
br label %28
28: ; preds = %39, %22
%29 = load i32, i32* %3
%30 = load i32, i32* %1
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %42
32: ; preds = %28
%33 = load i8**, i8*** %2
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %28
42: ; preds = %28
store i32 0, i32* %3
br label %43
43: ; preds = %53, %42
%44 = load i32, i32* %3
%45 = load i32, i32* %1
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %56
47: ; preds = %43
%48 = load i8**, i8*** %2
%49 = load i32, i32* %3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
br label %53
53: ; preds = %47
%54 = load i32, i32* %3
%55 = add nsw i32 %54, 1
store i32 %55, i32* %3
br label %43
56: ; preds = %43
%57 = load i8**, i8*** %2
%58 = bitcast i8** %57 to i8*
ret void
}

LLVM IR (-O2):
define void @tests() {
%1 = tail call i32 (i32, ...) bitcast (i32 (...)* @towerBuilder to i32 (i32, ...)*)(i32 2)
%2 = sext i32 %1 to i64
%3 = inttoptr i64 %2 to i8**
%4 = load i8*, i8** %3
%5 = tail call i32 @puts(i8* dereferenceable(1) %4)
%6 = getelementptr inbounds i8*, i8** %3, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
%9 = tail call i32 @putchar(i32 10)
%10 = tail call i32 (i32, ...) bitcast (i32 (...)* @towerBuilder to i32 (i32, ...)*)(i32 3)
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i8**
%13 = load i8*, i8** %12
%14 = tail call i32 @puts(i8* dereferenceable(1) %13)
%15 = getelementptr inbounds i8*, i8** %12, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32 @puts(i8* dereferenceable(1) %16)
%18 = getelementptr inbounds i8*, i8** %12, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32 @puts(i8* dereferenceable(1) %19)
%21 = load i8*, i8** %12
tail call void @free(i8* %21)
%22 = load i8*, i8** %15
tail call void @free(i8* %22)
%23 = load i8*, i8** %18
tail call void @free(i8* %23)
%24 = inttoptr i64 %11 to i8*
tail call void @free(i8* %24)
ret void
}