#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
void printBitmap(FILE *stream, unsigned char *bitmap, int w, int h) {
  int i, j;
  int bLineSize = (w - 1) / 8 + 1;
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (bitmap[bLineSize * i + j / 8] & (0x1 << (7 - (j % 8)))) {
        fputc('#', stream);
        fputc('#', stream);
      } else {
        fputc(' ', stream);
        fputc(' ', stream);
      }
    }
    fputc('\n', stream);
  }
}


x86 assembly (clang, -O0):
<printBitmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1221 <printBitmap+0x111>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1205 <printBitmap+0xf5>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%eax
mov    $0x8,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x30(%rbp),%rax
add    %edx,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%eax
mov    $0x7,%ecx
sub    %edx,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11d6 <printBitmap+0xc6>
mov    -0x8(%rbp),%rsi
mov    $0x23,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x23,%edi
call   1030 <fputc@plt>
jmp    11f2 <printBitmap+0xe2>
mov    -0x8(%rbp),%rsi
mov    $0x20,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x20,%edi
call   1030 <fputc@plt>
jmp    11f7 <printBitmap+0xe7>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1154 <printBitmap+0x44>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1030 <fputc@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1141 <printBitmap+0x31>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printBitmap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r12d
lea    -0x1(%r12),%eax
lea    0x6(%r12),%edx
test   %eax,%eax
cmovns %eax,%edx
mov    %ecx,0x14(%rsp)
test   %ecx,%ecx
jle    11eb <printBitmap+0xdb>
mov    %rsi,%r15
mov    %rdi,%rbp
mov    %edx,%eax
sar    $0x3,%eax
add    $0x1,%eax
mov    %eax,0x10(%rsp)
movl   $0x0,0xc(%rsp)
jmp    117e <printBitmap+0x6e>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %rbp,%rsi
call   1030 <fputc@plt>
mov    0xc(%rsp),%eax
add    $0x1,%eax
mov    %eax,0xc(%rsp)
cmp    0x14(%rsp),%eax
je     11eb <printBitmap+0xdb>
test   %r12d,%r12d
jle    1160 <printBitmap+0x50>
mov    0xc(%rsp),%r13d
imul   0x10(%rsp),%r13d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14d,%eax
shr    $0x3,%eax
add    %r13d,%eax
cltq
movzbl (%r15,%rax,1),%eax
mov    %r14d,%ecx
not    %cl
and    $0x7,%cl
movzbl %cl,%ecx
xor    %edx,%edx
bt     %ecx,%eax
setb   %dl
lea    (%rdx,%rdx,2),%ebx
or     $0x20,%ebx
mov    %ebx,%edi
mov    %rbp,%rsi
call   1030 <fputc@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
call   1030 <fputc@plt>
add    $0x1,%r14d
cmp    %r14d,%r12d
jne    11a0 <printBitmap+0x90>
jmp    1160 <printBitmap+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @printBitmap(i32* nocapture %0, i8* nocapture %1, i32 %2, i32 %3) {
%5 = add nsw i32 %2, -1
%6 = sdiv i32 %5, 8
%7 = add nsw i32 %6, 1
%8 = icmp sgt i32 %3, 0
br i1 %8, label %9, label %37
9: ; preds = %4
%10 = icmp sgt i32 %2, 0
br label %11
11: ; preds = %9, %33
%12 = phi i32 [ 0, %9 ], [ %35, %33 ]
br i1 %10, label %13, label %33
13: ; preds = %11
%14 = mul nsw i32 %12, %7
br label %15
15: ; preds = %13, %15
%16 = phi i32 [ 0, %13 ], [ %31, %15 ]
%17 = lshr i32 %16, 3
%18 = add nsw i32 %17, %14
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %1, i64 %19
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = and i32 %16, 7
%24 = xor i32 %23, 7
%25 = shl nuw i32 1, %24
%26 = and i32 %25, %22
%27 = icmp eq i32 %26, 0
%28 = select i1 %27, i8 32, i8 35
%29 = tail call i32 @fputc(i8 signext %28, i32* %0)
%30 = tail call i32 @fputc(i8 signext %28, i32* %0)
%31 = add nuw nsw i32 %16, 1
%32 = icmp eq i32 %31, %2
br i1 %32, label %33, label %15
33: ; preds = %15, %11
%34 = tail call i32 @fputc(i8 signext 10, i32* %0)
%35 = add nuw nsw i32 %12, 1
%36 = icmp eq i32 %35, %3
br i1 %36, label %37, label %11
37: ; preds = %33, %4
ret void
}