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

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
void p_bitmap(FILE *p, unsigned int h, int w, unsigned long buflen,
              unsigned char *buf) {
  {
    fprintf(p, "\033[C");
    {
      (void)putc(((9) & 0xFF), (p));
      (void)putc((((9) & 0xFF00) >> 8), (p));
    };
  };
  (void)fwrite("\365\0", 1, 2, p);
  {
    (void)putc(((((h)) & 0xFF00) >> 8), (p));
    (void)putc((((h)) & 0xFF), (p));
  };
  {
    (void)putc(((((w)) & 0xFF00) >> 8), (p));
    (void)putc((((w)) & 0xFF), (p));
  };
  {
    (void)putc(((((buflen)) & 0xFF0000) >> 16), (p));
    (void)putc(((((buflen)) & 0xFF00) >> 8), (p));
    (void)putc((((buflen)) & 0xFF), (p));
  };
  while (buflen) {
    int len;
    len = ((buflen) < (65535) ? (buflen) : (65535));
    {
      fprintf(p, "\033[C");
      {
        (void)putc(((len)&0xFF), (p));
        (void)putc((((len)&0xFF00) >> 8), (p));
      };
    };
    (void)fwrite((char *)buf, 1, len, p);
    buf += len;
    buflen -= len;
  }
  (void)fflush(p);
}


x86 assembly (clang, -O0):
<p_bitmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rsi
mov    $0x9,%edi
call   1030 <putc@plt>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1030 <putc@plt>
mov    -0x8(%rbp),%rcx
lea    0xe76(%rip),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1060 <fwrite@plt>
mov    -0xc(%rbp),%edi
and    $0xff00,%edi
shr    $0x8,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0xc(%rbp),%edi
and    $0xff,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x10(%rbp),%edi
and    $0xff00,%edi
sar    $0x8,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x10(%rbp),%edi
and    $0xff,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x18(%rbp),%rax
and    $0xff0000,%rax
shr    $0x10,%rax
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x18(%rbp),%rax
and    $0xff00,%rax
shr    $0x8,%rax
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x18(%rbp),%rax
and    $0xff,%rax
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
cmpq   $0x0,-0x18(%rbp)
je     12de <p_bitmap+0x19e>
cmpq   $0xffff,-0x18(%rbp)
jae    1258 <p_bitmap+0x118>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1266 <p_bitmap+0x126>
mov    $0xffff,%eax
mov    %rax,-0x30(%rbp)
jmp    1266 <p_bitmap+0x126>
mov    -0x30(%rbp),%rax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xd88(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x24(%rbp),%edi
and    $0xff,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x24(%rbp),%edi
and    $0xff00,%edi
sar    $0x8,%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
call   1060 <fwrite@plt>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
movslq -0x24(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    1232 <p_bitmap+0xf2>
mov    -0x8(%rbp),%rdi
call   1050 <fflush@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<p_bitmap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r12
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,%r15
lea    0xeb1(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1050 <fwrite@plt>
mov    $0x9,%edi
mov    %r15,%rsi
call   1030 <putc@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1030 <putc@plt>
lea    0xe85(%rip),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    %r15,%rcx
call   1050 <fwrite@plt>
movzbl %bh,%edi
mov    %r15,%rsi
call   1030 <putc@plt>
movzbl %bl,%edi
mov    %r15,%rsi
call   1030 <putc@plt>
mov    %ebp,%ebx
movzbl %bh,%edi
mov    %r15,%rsi
call   1030 <putc@plt>
movzbl %bl,%edi
mov    %r15,%rsi
call   1030 <putc@plt>
mov    %r12,%rbx
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%edi
mov    %r15,%rsi
call   1030 <putc@plt>
movzbl %bh,%edi
mov    %r15,%rsi
call   1030 <putc@plt>
movzbl %bl,%edi
mov    %r15,%rsi
call   1030 <putc@plt>
test   %r12,%r12
je     125c <p_bitmap+0x12c>
mov    %r12,%rax
lea    0xe09(%rip),%r12
nopw   0x0(%rax,%rax,1)
cmp    $0xffff,%rax
mov    $0xffff,%ebx
cmovb  %rax,%rbx
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r12,%rdi
mov    %rax,%r13
mov    %r15,%rcx
call   1050 <fwrite@plt>
movzbl %bl,%edi
mov    %r15,%rsi
call   1030 <putc@plt>
mov    %ebx,%edi
shr    $0x8,%edi
mov    %r15,%rsi
call   1030 <putc@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %r15,%rcx
call   1050 <fwrite@plt>
mov    %r13,%rax
add    %rbx,%r14
sub    %rbx,%rax
jne    1200 <p_bitmap+0xd0>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"\1B[C\00"
@.str.1 = [3 x i8] c"\F5\00\00"
define void @p_bitmap(i32* %0, i32 %1, i32 %2, i64 %3, i8* %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i64 %3, i64* %9
store i8* %4, i8** %10
%12 = load i32*, i32** %6
%13 = call i32 @fprintf(i32* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%14 = load i32*, i32** %6
%15 = call i32 @putc(i32 9, i32* %14)
%16 = load i32*, i32** %6
%17 = call i32 @putc(i32 0, i32* %16)
%18 = load i32*, i32** %6
%19 = call i32 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 2, i32* %18)
%20 = load i32, i32* %7
%21 = and i32 %20, 65280
%22 = lshr i32 %21, 8
%23 = load i32*, i32** %6
%24 = call i32 @putc(i32 %22, i32* %23)
%25 = load i32, i32* %7
%26 = and i32 %25, 255
%27 = load i32*, i32** %6
%28 = call i32 @putc(i32 %26, i32* %27)
%29 = load i32, i32* %8
%30 = and i32 %29, 65280
%31 = ashr i32 %30, 8
%32 = load i32*, i32** %6
%33 = call i32 @putc(i32 %31, i32* %32)
%34 = load i32, i32* %8
%35 = and i32 %34, 255
%36 = load i32*, i32** %6
%37 = call i32 @putc(i32 %35, i32* %36)
%38 = load i64, i64* %9
%39 = and i64 %38, 16711680
%40 = lshr i64 %39, 16
%41 = trunc i64 %40 to i32
%42 = load i32*, i32** %6
%43 = call i32 @putc(i32 %41, i32* %42)
%44 = load i64, i64* %9
%45 = and i64 %44, 65280
%46 = lshr i64 %45, 8
%47 = trunc i64 %46 to i32
%48 = load i32*, i32** %6
%49 = call i32 @putc(i32 %47, i32* %48)
%50 = load i64, i64* %9
%51 = and i64 %50, 255
%52 = trunc i64 %51 to i32
%53 = load i32*, i32** %6
%54 = call i32 @putc(i32 %52, i32* %53)
br label %55
55: ; preds = %64, %5
%56 = load i64, i64* %9
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %90
58: ; preds = %55
%59 = load i64, i64* %9
%60 = icmp ult i64 %59, 65535
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = load i64, i64* %9
br label %64
63: ; preds = %58
br label %64
64: ; preds = %63, %61
%65 = phi i64 [ %62, %61 ], [ 65535, %63 ]
%66 = trunc i64 %65 to i32
store i32 %66, i32* %11
%67 = load i32*, i32** %6
%68 = call i32 @fprintf(i32* %67, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%69 = load i32, i32* %11
%70 = and i32 %69, 255
%71 = load i32*, i32** %6
%72 = call i32 @putc(i32 %70, i32* %71)
%73 = load i32, i32* %11
%74 = and i32 %73, 65280
%75 = ashr i32 %74, 8
%76 = load i32*, i32** %6
%77 = call i32 @putc(i32 %75, i32* %76)
%78 = load i8*, i8** %10
%79 = load i32, i32* %11
%80 = load i32*, i32** %6
%81 = call i32 @fwrite(i8* %78, i32 1, i32 %79, i32* %80)
%82 = load i32, i32* %11
%83 = load i8*, i8** %10
%84 = sext i32 %82 to i64
%85 = getelementptr inbounds i8, i8* %83, i64 %84
store i8* %85, i8** %10
%86 = load i32, i32* %11
%87 = sext i32 %86 to i64
%88 = load i64, i64* %9
%89 = sub i64 %88, %87
store i64 %89, i64* %9
br label %55
90: ; preds = %55
%91 = load i32*, i32** %6
%92 = call i32 @fflush(i32* %91)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"\1B[C\00"
@.str.1 = [3 x i8] c"\F5\00\00"
define void @p_bitmap(i32* %0, i32 %1, i32 %2, i64 %3, i8* nocapture %4) {
%6 = tail call i64 bitcast (i32 (i8*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 3, i64 1, i32* %0)
%7 = tail call i32 @putc(i32 9, i32* %0)
%8 = tail call i32 @putc(i32 0, i32* %0)
%9 = tail call i32 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 2, i32* %0)
%10 = lshr i32 %1, 8
%11 = and i32 %10, 255
%12 = tail call i32 @putc(i32 %11, i32* %0)
%13 = and i32 %1, 255
%14 = tail call i32 @putc(i32 %13, i32* %0)
%15 = lshr i32 %2, 8
%16 = and i32 %15, 255
%17 = tail call i32 @putc(i32 %16, i32* %0)
%18 = and i32 %2, 255
%19 = tail call i32 @putc(i32 %18, i32* %0)
%20 = trunc i64 %3 to i32
%21 = lshr i32 %20, 16
%22 = and i32 %21, 255
%23 = tail call i32 @putc(i32 %22, i32* %0)
%24 = lshr i32 %20, 8
%25 = and i32 %24, 255
%26 = tail call i32 @putc(i32 %25, i32* %0)
%27 = and i32 %20, 255
%28 = tail call i32 @putc(i32 %27, i32* %0)
%29 = icmp eq i64 %3, 0
br i1 %29, label %45, label %30
30: ; preds = %5, %30
%31 = phi i64 [ %43, %30 ], [ %3, %5 ]
%32 = phi i8* [ %42, %30 ], [ %4, %5 ]
%33 = icmp ult i64 %31, 65535
%34 = select i1 %33, i64 %31, i64 65535
%35 = trunc i64 %34 to i32
%36 = tail call i64 bitcast (i32 (i8*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 3, i64 1, i32* %0)
%37 = and i32 %35, 255
%38 = tail call i32 @putc(i32 %37, i32* %0)
%39 = lshr i32 %35, 8
%40 = tail call i32 @putc(i32 %39, i32* %0)
%41 = tail call i32 @fwrite(i8* %32, i32 1, i32 %35, i32* %0)
%42 = getelementptr inbounds i8, i8* %32, i64 %34
%43 = sub i64 %31, %34
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %30
45: ; preds = %30, %5
%46 = tail call i32 @fflush(i32* %0)
ret void
}