#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 uint64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_matrix(double *matrix, const uint64_t N) {
  for (int ii = 0; ii < N; ii++) {
    for (int jj = 0; jj < N; jj++) {
      printf("%*lf", 15, matrix[(ii * N + jj)]);
    }
    printf("\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    1198 <print_matrix+0x88>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117c <print_matrix+0x6c>
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    0xe9e(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1139 <print_matrix+0x29>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@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    1193 <print_matrix+0x73>
mov    %rdi,%rbx
mov    %esi,%r15d
lea    0x0(,%r15,8),%r12
xor    %r13d,%r13d
lea    0xeb9(%rip),%r14
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rbx,%rbp,8),%xmm0
mov    %r14,%rdi
mov    $0xf,%esi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1160 <print_matrix+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13
add    %r12,%rbx
cmp    %r15,%r13
jne    1150 <print_matrix+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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