#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 *, ...);
int /*<<< orphan*/ printf(char *, char const *);
void print_ddense2mm(FILE *f, const char *name, int m, int n, const double *A) {
  printf("warning: writing obj %s\n", name);
  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_ddense2mm>:
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    -0x10(%rbp),%rsi
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xec0(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xeba(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xeb5(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xeac(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1218 <print_ddense2mm+0xf8>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11f8 <print_ddense2mm+0xd8>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe6d(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11b6 <print_ddense2mm+0x96>
mov    -0x8(%rbp),%rdi
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a3 <print_ddense2mm+0x83>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_ddense2mm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,0x10(%rsp)
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    0xea7(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe9f(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1060 <fwrite@plt>
lea    0xe96(%rip),%rsi
mov    %rbp,%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe8e(%rip),%rsi
mov    %rbp,%rdi
mov    %r14d,0xc(%rsp)
mov    %r14d,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %r15d,%r15d
jle    123e <print_ddense2mm+0xfe>
mov    %r15d,%eax
mov    0xc(%rsp),%ecx
mov    %rcx,0x18(%rsp)
mov    %rax,0x20(%rsp)
lea    0x0(,%rax,8),%r13
xor    %r14d,%r14d
lea    0xe63(%rip),%rbx
jmp    120e <print_ddense2mm+0xce>
nop
mov    $0xa,%edi
mov    %rbp,%rsi
call   1040 <fputc@plt>
add    $0x1,%r14
addq   $0x8,0x10(%rsp)
cmp    0x20(%rsp),%r14
je     123e <print_ddense2mm+0xfe>
cmpl   $0x0,0xc(%rsp)
jle    11f0 <print_ddense2mm+0xb0>
mov    0x18(%rsp),%r15
mov    0x10(%rsp),%r12
nop
movsd  (%r12),%xmm0
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
add    %r13,%r12
add    $0xffffffffffffffff,%r15
jne    1220 <print_ddense2mm+0xe0>
jmp    11f0 <print_ddense2mm+0xb0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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