#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 muggle_output_bin(const unsigned char *bytes, unsigned int row,
                       unsigned int col) {
  unsigned int val = 0;
  for (unsigned int i = 0; i < row; ++i) {
    for (unsigned int j = 0; j < col; ++j) {
      val = (0x01 << j) & bytes[i];
      printf("%u ", val == 0 ? 0 : 1);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<muggle_output_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11b1 <muggle_output_bin+0xa1>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    1195 <muggle_output_bin+0x85>
mov    -0x1c(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x8(%rbp),%rcx
mov    -0x18(%rbp),%edx
movzbl (%rcx,%rdx,1),%ecx
and    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
mov    $0x1,%esi
xor    %eax,%eax
cmp    $0x0,%ecx
cmove  %eax,%esi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1143 <muggle_output_bin+0x33>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1130 <muggle_output_bin+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<muggle_output_bin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     1190 <muggle_output_bin+0x70>
mov    %edx,%r13d
mov    %rdi,%r14
mov    %esi,%r12d
lea    0xec1(%rip),%r15
xor    %ebx,%ebx
jmp    1163 <muggle_output_bin+0x43>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %r12,%rbx
je     1190 <muggle_output_bin+0x70>
test   %r13d,%r13d
je     1150 <muggle_output_bin+0x30>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movzbl (%r14,%rbx,1),%esi
mov    %ebp,%ecx
shr    %cl,%esi
and    $0x1,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%r13d
jne    1170 <muggle_output_bin+0x50>
jmp    1150 <muggle_output_bin+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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