#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 jerasure_print_bitmatrix(int *m, int rows, int cols, int w) {
  int i, j;
  for (i = 0; i < rows; i++) {
    if (i != 0 && i % w == 0)
      printf("\n");
    for (j = 0; j < cols; j++) {
      if (j != 0 && j % w == 0)
        printf(" ");
      printf("%d", m[i * cols + j]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<jerasure_print_bitmatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e7 <jerasure_print_bitmatrix+0xd7>
cmpl   $0x0,-0x18(%rbp)
je     1160 <jerasure_print_bitmatrix+0x50>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    1160 <jerasure_print_bitmatrix+0x50>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11cb <jerasure_print_bitmatrix+0xbb>
cmpl   $0x0,-0x1c(%rbp)
je     119b <jerasure_print_bitmatrix+0x8b>
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    119b <jerasure_print_bitmatrix+0x8b>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <jerasure_print_bitmatrix+0x57>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112c <jerasure_print_bitmatrix+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jerasure_print_bitmatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,0x4(%rsp)
mov    %rdi,0x8(%rsp)
test   %esi,%esi
jle    1226 <jerasure_print_bitmatrix+0x106>
mov    %ecx,%r13d
movslq 0x4(%rsp),%rax
mov    %esi,%ecx
mov    %rcx,0x20(%rsp)
mov    %eax,%r14d
mov    %rax,0x10(%rsp)
lea    0x0(,%rax,4),%rax
mov    %rax,0x18(%rsp)
lea    0xe96(%rip),%r12
mov    0x8(%rsp),%r15
xor    %ebp,%ebp
jmp    119e <jerasure_print_bitmatrix+0x7e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
add    0x18(%rsp),%r15
cmp    0x20(%rsp),%rbp
je     1226 <jerasure_print_bitmatrix+0x106>
test   %rbp,%rbp
je     11ad <jerasure_print_bitmatrix+0x8d>
mov    %ebp,%eax
cltd
idiv   %r13d
test   %edx,%edx
je     1210 <jerasure_print_bitmatrix+0xf0>
cmpl   $0x0,0x4(%rsp)
jle    1180 <jerasure_print_bitmatrix+0x60>
mov    %rbp,%rax
imul   0x10(%rsp),%rax
mov    0x8(%rsp),%rcx
mov    (%rcx,%rax,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x1,0x4(%rsp)
je     1180 <jerasure_print_bitmatrix+0x60>
mov    $0x1,%ebx
jmp    11f7 <jerasure_print_bitmatrix+0xd7>
nopl   (%rax)
mov    (%r15,%rbx,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
je     1180 <jerasure_print_bitmatrix+0x60>
mov    %ebx,%eax
cltd
idiv   %r13d
test   %edx,%edx
jne    11e0 <jerasure_print_bitmatrix+0xc0>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11e0 <jerasure_print_bitmatrix+0xc0>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0x4(%rsp)
jg     11b4 <jerasure_print_bitmatrix+0x94>
jmp    1180 <jerasure_print_bitmatrix+0x60>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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