#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 *, float);
int /*<<< orphan*/ putchar(int);
void printmatf(char *format, float *mat, int m, int n) {
  for (long i = 0; i < m; ++i) {
    for (long j = 0; j < n; ++j)
      printf(format, mat[i * n + j]);
    putchar(10);
  }
}


x86 assembly (clang, -O0):
<printmatf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmp    %rcx,%rax
jge    11b6 <printmatf+0x96>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmp    %rcx,%rax
jge    119b <printmatf+0x7b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x18(%rbp),%rdx
imul   %rdx,%rcx
add    -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1157 <printmatf+0x37>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113e <printmatf+0x1e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printmatf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,0xc(%rsp)
test   %edx,%edx
jle    11a9 <printmatf+0x89>
mov    %rsi,%rbx
mov    %rdi,%r12
movslq %edx,%rax
mov    %rax,0x10(%rsp)
movslq 0xc(%rsp),%rbp
lea    0x0(,%rbp,4),%r13
xor    %r14d,%r14d
jmp    1178 <printmatf+0x58>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
add    %r13,%rbx
cmp    0x10(%rsp),%r14
je     11a9 <printmatf+0x89>
cmpl   $0x0,0xc(%rsp)
jle    1160 <printmatf+0x40>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  (%rbx,%r15,4),%xmm0
mov    %r12,%rdi
call   1040 <printf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
jne    1190 <printmatf+0x70>
jmp    1160 <printmatf+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @printmatf(i8* %0, float* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca float*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
store i8* %0, i8** %5
store float* %1, float** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i64 0, i64* %9
br label %11
11: ; preds = %39, %4
%12 = load i64, i64* %9
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = icmp slt i64 %12, %14
br i1 %15, label %16, label %42
16: ; preds = %11
store i64 0, i64* %10
br label %17
17: ; preds = %34, %16
%18 = load i64, i64* %10
%19 = load i32, i32* %8
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %18, %20
br i1 %21, label %22, label %37
22: ; preds = %17
%23 = load i8*, i8** %5
%24 = load float*, float** %6
%25 = load i64, i64* %9
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = mul nsw i64 %25, %27
%29 = load i64, i64* %10
%30 = add nsw i64 %28, %29
%31 = getelementptr inbounds float, float* %24, i64 %30
%32 = load float, float* %31
%33 = call i32 @printf(i8* %23, float %32)
br label %34
34: ; preds = %22
%35 = load i64, i64* %10
%36 = add nsw i64 %35, 1
store i64 %36, i64* %10
br label %17
37: ; preds = %17
%38 = call i32 @putchar(i32 10)
br label %39
39: ; preds = %37
%40 = load i64, i64* %9
%41 = add nsw i64 %40, 1
store i64 %41, i64* %9
br label %11
42: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @printmatf(i8* %0, float* nocapture %1, i32 %2, i32 %3) {
%5 = sext i32 %2 to i64
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = sext i32 %3 to i64
%9 = icmp sgt i32 %3, 0
br label %10
10: ; preds = %7, %15
%11 = phi i64 [ 0, %7 ], [ %17, %15 ]
br i1 %9, label %12, label %15
12: ; preds = %10
%13 = mul nsw i64 %11, %8
br label %19
14: ; preds = %15, %4
ret void
15: ; preds = %19, %10
%16 = tail call i32 @putchar(i32 10)
%17 = add nuw nsw i64 %11, 1
%18 = icmp eq i64 %17, %5
br i1 %18, label %14, label %10
19: ; preds = %12, %19
%20 = phi i64 [ 0, %12 ], [ %25, %19 ]
%21 = add nsw i64 %20, %13
%22 = getelementptr inbounds float, float* %1, i64 %21
%23 = load float, float* %22
%24 = tail call i32 @printf(i8* %0, float %23)
%25 = add nuw nsw i64 %20, 1
%26 = icmp eq i64 %25, %8
br i1 %26, label %15, label %19
}