#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 */
scalar_t__ checkbit(char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int, int);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void dumpbitmap(char *bptr, int height, int width, int rwid) {
  int i, j;
  fprintf(stderr, "height=%d, width=%d, rwid=%d\n", height, width, rwid);
  for (j = 0; j < height; j++) {
    for (i = 0; i < width; i++)
      if (checkbit(bptr, j * rwid * 8 + i))
        putc('X', stderr);
      else
        putc('.', stderr);
    putc('\n', stderr);
  }
}


x86 assembly (clang, -O0):
<dumpbitmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xea1(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1209 <dumpbitmap+0xd9>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11e8 <dumpbitmap+0xb8>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
imul   -0x14(%rbp),%esi
shl    $0x3,%esi
add    -0x18(%rbp),%esi
call   1050 <checkbit@plt>
cmp    $0x0,%rax
je     11c2 <dumpbitmap+0x92>
mov    0x2e2f(%rip),%rax
mov    (%rax),%esi
mov    $0x58,%edi
call   1030 <putc@plt>
jmp    11d5 <dumpbitmap+0xa5>
mov    0x2e17(%rip),%rax
mov    (%rax),%esi
mov    $0x2e,%edi
call   1030 <putc@plt>
jmp    11da <dumpbitmap+0xaa>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    117e <dumpbitmap+0x4e>
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <putc@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116b <dumpbitmap+0x3b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpbitmap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r8d
mov    %edx,%ecx
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x2e91(%rip),%r13
mov    0x0(%r13),%edi
lea    0xea6(%rip),%rsi
mov    %ebp,%edx
mov    %ecx,0x10(%rsp)
mov    %r8d,0xc(%rsp)
call   1040 <fprintf@plt>
mov    %ebp,0x14(%rsp)
test   %ebp,%ebp
jle    11fa <dumpbitmap+0xca>
shll   $0x3,0xc(%rsp)
movl   $0x0,0x8(%rsp)
mov    $0x2e,%r15d
xor    %r12d,%r12d
jmp    11b5 <dumpbitmap+0x85>
xchg   %ax,%ax
mov    0x0(%r13),%esi
mov    $0xa,%edi
call   1030 <putc@plt>
add    $0x1,%r12d
mov    0x8(%rsp),%eax
add    0xc(%rsp),%eax
mov    %eax,0x8(%rsp)
cmp    0x14(%rsp),%r12d
je     11fa <dumpbitmap+0xca>
cmpl   $0x0,0x10(%rsp)
jle    1190 <dumpbitmap+0x60>
mov    0x8(%rsp),%ebp
mov    0x10(%rsp),%r14d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <checkbit@plt>
test   %rax,%rax
mov    0x0(%r13),%esi
mov    $0x58,%edi
cmove  %r15d,%edi
call   1030 <putc@plt>
add    $0x1,%ebp
add    $0xffffffff,%r14d
jne    11d0 <dumpbitmap+0xa0>
jmp    1190 <dumpbitmap+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"height=%d, width=%d, rwid=%d\0A\00"
define void @dumpbitmap(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 %3)
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %30
8: ; preds = %4
%9 = icmp sgt i32 %2, 0
%10 = shl i32 %3, 3
br label %11
11: ; preds = %8, %25
%12 = phi i32 [ 0, %8 ], [ %28, %25 ]
br i1 %9, label %13, label %25
13: ; preds = %11
%14 = mul i32 %10, %12
br label %15
15: ; preds = %13, %15
%16 = phi i32 [ 0, %13 ], [ %23, %15 ]
%17 = add nsw i32 %16, %14
%18 = tail call i64 @checkbit(i8* %0, i32 %17)
%19 = icmp eq i64 %18, 0
%20 = load i32, i32* @stderr
%21 = select i1 %19, i8 46, i8 88
%22 = tail call i32 @putc(i8 signext %21, i32 %20)
%23 = add nuw nsw i32 %16, 1
%24 = icmp eq i32 %23, %2
br i1 %24, label %25, label %15
25: ; preds = %15, %11
%26 = load i32, i32* @stderr
%27 = tail call i32 @putc(i8 signext 10, i32 %26)
%28 = add nuw nsw i32 %12, 1
%29 = icmp eq i32 %28, %1
br i1 %29, label %30, label %11
30: ; preds = %25, %4
ret void
}