#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*/ OSRAMWriteArray(unsigned char const *, unsigned long);
int /*<<< orphan*/ OSRAMWriteByte(int);
int /*<<< orphan*/ OSRAMWriteFinal(unsigned char const);
int /*<<< orphan*/ OSRAMWriteFirst(int);
void OSRAMImageDraw(const unsigned char *pucImage, unsigned long ulX,
                    unsigned long ulY, unsigned long ulWidth,
                    unsigned long ulHeight) {
  ;
  ;
  ;
  ;
  ulX += 36;
  while (ulHeight--) {
    OSRAMWriteFirst(0x80);
    OSRAMWriteByte((ulY == 0) ? 0xb0 : 0xb1);
    OSRAMWriteByte(0x80);
    OSRAMWriteByte(ulX & 0x0f);
    OSRAMWriteByte(0x80);
    OSRAMWriteByte(0x10 | ((ulX >> 4) & 0x0f));
    OSRAMWriteByte(0x40);
    OSRAMWriteArray(pucImage, ulWidth - 1);
    OSRAMWriteFinal(pucImage[ulWidth - 1]);
    pucImage += ulWidth;
    ulY++;
  }
}


x86 assembly (clang, -O0):
<OSRAMImageDraw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x10(%rbp),%rax
add    $0x24,%rax
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x28(%rbp)
cmp    $0x0,%rax
je     122c <OSRAMImageDraw+0xec>
mov    $0x80,%edi
call   1060 <OSRAMWriteFirst@plt>
mov    -0x18(%rbp),%rcx
mov    $0xb1,%edi
mov    $0xb0,%eax
cmp    $0x0,%rcx
cmove  %eax,%edi
call   1050 <OSRAMWriteByte@plt>
mov    $0x80,%edi
call   1050 <OSRAMWriteByte@plt>
mov    -0x10(%rbp),%rax
and    $0xf,%rax
mov    %eax,%edi
call   1050 <OSRAMWriteByte@plt>
mov    $0x80,%edi
call   1050 <OSRAMWriteByte@plt>
mov    -0x10(%rbp),%rax
shr    $0x4,%rax
and    $0xf,%rax
or     $0x10,%rax
mov    %eax,%edi
call   1050 <OSRAMWriteByte@plt>
mov    $0x40,%edi
call   1050 <OSRAMWriteByte@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
sub    $0x1,%rsi
call   1030 <OSRAMWriteArray@plt>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movzbl (%rax,%rcx,1),%edi
call   1040 <OSRAMWriteFinal@plt>
mov    -0x20(%rbp),%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1168 <OSRAMImageDraw+0x28>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OSRAMImageDraw>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
test   %r8,%r8
je     1201 <OSRAMImageDraw+0xc1>
mov    %r8,%rbp
mov    %rcx,%r13
mov    %rsi,%r12
mov    %rdi,%rbx
add    $0x24,%r12d
mov    %r12d,%eax
and    $0xf,%eax
mov    %eax,0xc(%rsp)
shr    $0x4,%r12d
and    $0xf,%r12d
or     $0x10,%r12d
lea    -0x1(%rcx),%r14
negq   0x10(%rsp)
xor    %r15d,%r15d
xchg   %ax,%ax
mov    $0x80,%edi
call   1060 <OSRAMWriteFirst@plt>
xor    %edi,%edi
cmp    %r15,0x10(%rsp)
sete   %dil
xor    $0xb1,%edi
call   1050 <OSRAMWriteByte@plt>
mov    $0x80,%edi
call   1050 <OSRAMWriteByte@plt>
mov    0xc(%rsp),%edi
call   1050 <OSRAMWriteByte@plt>
mov    $0x80,%edi
call   1050 <OSRAMWriteByte@plt>
mov    %r12d,%edi
call   1050 <OSRAMWriteByte@plt>
mov    $0x40,%edi
call   1050 <OSRAMWriteByte@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <OSRAMWriteArray@plt>
movzbl -0x1(%rbx,%r13,1),%edi
add    %r13,%rbx
call   1040 <OSRAMWriteFinal@plt>
add    $0x1,%r15
cmp    %r15,%rbp
jne    1190 <OSRAMImageDraw+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @OSRAMImageDraw(i8* %0, i64 %1, i64 %2, i64 %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i8* %0, i8** %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store i64 %4, i64* %10
%11 = load i64, i64* %7
%12 = add i64 %11, 36
store i64 %12, i64* %7
br label %13
13: ; preds = %17, %5
%14 = load i64, i64* %10
%15 = add i64 %14, -1
store i64 %15, i64* %10
%16 = icmp ne i64 %14, 0
br i1 %16, label %17, label %52
17: ; preds = %13
%18 = call i32 @OSRAMWriteFirst(i32 128)
%19 = load i64, i64* %8
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 176, i32 177
%23 = call i32 @OSRAMWriteByte(i32 %22)
%24 = call i32 @OSRAMWriteByte(i32 128)
%25 = load i64, i64* %7
%26 = and i64 %25, 15
%27 = trunc i64 %26 to i32
%28 = call i32 @OSRAMWriteByte(i32 %27)
%29 = call i32 @OSRAMWriteByte(i32 128)
%30 = load i64, i64* %7
%31 = lshr i64 %30, 4
%32 = and i64 %31, 15
%33 = or i64 16, %32
%34 = trunc i64 %33 to i32
%35 = call i32 @OSRAMWriteByte(i32 %34)
%36 = call i32 @OSRAMWriteByte(i32 64)
%37 = load i8*, i8** %6
%38 = load i64, i64* %9
%39 = sub i64 %38, 1
%40 = call i32 @OSRAMWriteArray(i8* %37, i64 %39)
%41 = load i8*, i8** %6
%42 = load i64, i64* %9
%43 = sub i64 %42, 1
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = call i32 @OSRAMWriteFinal(i8 zeroext %45)
%47 = load i64, i64* %9
%48 = load i8*, i8** %6
%49 = getelementptr inbounds i8, i8* %48, i64 %47
store i8* %49, i8** %6
%50 = load i64, i64* %8
%51 = add i64 %50, 1
store i64 %51, i64* %8
br label %13
52: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @OSRAMImageDraw(i8* %0, i64 %1, i64 %2, i64 %3, i64 %4) {
%6 = icmp eq i64 %4, 0
br i1 %6, label %36, label %7
7: ; preds = %5
%8 = trunc i64 %1 to i32
%9 = add i32 %8, 36
%10 = and i32 %9, 15
%11 = lshr i32 %9, 4
%12 = and i32 %11, 15
%13 = or i32 %12, 16
%14 = add i64 %3, -1
br label %15
15: ; preds = %7, %15
%16 = phi i64 [ %4, %7 ], [ %19, %15 ]
%17 = phi i8* [ %0, %7 ], [ %33, %15 ]
%18 = phi i64 [ %2, %7 ], [ %34, %15 ]
%19 = add i64 %16, -1
%20 = tail call i32 @OSRAMWriteFirst(i32 128)
%21 = icmp eq i64 %18, 0
%22 = select i1 %21, i32 176, i32 177
%23 = tail call i32 @OSRAMWriteByte(i32 %22)
%24 = tail call i32 @OSRAMWriteByte(i32 128)
%25 = tail call i32 @OSRAMWriteByte(i32 %10)
%26 = tail call i32 @OSRAMWriteByte(i32 128)
%27 = tail call i32 @OSRAMWriteByte(i32 %13)
%28 = tail call i32 @OSRAMWriteByte(i32 64)
%29 = tail call i32 @OSRAMWriteArray(i8* %17, i64 %14)
%30 = getelementptr inbounds i8, i8* %17, i64 %14
%31 = load i8, i8* %30
%32 = tail call i32 @OSRAMWriteFinal(i8 zeroext %31)
%33 = getelementptr inbounds i8, i8* %17, i64 %3
%34 = add i64 %18, 1
%35 = icmp eq i64 %19, 0
br i1 %35, label %36, label %15
36: ; preds = %15, %5
ret void
}