#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 */
float **convert2d(int, int, float *);
int /*<<< orphan*/ free(float **);
int /*<<< orphan*/ printf(char *, ...);
void print_2d_list(int len1, int len2, float *list) {
  float **list2d = convert2d(len1, len2, list);
  for (int index1 = 0; index1 < len1; index1++) {
    for (int index2 = 0; index2 < len2; index2++) {
      printf("%1.1f ", list2d[index1][index2]);
    }
    printf("\n");
  }
  free(list2d);
}


x86 assembly (clang, -O0):
<print_2d_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1050 <convert2d@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11cc <print_2d_list+0x9c>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b0 <print_2d_list+0x80>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe65(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116f <print_2d_list+0x3f>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <print_2d_list+0x2c>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_2d_list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebp
mov    %esi,0x4(%rsp)
call   1060 <convert2d@plt>
mov    %rax,%r13
test   %ebp,%ebp
jle    11b4 <print_2d_list+0x74>
mov    %ebp,%r15d
mov    0x4(%rsp),%ebp
xor    %ebx,%ebx
lea    0xe93(%rip),%r12
jmp    1183 <print_2d_list+0x43>
nop
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x1,%rbx
cmp    %r15,%rbx
je     11b4 <print_2d_list+0x74>
cmpl   $0x0,0x4(%rsp)
jle    1170 <print_2d_list+0x30>
xor    %r14d,%r14d
nopl   (%rax)
mov    0x0(%r13,%rbx,8),%rax
movss  (%rax,%r14,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbp
jne    1190 <print_2d_list+0x50>
jmp    1170 <print_2d_list+0x30>
mov    %r13,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%1.1f \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_2d_list(i32 %0, i32 %1, float* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca float*
%7 = alloca float**
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store float* %2, float** %6
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = load float*, float** %6
%13 = call float** @convert2d(i32 %10, i32 %11, float* %12)
store float** %13, float*** %7
store i32 0, i32* %8
br label %14
14: ; preds = %40, %3
%15 = load i32, i32* %8
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %43
18: ; preds = %14
store i32 0, i32* %9
br label %19
19: ; preds = %35, %18
%20 = load i32, i32* %9
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %38
23: ; preds = %19
%24 = load float**, float*** %7
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds float*, float** %24, i64 %26
%28 = load float*, float** %27
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds float, float* %28, i64 %30
%32 = load float, float* %31
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %33)
br label %35
35: ; preds = %23
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %19
38: ; preds = %19
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %38
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
store i32 %42, i32* %8
br label %14
43: ; preds = %14
%44 = load float**, float*** %7
%45 = call i32 @free(float** %44)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%1.1f \00"
define void @print_2d_list(i32 %0, i32 %1, float* %2) {
%4 = tail call float** @convert2d(i32 %0, i32 %1, float* %2)
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = icmp sgt i32 %1, 0
%8 = zext i32 %0 to i64
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %6, %16
%11 = phi i64 [ 0, %6 ], [ %18, %16 ]
br i1 %7, label %12, label %16
12: ; preds = %10
%13 = getelementptr inbounds float*, float** %4, i64 %11
br label %20
14: ; preds = %16, %3
%15 = tail call i32 @free(float** %4)
ret void
16: ; preds = %20, %10
%17 = tail call i32 @putchar(i32 10)
%18 = add nuw nsw i64 %11, 1
%19 = icmp eq i64 %18, %8
br i1 %19, label %14, label %10
20: ; preds = %12, %20
%21 = phi i64 [ 0, %12 ], [ %27, %20 ]
%22 = load float*, float** %13
%23 = getelementptr inbounds float, float* %22, i64 %21
%24 = load float, float* %23
%25 = fpext float %24 to double
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %25)
%27 = add nuw nsw i64 %21, 1
%28 = icmp eq i64 %27, %9
br i1 %28, label %16, label %20
}