#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 scalar_t__ *m;
typedef size_t j;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_matrix(double *A, int m, int n) {
  int i, j;
  printf("[");
  for (i = 0; i < m; i++) {
    printf("\t[");
    for (j = 0; j < n; j++) {
      printf("%12.8f%s", A[((j) * (m) + (i))], ((j != n - 1) ? ", " : ""));
    }
    printf("]%s\n", ((i != n - 1) ? "," : ""));
  }
  printf("]\n");
}


x86 assembly (clang, -O0):
<print_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ec <print_matrix+0xdc>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11b3 <print_matrix+0xa3>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%edx
sub    $0x1,%edx
lea    0xe8e(%rip),%rsi
lea    0xe7b(%rip),%rax
cmp    %edx,%ecx
cmovne %rax,%rsi
lea    0xe65(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1158 <print_matrix+0x48>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%edx
sub    $0x1,%edx
lea    0xe55(%rip),%rsi
lea    0xe4a(%rip),%rax
cmp    %edx,%ecx
cmovne %rax,%rsi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <print_matrix+0x27>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,0x8(%rsp)
mov    %esi,%ebx
mov    %rdi,0x10(%rsp)
mov    $0x5b,%edi
call   1030 <putchar@plt>
test   %ebx,%ebx
jle    1247 <print_matrix+0x117>
mov    0x8(%rsp),%rax
lea    -0x1(%rax),%r13d
mov    %ebx,%ecx
mov    %eax,%ebp
mov    %rcx,0x18(%rsp)
lea    0x0(,%rcx,8),%r14
lea    0xe96(%rip),%r12
xor    %ebx,%ebx
mov    %r14,0x30(%rsp)
mov    %rbp,0x28(%rsp)
jmp    11c9 <print_matrix+0x99>
nopl   0x0(%rax,%rax,1)
mov    0x20(%rsp),%rbx
cmp    %r13,%rbx
lea    0xe75(%rip),%rsi
cmove  %r15,%rsi
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
addq   $0x8,0x10(%rsp)
cmp    0x18(%rsp),%rbx
mov    %r15,%r12
je     1247 <print_matrix+0x117>
mov    %rbx,0x20(%rsp)
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x8(%rsp)
lea    0xe24(%rip),%rcx
mov    %r12,%r15
lea    0xe11(%rip),%rax
jle    1190 <print_matrix+0x60>
mov    0x10(%rsp),%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  (%r12),%xmm0
cmp    %rbx,%r13
mov    %r13,%rbp
mov    %rcx,%r13
mov    %rcx,%rsi
cmove  %r15,%rsi
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %r14,%rax
mov    %r13,%rcx
mov    %rbp,%r13
mov    0x30(%rsp),%r14
mov    0x28(%rsp),%rbp
add    $0x1,%rbx
add    %r14,%r12
cmp    %rbx,%rbp
jne    1200 <print_matrix+0xd0>
jmp    1190 <print_matrix+0x60>
lea    0xdc8(%rip),%rdi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"\09[\00"
@.str.2 = [9 x i8] c"%12.8f%s\00"
@.str.3 = [3 x i8] c", \00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [5 x i8] c"]%s\0A\00"
@.str.6 = [2 x i8] c",\00"
@str = [2 x i8] c"]\00"
define void @print_matrix(double* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32 @putchar(i32 91)
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %33
6: ; preds = %3
%7 = icmp sgt i32 %2, 0
%8 = add nsw i32 %2, -1
%9 = zext i32 %1 to i64
%10 = zext i32 %8 to i64
%11 = zext i32 %1 to i64
%12 = zext i32 %2 to i64
br label %13
13: ; preds = %6, %27
%14 = phi i64 [ 0, %6 ], [ %31, %27 ]
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br i1 %7, label %16, label %27
16: ; preds = %13, %16
%17 = phi i64 [ %25, %16 ], [ 0, %13 ]
%18 = mul nsw i64 %17, %9
%19 = add nuw nsw i64 %18, %14
%20 = getelementptr inbounds double, double* %0, i64 %19
%21 = load double, double* %20
%22 = icmp eq i64 %17, %10
%23 = select i1 %22, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %21, i8* %23)
%25 = add nuw nsw i64 %17, 1
%26 = icmp eq i64 %25, %12
br i1 %26, label %27, label %16
27: ; preds = %16, %13
%28 = icmp eq i64 %14, %10
%29 = select i1 %28, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %29)
%31 = add nuw nsw i64 %14, 1
%32 = icmp eq i64 %31, %11
br i1 %32, label %33, label %13
33: ; preds = %27, %3
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}