#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*/ GLCD_SetWindow(unsigned int, unsigned int, unsigned int,
                                  unsigned int);
int /*<<< orphan*/ wr_cmd(int);
int /*<<< orphan*/ wr_dat_only(unsigned short);
int /*<<< orphan*/ wr_dat_start();
int /*<<< orphan*/ wr_dat_stop();
void GLCD_Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,
                 unsigned char *bitmap) {
  int i, j;
  unsigned short *bitmap_ptr = (unsigned short *)bitmap;
  GLCD_SetWindow(x, y, w, h);
  wr_cmd(0x22);
  wr_dat_start();
  for (i = (h - 1) * w; i > -1; i -= w) {
    for (j = 0; j < w; j++) {
      wr_dat_only(bitmap_ptr[i + j]);
    }
  }
  wr_dat_stop();
}


x86 assembly (clang, -O0):
<GLCD_Bitmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1040 <GLCD_SetWindow@plt>
mov    $0x22,%edi
call   1060 <wr_cmd@plt>
mov    $0x0,%al
call   1050 <wr_dat_start@plt>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jle    11f5 <GLCD_Bitmap+0xa5>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11e0 <GLCD_Bitmap+0x90>
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movzwl (%rax,%rcx,2),%edi
call   1030 <wr_dat_only@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b0 <GLCD_Bitmap+0x60>
jmp    11e5 <GLCD_Bitmap+0x95>
mov    -0xc(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
jmp    119f <GLCD_Bitmap+0x4f>
mov    $0x0,%al
call   1070 <wr_dat_stop@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GLCD_Bitmap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %ecx,%r12d
mov    %edx,%r15d
call   1040 <GLCD_SetWindow@plt>
mov    $0x22,%edi
call   1060 <wr_cmd@plt>
xor    %eax,%eax
call   1050 <wr_dat_start@plt>
add    $0xffffffff,%r12d
imul   %r15d,%r12d
test   %r12d,%r12d
js     11c5 <GLCD_Bitmap+0x75>
mov    %r15d,%r13d
jmp    1195 <GLCD_Bitmap+0x45>
nopl   0x0(%rax)
sub    %r15d,%r12d
js     11c5 <GLCD_Bitmap+0x75>
test   %r15d,%r15d
je     1190 <GLCD_Bitmap+0x40>
mov    %r12d,%eax
lea    (%r14,%rax,2),%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzwl 0x0(%rbp,%rbx,2),%edi
call   1030 <wr_dat_only@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11b0 <GLCD_Bitmap+0x60>
jmp    1190 <GLCD_Bitmap+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <wr_dat_stop@plt>

LLVM IR (-O0):
define void @GLCD_Bitmap(i32 %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i16*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%14 = load i8*, i8** %10
%15 = bitcast i8* %14 to i16*
store i16* %15, i16** %13
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = load i32, i32* %9
%20 = call i32 @GLCD_SetWindow(i32 %16, i32 %17, i32 %18, i32 %19)
%21 = call i32 @wr_cmd(i32 34)
%22 = call i32 (...) @wr_dat_start()
%23 = load i32, i32* %9
%24 = sub i32 %23, 1
%25 = load i32, i32* %8
%26 = mul i32 %24, %25
store i32 %26, i32* %11
br label %27
27: ; preds = %48, %5
%28 = load i32, i32* %11
%29 = icmp sgt i32 %28, -1
br i1 %29, label %30, label %52
30: ; preds = %27
store i32 0, i32* %12
br label %31
31: ; preds = %44, %30
%32 = load i32, i32* %12
%33 = load i32, i32* %8
%34 = icmp ult i32 %32, %33
br i1 %34, label %35, label %47
35: ; preds = %31
%36 = load i16*, i16** %13
%37 = load i32, i32* %11
%38 = load i32, i32* %12
%39 = add nsw i32 %37, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i16, i16* %36, i64 %40
%42 = load i16, i16* %41
%43 = call i32 @wr_dat_only(i16 zeroext %42)
br label %44
44: ; preds = %35
%45 = load i32, i32* %12
%46 = add nsw i32 %45, 1
store i32 %46, i32* %12
br label %31
47: ; preds = %31
br label %48
48: ; preds = %47
%49 = load i32, i32* %8
%50 = load i32, i32* %11
%51 = sub i32 %50, %49
store i32 %51, i32* %11
br label %27
52: ; preds = %27
%53 = call i32 (...) @wr_dat_stop()
ret void
}

LLVM IR (-O2):
define void @GLCD_Bitmap(i32 %0, i32 %1, i32 %2, i32 %3, i8* nocapture %4) {
%6 = bitcast i8* %4 to i16*
%7 = tail call i32 @GLCD_SetWindow(i32 %0, i32 %1, i32 %2, i32 %3)
%8 = tail call i32 @wr_cmd(i32 34)
%9 = tail call i32 (...) @wr_dat_start()
%10 = add i32 %3, -1
%11 = mul i32 %10, %2
%12 = icmp sgt i32 %11, -1
br i1 %12, label %13, label %31
13: ; preds = %5
%14 = icmp eq i32 %2, 0
%15 = zext i32 %2 to i64
br label %16
16: ; preds = %13, %28
%17 = phi i32 [ %11, %13 ], [ %29, %28 ]
br i1 %14, label %28, label %18
18: ; preds = %16
%19 = zext i32 %17 to i64
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ 0, %18 ], [ %26, %20 ]
%22 = add nuw nsw i64 %21, %19
%23 = getelementptr inbounds i16, i16* %6, i64 %22
%24 = load i16, i16* %23
%25 = tail call i32 @wr_dat_only(i16 zeroext %24)
%26 = add nuw nsw i64 %21, 1
%27 = icmp eq i64 %26, %15
br i1 %27, label %28, label %20
28: ; preds = %20, %16
%29 = sub i32 %17, %2
%30 = icmp sgt i32 %29, -1
br i1 %30, label %16, label %31
31: ; preds = %28, %5
%32 = tail call i32 (...) @wr_dat_stop()
ret void
}