#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 pr_mx(void *B, int rows, int cols) {
  double *b = B;
  int i, j;
  for (i = 0; i < rows; i++) {
    for (j = 0; j < cols; j++)
      printf("%c%5.2f", j == cols - 1 ? '|' : ' ', *b++);
    printf("\n");
  }
  for (i = 0; i < cols; i++)
    printf("------");
  printf("\n\n");
}


x86 assembly (clang, -O0):
<pr_mx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b3 <pr_mx+0xa3>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1197 <pr_mx+0x87>
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%edx
sub    $0x1,%edx
mov    $0x20,%esi
mov    $0x7c,%eax
cmp    %edx,%ecx
cmove  %eax,%esi
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x18(%rbp)
movsd  (%rax),%xmm0
lea    0xe7e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1144 <pr_mx+0x34>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <pr_mx+0x21>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11e2 <pr_mx+0xd2>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ba <pr_mx+0xaa>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_mx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,0x4(%rsp)
test   %esi,%esi
jle    11a8 <pr_mx+0x78>
mov    %rdi,%rbp
xor    %r12d,%r12d
mov    $0x7c,%r13d
lea    0xea7(%rip),%rbx
jmp    1175 <pr_mx+0x45>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
cmp    0x4(%rsp),%r12d
je     11a8 <pr_mx+0x78>
mov    %r14d,%r15d
test   %r14d,%r14d
jle    1160 <pr_mx+0x30>
nopl   (%rax)
cmp    $0x1,%r15d
mov    $0x20,%esi
cmove  %r13d,%esi
movsd  0x0(%rbp),%xmm0
add    $0x8,%rbp
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
add    $0xffffffff,%r15d
jne    1180 <pr_mx+0x50>
jmp    1160 <pr_mx+0x30>
test   %r14d,%r14d
jle    11d0 <pr_mx+0xa0>
lea    0xe54(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffff,%r14d
jne    11c0 <pr_mx+0x90>
lea    0xe38(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

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