#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 print(const char *name, const double *matrix, int row, int column) {
  printf("Matrix %s has %d rows and %d columns:\n", name, row, column);
  for (int i = 0; i < row; i++) {
    for (int j = 0; j < column; j++) {
      printf("%.3f ", matrix[j * row + i]);
    }
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b2 <print+0xa2>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1196 <print+0x86>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xea6(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1158 <print+0x48>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1145 <print+0x35>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rsi
lea    0xec3(%rip),%rdi
mov    %ecx,0x4(%rsp)
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    11bb <print+0x9b>
mov    %ebp,%eax
mov    0x4(%rsp),%ecx
mov    %rcx,0x8(%rsp)
mov    %rax,0x10(%rsp)
lea    0x0(,%rax,8),%rbx
xor    %r14d,%r14d
lea    0xeb9(%rip),%rbp
jmp    1189 <print+0x69>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
add    $0x8,%r15
cmp    0x10(%rsp),%r14
je     11bb <print+0x9b>
mov    0x8(%rsp),%r12
mov    %r15,%r13
cmpl   $0x0,0x4(%rsp)
jle    1170 <print+0x50>
nopl   0x0(%rax,%rax,1)
movsd  0x0(%r13),%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    %rbx,%r13
add    $0xffffffffffffffff,%r12
jne    11a0 <print+0x80>
jmp    1170 <print+0x50>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"Matrix %s has %d rows and %d columns:\0A\00"
@.str.1 = [6 x i8] c"%.3f \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print(i8* %0, double* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i8*, i8** %5
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %11, i32 %12, i32 %13)
store i32 0, i32* %9
br label %15
15: ; preds = %40, %4
%16 = load i32, i32* %9
%17 = load i32, i32* %7
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %43
19: ; preds = %15
store i32 0, i32* %10
br label %20
20: ; preds = %35, %19
%21 = load i32, i32* %10
%22 = load i32, i32* %8
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %38
24: ; preds = %20
%25 = load double*, double** %6
%26 = load i32, i32* %10
%27 = load i32, i32* %7
%28 = mul nsw i32 %26, %27
%29 = load i32, i32* %9
%30 = add nsw i32 %28, %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %25, i64 %31
%33 = load double, double* %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %33)
br label %35
35: ; preds = %24
%36 = load i32, i32* %10
%37 = add nsw i32 %36, 1
store i32 %37, i32* %10
br label %20
38: ; preds = %20
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %40
40: ; preds = %38
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 1
store i32 %42, i32* %9
br label %15
43: ; preds = %15
%44 = 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 = [39 x i8] c"Matrix %s has %d rows and %d columns:\0A\00"
@.str.1 = [6 x i8] c"%.3f \00"
define void @print(i8* %0, double* nocapture %1, i32 %2, i32 %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2, i32 %3)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = icmp sgt i32 %3, 0
%9 = zext i32 %2 to i64
%10 = zext i32 %2 to i64
%11 = zext i32 %3 to i64
br label %12
12: ; preds = %7, %16
%13 = phi i64 [ 0, %7 ], [ %18, %16 ]
br i1 %8, label %20, label %16
14: ; preds = %16, %4
%15 = tail call i32 @putchar(i32 10)
ret void
16: ; preds = %20, %12
%17 = tail call i32 @putchar(i32 10)
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %10
br i1 %19, label %14, label %12
20: ; preds = %12, %20
%21 = phi i64 [ %27, %20 ], [ 0, %12 ]
%22 = mul nsw i64 %21, %9
%23 = add nuw nsw i64 %22, %13
%24 = getelementptr inbounds double, double* %1, i64 %23
%25 = load double, double* %24
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %25)
%27 = add nuw nsw i64 %21, 1
%28 = icmp eq i64 %27, %11
br i1 %28, label %16, label %20
}