#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*/ OLED_SetPos(unsigned char, unsigned char);
int /*<<< orphan*/ WriteDat(unsigned char);
void OLED_DrawBMP(unsigned char x0, unsigned char y0, unsigned char x1,
                  unsigned char y1, unsigned char BMP[]) {
  unsigned int j = 0;
  unsigned char x, y;
  if (y1 % 8 == 0)
    y = y1 / 8;
  else
    y = y1 / 8 + 1;
  for (y = y0; y < y1; y++) {
    OLED_SetPos(x0, y);
    for (x = x0; x < x1; x++) {
      WriteDat(BMP[j++]);
    }
  }
}


x86 assembly (clang, -O0):
<OLED_DrawBMP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dl,-0x2(%rbp)
mov    %cl,-0x3(%rbp)
mov    %al,-0x4(%rbp)
mov    %r8,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movzbl -0x4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1173 <OLED_DrawBMP+0x53>
movzbl -0x4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %al,-0x16(%rbp)
jmp    1185 <OLED_DrawBMP+0x65>
movzbl -0x4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %al,-0x16(%rbp)
mov    -0x2(%rbp),%al
mov    %al,-0x16(%rbp)
movzbl -0x16(%rbp),%eax
movzbl -0x4(%rbp),%ecx
cmp    %ecx,%eax
jge    11f9 <OLED_DrawBMP+0xd9>
mov    -0x1(%rbp),%al
movzbl %al,%edi
movzbl -0x16(%rbp),%esi
call   1040 <OLED_SetPos@plt>
mov    -0x1(%rbp),%al
mov    %al,-0x15(%rbp)
movzbl -0x15(%rbp),%eax
movzbl -0x3(%rbp),%ecx
cmp    %ecx,%eax
jge    11e7 <OLED_DrawBMP+0xc7>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%edi
call   1030 <WriteDat@plt>
mov    -0x15(%rbp),%al
add    $0x1,%al
mov    %al,-0x15(%rbp)
jmp    11b0 <OLED_DrawBMP+0x90>
jmp    11ec <OLED_DrawBMP+0xcc>
mov    -0x16(%rbp),%al
add    $0x1,%al
mov    %al,-0x16(%rbp)
jmp    118b <OLED_DrawBMP+0x6b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OLED_DrawBMP>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,0x4(%rsp)
mov    %esi,%ebp
cmp    %r15b,%bpl
jae    1198 <OLED_DrawBMP+0x78>
mov    %r8,%rbx
mov    0x4(%rsp),%eax
sub    %dil,%al
mov    %al,0x3(%rsp)
xor    %r13d,%r13d
movzbl %dil,%r12d
jmp    1159 <OLED_DrawBMP+0x39>
add    $0x1,%bpl
cmp    %r15b,%bpl
je     1198 <OLED_DrawBMP+0x78>
movzbl %bpl,%esi
mov    %r12d,%edi
call   1040 <OLED_SetPos@plt>
cmp    %r12b,0x4(%rsp)
jbe    1150 <OLED_DrawBMP+0x30>
mov    0x3(%rsp),%r14b
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13d,%eax
add    $0x1,%r13d
movzbl (%rbx,%rax,1),%edi
call   1030 <WriteDat@plt>
add    $0xff,%r14b
jne    1180 <OLED_DrawBMP+0x60>
jmp    1150 <OLED_DrawBMP+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @OLED_DrawBMP(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i8* nocapture %4) {
%6 = icmp ult i8 %1, %3
br i1 %6, label %7, label %30
7: ; preds = %5
%8 = icmp ugt i8 %2, %0
%9 = sub i8 %2, %0
br label %10
10: ; preds = %7, %26
%11 = phi i8 [ %1, %7 ], [ %28, %26 ]
%12 = phi i32 [ 0, %7 ], [ %27, %26 ]
%13 = tail call i32 @OLED_SetPos(i8 zeroext %0, i8 zeroext %11)
br i1 %8, label %14, label %26
14: ; preds = %10
%15 = trunc i32 %12 to i8
%16 = add i8 %9, %15
br label %17
17: ; preds = %14, %17
%18 = phi i32 [ %19, %17 ], [ %12, %14 ]
%19 = add i32 %18, 1
%20 = zext i32 %18 to i64
%21 = getelementptr inbounds i8, i8* %4, i64 %20
%22 = load i8, i8* %21
%23 = tail call i32 @WriteDat(i8 zeroext %22)
%24 = trunc i32 %19 to i8
%25 = icmp eq i8 %16, %24
br i1 %25, label %26, label %17
26: ; preds = %17, %10
%27 = phi i32 [ %12, %10 ], [ %19, %17 ]
%28 = add nuw i8 %11, 1
%29 = icmp eq i8 %28, %3
br i1 %29, label %30, label %10
30: ; preds = %26, %5
ret void
}