#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 int u_short;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int pr_matrix(void *m1, int rows, int cols, char *s) {
  int r, c;
  u_short *m = m1;
  fprintf(stderr, "%s\n", s);
  for (r = 0; r < rows; r++) {
    for (c = 0; c < cols; c++)
      fprintf(stderr, "%3d  ", m[r * cols + c]);
    fprintf(stderr, "\n");
  }
  fprintf(stderr, "\n");
  return 0;
}


x86 assembly (clang, -O0):
<pr_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    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xebe(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cd <pr_matrix+0xbd>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11a8 <pr_matrix+0x98>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1163 <pr_matrix+0x53>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1150 <pr_matrix+0x40>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    0xe25(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,0x4(%rsp)
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2eb2(%rip),%r12
mov    (%r12),%edi
lea    0xec7(%rip),%rsi
mov    %rcx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %ebp,%ebp
jle    11bd <pr_matrix+0xad>
movslq 0x4(%rsp),%rax
mov    %ebp,%ecx
mov    %rcx,0x8(%rsp)
mov    %eax,%r14d
shl    $0x2,%rax
mov    %rax,0x10(%rsp)
lea    0xe9e(%rip),%rbp
xor    %r15d,%r15d
jmp    1192 <pr_matrix+0x82>
nopl   0x0(%rax,%rax,1)
mov    (%r12),%edi
lea    0xe87(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%r15
add    0x10(%rsp),%rbx
cmp    0x8(%rsp),%r15
je     11bd <pr_matrix+0xad>
cmpl   $0x0,0x4(%rsp)
jle    1170 <pr_matrix+0x60>
xor    %r13d,%r13d
nopl   0x0(%rax)
mov    (%r12),%edi
mov    (%rbx,%r13,4),%edx
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%r13
cmp    %r13,%r14
jne    11a0 <pr_matrix+0x90>
jmp    1170 <pr_matrix+0x60>
mov    (%r12),%edi
lea    0xe3a(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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