#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 */
int /*<<< orphan*/ printf(char *, ...);
void matrix_print_float(const char *name, const float *a,
                        const unsigned int dimX, const unsigned int dimY) {
  printf("%s=[\n", name);
  for (unsigned int i = 0; i < dimX * dimY; i++) {
    printf("%f ", a[i]);
  }
  printf("]\n");
}


x86 assembly (clang, -O0):
<matrix_print_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x18(%rbp),%ecx
cmp    %ecx,%eax
jae    117d <matrix_print_float+0x6d>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe9e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <matrix_print_float+0x2f>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_print_float>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rsi
lea    0xec7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
imul   %r14d,%ebp
test   %ebp,%ebp
je     117d <matrix_print_float+0x5d>
mov    %ebp,%ebp
xor    %ebx,%ebx
lea    0xeb3(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  (%r15,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <matrix_print_float+0x40>
lea    0xe86(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%s=[\0A\00"
@.str.1 = [4 x i8] c"%f \00"
@.str.2 = [3 x i8] c"]\0A\00"
define void @matrix_print_float(i8* %0, float* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca float*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store float* %1, float** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i8*, i8** %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %10)
store i32 0, i32* %9
br label %12
12: ; preds = %26, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = mul i32 %14, %15
%17 = icmp ult i32 %13, %16
br i1 %17, label %18, label %29
18: ; preds = %12
%19 = load float*, float** %6
%20 = load i32, i32* %9
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds float, float* %19, i64 %21
%23 = load float, float* %22
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %9
%28 = add i32 %27, 1
store i32 %28, i32* %9
br label %12
29: ; preds = %12
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s=[\0A\00"
@.str.1 = [4 x i8] c"%f \00"
@str = [2 x i8] c"]\00"
define void @matrix_print_float(i8* %0, float* nocapture %1, i32 %2, i32 %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = mul i32 %3, %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = zext i32 %6 to i64
br label %12
10: ; preds = %12, %4
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
12: ; preds = %8, %12
%13 = phi i64 [ 0, %8 ], [ %18, %12 ]
%14 = getelementptr inbounds float, float* %1, i64 %13
%15 = load float, float* %14
%16 = fpext float %15 to double
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %16)
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %9
br i1 %19, label %10, label %12
}