#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 *, ...);
void printMatrixCustom(double *matrix, size_t size_r, size_t size_c) {
  printf("\n *************** MATRIX ****************\n\n");
  int i, j;
  for (i = 0; i < size_r; i++) {
    for (j = 0; j < size_c; ++j) {
      printf(" %.4f ", matrix[i * size_c + j]);
    }
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printMatrixCustom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11ad <printMatrixCustom+0x9d>
movl   $0x0,-0x20(%rbp)
movslq -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1191 <printMatrixCustom+0x81>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
add    %rdx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xeb0(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114e <printMatrixCustom+0x3e>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1139 <printMatrixCustom+0x29>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMatrixCustom>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xebc(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,(%rsp)
test   %rbp,%rbp
je     11ab <printMatrixCustom+0x7b>
lea    0x0(,%r15,8),%r13
xor    %ebp,%ebp
lea    0xe96(%rip),%r12
jmp    1187 <printMatrixCustom+0x57>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
add    %r13,%rbx
cmp    (%rsp),%rbp
je     11ab <printMatrixCustom+0x7b>
test   %r15,%r15
je     1170 <printMatrixCustom+0x40>
xor    %r14d,%r14d
nop
movsd  (%rbx,%r14,8),%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x1,%r14
cmp    %r14,%r15
jne    1190 <printMatrixCustom+0x60>
jmp    1170 <printMatrixCustom+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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