#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void print_sdense2mm(FILE *f, const char *name, int m, int n, const float *A) {
  fprintf(f, "# name: %s\n", name);
  fprintf(f, "# type: matrix\n");
  fprintf(f, "# rows: %i\n", m);
  fprintf(f, "# columns: %i\n", n);
  int i;
  for (i = 0; i < m; ++i) {
    int j;
    for (j = 0; j < n; ++j) {
      fprintf(f, "%.16e ", A[j * m + i]);
    }
    fprintf(f, "\n");
  }
}


x86 assembly (clang, -O0):
<print_sdense2mm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xec7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xec1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xebc(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xeb3(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11fc <print_sdense2mm+0xec>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11dc <print_sdense2mm+0xcc>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe70(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1196 <print_sdense2mm+0x86>
mov    -0x8(%rbp),%rdi
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1183 <print_sdense2mm+0x73>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_sdense2mm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,0x10(%rsp)
mov    %ecx,%r14d
mov    %edx,%ebx
mov    %rsi,%rdx
mov    %rdi,%rbp
lea    0xeab(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xea9(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1050 <fwrite@plt>
lea    0xea0(%rip),%rsi
mov    %rbp,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xe99(%rip),%rsi
mov    %rbp,%rdi
mov    %r14d,0xc(%rsp)
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %ebx,%ebx
jle    1221 <print_sdense2mm+0xf1>
mov    %ebx,%eax
mov    0xc(%rsp),%ecx
mov    %rcx,0x18(%rsp)
mov    %rax,0x20(%rsp)
lea    0x0(,%rax,4),%r13
xor    %r14d,%r14d
lea    0xe70(%rip),%rbx
jmp    11ee <print_sdense2mm+0xbe>
nopl   0x0(%rax)
mov    $0xa,%edi
mov    %rbp,%rsi
call   1030 <fputc@plt>
add    $0x1,%r14
addq   $0x4,0x10(%rsp)
cmp    0x20(%rsp),%r14
je     1221 <print_sdense2mm+0xf1>
cmpl   $0x0,0xc(%rsp)
jle    11d0 <print_sdense2mm+0xa0>
mov    0x18(%rsp),%r12
mov    0x10(%rsp),%r15
nop
movss  (%r15),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
add    %r13,%r15
add    $0xffffffffffffffff,%r12
jne    1200 <print_sdense2mm+0xd0>
jmp    11d0 <print_sdense2mm+0xa0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [12 x i8] c"# name: %s\0A\00"
@.str.1 = [16 x i8] c"# type: matrix\0A\00"
@.str.2 = [12 x i8] c"# rows: %i\0A\00"
@.str.3 = [15 x i8] c"# columns: %i\0A\00"
@.str.4 = [7 x i8] c"%.16e \00"
define void @print_sdense2mm(i32* nocapture %0, i8* %1, i32 %2, i32 %3, float* nocapture %4) {
%6 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %1)
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i64 15, i64 1, i32* %0)
%8 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%9 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %3)
%10 = icmp sgt i32 %2, 0
br i1 %10, label %11, label %32
11: ; preds = %5
%12 = icmp sgt i32 %3, 0
%13 = zext i32 %2 to i64
%14 = zext i32 %2 to i64
%15 = zext i32 %3 to i64
br label %16
16: ; preds = %11, %28
%17 = phi i64 [ 0, %11 ], [ %30, %28 ]
br i1 %12, label %18, label %28
18: ; preds = %16, %18
%19 = phi i64 [ %26, %18 ], [ 0, %16 ]
%20 = mul nsw i64 %19, %13
%21 = add nuw nsw i64 %20, %17
%22 = getelementptr inbounds float, float* %4, i64 %21
%23 = load float, float* %22
%24 = fpext float %23 to double
%25 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double %24)
%26 = add nuw nsw i64 %19, 1
%27 = icmp eq i64 %26, %15
br i1 %27, label %28, label %18
28: ; preds = %18, %16
%29 = tail call i32 @fputc(i32 10, i32* %0)
%30 = add nuw nsw i64 %17, 1
%31 = icmp eq i64 %30, %14
br i1 %31, label %32, label %16
32: ; preds = %28, %5
ret void
}