int main(void) {
  int(*r1)[5];
  int(*r2)[5][10];
  r1 = f1();
  printf("%d\n", (*r1)[3]);
  printf("%d\n", r1[0][3]);
  r2 = f2();
  printf("%d\n", (*r2)[1][2]);
  printf("%d\n", r2[0][1][2]);
  free(r1);
  free(r2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <f1@plt>
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <f2@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x30(%rax),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x30(%rax),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1060 <f1@plt>
movslq %eax,%r15
mov    0xc(%r15),%esi
lea    0xea6(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%r15),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <f2@plt>
movslq %eax,%rbx
mov    0x30(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x30(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <free@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]*
%3 = alloca [5 x [10 x i32]]*
store i32 0, i32* %1
%4 = call i32 (...) @f1()
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to [5 x i32]*
store [5 x i32]* %6, [5 x i32]** %2
%7 = load [5 x i32]*, [5 x i32]** %2
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 3
%9 = load i32, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load [5 x i32]*, [5 x i32]** %2
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %11, i64 0
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %12, i64 0, i64 3
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = call i32 (...) @f2()
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to [5 x [10 x i32]]*
store [5 x [10 x i32]]* %18, [5 x [10 x i32]]** %3
%19 = load [5 x [10 x i32]]*, [5 x [10 x i32]]** %3
%20 = getelementptr inbounds [5 x [10 x i32]], [5 x [10 x i32]]* %19, i64 0, i64 1
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %20, i64 0, i64 2
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load [5 x [10 x i32]]*, [5 x [10 x i32]]** %3
%25 = getelementptr inbounds [5 x [10 x i32]], [5 x [10 x i32]]* %24, i64 0
%26 = getelementptr inbounds [5 x [10 x i32]], [5 x [10 x i32]]* %25, i64 0, i64 1
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %26, i64 0, i64 2
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = load [5 x i32]*, [5 x i32]** %2
%31 = bitcast [5 x i32]* %30 to i8*
%32 = load [5 x [10 x i32]]*, [5 x [10 x i32]]** %3
%33 = bitcast [5 x [10 x i32]]* %32 to i8*
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @f1()
%2 = sext i32 %1 to i64
%3 = inttoptr i64 %2 to [5 x i32]*
%4 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 3
%5 = load i32, i32* %4
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %4
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 (...) @f2()
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to [5 x [10 x i32]]*
%12 = getelementptr inbounds [5 x [10 x i32]], [5 x [10 x i32]]* %11, i64 0, i64 1, i64 2
%13 = load i32, i32* %12
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %12
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = inttoptr i64 %2 to i8*
tail call void @free(i8* %17)
%18 = inttoptr i64 %10 to i8*
tail call void @free(i8* %18)
ret i32 0
}