#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void print_matrix(double *m, int matrix_dim) {
  int i, j;
  for (i = 0; i < matrix_dim; i++) {
    for (j = 0; j < matrix_dim; j++)
      fprintf(stderr, "%f ", m[i * matrix_dim + j]);
    fprintf(stderr, "\n");
  }
}


x86 assembly (clang, -O0):
<print_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a5 <print_matrix+0x95>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1180 <print_matrix+0x70>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe95(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1139 <print_matrix+0x29>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <print_matrix+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    119a <print_matrix+0x8a>
mov    %rdi,%rbx
mov    %esi,%r12d
lea    0x0(,%r12,8),%rax
mov    %rax,(%rsp)
mov    0x2ea8(%rip),%rbp
lea    0xec1(%rip),%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%rbp),%edi
movsd  (%rbx,%r13,8),%xmm0
mov    %r14,%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
add    $0x1,%r13
cmp    %r13,%r12
jne    1160 <print_matrix+0x50>
mov    0x0(%rbp),%edi
lea    0xe7e(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%r15
add    (%rsp),%rbx
cmp    %r12,%r15
jne    1150 <print_matrix+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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