#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 *, ...);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
int strlen(char *);
void jerasure_print_matrix(int *m, int rows, int cols, int w) {
  int i, j;
  int fw;
  char s[30];
  unsigned int w2;
  if (w == 32) {
    fw = 10;
  } else {
    w2 = (1 << w);
    sprintf(s, "%u", w2 - 1);
    fw = strlen(s);
  }
  for (i = 0; i < rows; i++) {
    for (j = 0; j < cols; j++) {
      if (j != 0)
        printf(" ");
      printf("%*u", fw, m[i * cols + j]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<jerasure_print_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jne    115b <jerasure_print_matrix+0x2b>
movl   $0xa,-0x20(%rbp)
jmp    118a <jerasure_print_matrix+0x5a>
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x44(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%edx
sub    $0x1,%edx
lea    0xe87(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1217 <jerasure_print_matrix+0xe7>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11fb <jerasure_print_matrix+0xcb>
cmpl   $0x0,-0x1c(%rbp)
je     11c8 <jerasure_print_matrix+0x98>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a4 <jerasure_print_matrix+0x74>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1191 <jerasure_print_matrix+0x61>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jerasure_print_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %edx,0xc(%rsp)
mov    %esi,%ebx
mov    %rdi,0x10(%rsp)
mov    $0xa,%ebp
cmp    $0x20,%ecx
je     118a <jerasure_print_matrix+0x4a>
mov    $0xffffffff,%edx
shl    %cl,%edx
not    %edx
lea    0xe8d(%rip),%rsi
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
call   1060 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
test   %ebx,%ebx
jle    1246 <jerasure_print_matrix+0x106>
movslq 0xc(%rsp),%rax
mov    %ebx,%ecx
mov    %rcx,0x28(%rsp)
mov    %eax,%r14d
mov    %rax,0x18(%rsp)
lea    0x0(,%rax,4),%rax
mov    %rax,0x20(%rsp)
lea    0xe49(%rip),%rbx
mov    0x10(%rsp),%r13
xor    %r12d,%r12d
jmp    11ea <jerasure_print_matrix+0xaa>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
add    0x20(%rsp),%r13
cmp    0x28(%rsp),%r12
je     1246 <jerasure_print_matrix+0x106>
cmpl   $0x0,0xc(%rsp)
jle    11d0 <jerasure_print_matrix+0x90>
mov    %r12,%rax
imul   0x18(%rsp),%rax
mov    0x10(%rsp),%rcx
mov    (%rcx,%rax,4),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x1,0xc(%rsp)
je     11d0 <jerasure_print_matrix+0x90>
mov    $0x1,%r15d
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    0x0(%r13,%r15,4),%edx
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15
cmp    %r15,%r14
jne    1220 <jerasure_print_matrix+0xe0>
jmp    11d0 <jerasure_print_matrix+0x90>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@.str.2 = [4 x i8] c"%*u\00"
define void @jerasure_print_matrix(i32* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [30 x i8]
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%7 = icmp eq i32 %3, 32
br i1 %7, label %13, label %8
8: ; preds = %4
%9 = shl nsw i32 -1, %3
%10 = xor i32 %9, -1
%11 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @strlen(i8* %6)
br label %13
13: ; preds = %4, %8
%14 = phi i32 [ %12, %8 ], [ 10, %4 ]
%15 = icmp sgt i32 %1, 0
br i1 %15, label %16, label %42
16: ; preds = %13
%17 = icmp sgt i32 %2, 0
%18 = sext i32 %2 to i64
%19 = zext i32 %1 to i64
%20 = zext i32 %2 to i64
%21 = icmp eq i32 %2, 1
br label %22
22: ; preds = %16, %38
%23 = phi i64 [ 0, %16 ], [ %40, %38 ]
br i1 %17, label %24, label %38
24: ; preds = %22
%25 = mul nsw i64 %23, %18
%26 = getelementptr inbounds i32, i32* %0, i64 %25
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %27)
br i1 %21, label %38, label %29
29: ; preds = %24, %29
%30 = phi i64 [ %36, %29 ], [ 1, %24 ]
%31 = call i32 @putchar(i32 32)
%32 = add nsw i64 %30, %25
%33 = getelementptr inbounds i32, i32* %0, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %34)
%36 = add nuw nsw i64 %30, 1
%37 = icmp eq i64 %36, %20
br i1 %37, label %38, label %29
38: ; preds = %29, %24, %22
%39 = call i32 @putchar(i32 10)
%40 = add nuw nsw i64 %23, 1
%41 = icmp eq i64 %40, %19
br i1 %41, label %42, label %22
42: ; preds = %38, %13
ret void
}