#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_matrix(char *desc, int m, int n, double *a, int lda) {
  int i, j;
  printf("\n %s\n", desc);
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++)
      printf(" %6.2f", a[i + j * lda]);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b2 <print_matrix+0xa2>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1196 <print_matrix+0x86>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe85(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1156 <print_matrix+0x46>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1143 <print_matrix+0x33>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%ebx
mov    %rcx,%r15
mov    %edx,0x4(%rsp)
mov    %esi,%ebp
mov    %rdi,%rsi
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    11cb <print_matrix+0xab>
movslq %ebx,%rbx
mov    %ebp,%eax
mov    %rax,0x10(%rsp)
mov    0x4(%rsp),%eax
mov    %rax,0x8(%rsp)
shl    $0x3,%rbx
xor    %r13d,%r13d
lea    0xe96(%rip),%rbp
jmp    1199 <print_matrix+0x79>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13
add    $0x8,%r15
cmp    0x10(%rsp),%r13
je     11cb <print_matrix+0xab>
cmpl   $0x0,0x4(%rsp)
jle    1180 <print_matrix+0x60>
mov    0x8(%rsp),%r14
mov    %r15,%r12
nopl   0x0(%rax,%rax,1)
movsd  (%r12),%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    %rbx,%r12
add    $0xffffffffffffffff,%r14
jne    11b0 <print_matrix+0x90>
jmp    1180 <print_matrix+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"\0A %s\0A\00"
@.str.1 = [7 x i8] c" %6.2f\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_matrix(i8* %0, i32 %1, i32 %2, double* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store double* %3, double** %9
store i32 %4, i32* %10
%13 = load i8*, i8** %6
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 0, i32* %11
br label %15
15: ; preds = %40, %5
%16 = load i32, i32* %11
%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* %12
br label %20
20: ; preds = %35, %19
%21 = load i32, i32* %12
%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** %9
%26 = load i32, i32* %11
%27 = load i32, i32* %12
%28 = load i32, i32* %10
%29 = mul nsw i32 %27, %28
%30 = add nsw i32 %26, %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 ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %33)
br label %35
35: ; preds = %24
%36 = load i32, i32* %12
%37 = add nsw i32 %36, 1
store i32 %37, i32* %12
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* %11
%42 = add nsw i32 %41, 1
store i32 %42, i32* %11
br label %15
43: ; preds = %15
ret void
}

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