#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*/ lcd_draw_line(unsigned int, unsigned int, unsigned int,
                                 unsigned int, int);
int /*<<< orphan*/ lcd_write_index_register(int);
int /*<<< orphan*/ lcd_write_wdr(int);
void lcd_draw_rectangle(unsigned int x0, unsigned int y0, unsigned int x1,
                        unsigned int y1, char fill, int color) {
  if (fill) {
    unsigned int counter_x;
    unsigned char counter_y;
    lcd_write_index_register(0x20);
    lcd_write_wdr(x0);
    lcd_write_index_register(0x21);
    lcd_write_wdr(y0);
    lcd_write_index_register(0x50);
    lcd_write_wdr(x0);
    lcd_write_index_register(0x51);
    lcd_write_wdr(x1);
    lcd_write_index_register(0x52);
    lcd_write_wdr(239 - y1);
    lcd_write_index_register(0x53);
    lcd_write_wdr(239 - y0);
    lcd_write_index_register(0x22);
    for (counter_y = y0; counter_y <= y1; counter_y++) {
      for (counter_x = x0; counter_x <= x1; counter_x++)
        lcd_write_wdr(color);
    }
  } else {
    lcd_draw_line(x0, y0, x1, y0, color);
    lcd_draw_line(x1, y0, x1, y1, color);
    lcd_draw_line(x1, y1, x0, y1, color);
    lcd_draw_line(x0, y1, x0, y0, color);
  }
}


x86 assembly (clang, -O0):
<lcd_draw_rectangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %r8b,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %r9d,-0x18(%rbp)
cmpb   $0x0,-0x11(%rbp)
je     122a <lcd_draw_rectangle+0xfa>
mov    $0x20,%edi
call   1030 <lcd_write_index_register@plt>
mov    -0x4(%rbp),%edi
call   1040 <lcd_write_wdr@plt>
mov    $0x21,%edi
call   1030 <lcd_write_index_register@plt>
mov    -0x8(%rbp),%edi
call   1040 <lcd_write_wdr@plt>
mov    $0x50,%edi
call   1030 <lcd_write_index_register@plt>
mov    -0x4(%rbp),%edi
call   1040 <lcd_write_wdr@plt>
mov    $0x51,%edi
call   1030 <lcd_write_index_register@plt>
mov    -0xc(%rbp),%edi
call   1040 <lcd_write_wdr@plt>
mov    $0x52,%edi
call   1030 <lcd_write_index_register@plt>
mov    $0xef,%edi
sub    -0x10(%rbp),%edi
call   1040 <lcd_write_wdr@plt>
mov    $0x53,%edi
call   1030 <lcd_write_index_register@plt>
mov    $0xef,%edi
sub    -0x8(%rbp),%edi
call   1040 <lcd_write_wdr@plt>
mov    $0x22,%edi
call   1030 <lcd_write_index_register@plt>
mov    -0x8(%rbp),%eax
mov    %al,-0x1d(%rbp)
movzbl -0x1d(%rbp),%eax
cmp    -0x10(%rbp),%eax
ja     1225 <lcd_draw_rectangle+0xf5>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
ja     1213 <lcd_draw_rectangle+0xe3>
mov    -0x18(%rbp),%edi
call   1040 <lcd_write_wdr@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f1 <lcd_draw_rectangle+0xc1>
jmp    1218 <lcd_draw_rectangle+0xe8>
mov    -0x1d(%rbp),%al
add    $0x1,%al
mov    %al,-0x1d(%rbp)
jmp    11de <lcd_draw_rectangle+0xae>
jmp    127e <lcd_draw_rectangle+0x14e>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1050 <lcd_draw_line@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1050 <lcd_draw_line@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1050 <lcd_draw_line@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1050 <lcd_draw_line@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_draw_rectangle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r13d
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%r12d
mov    %edi,%r15d
test   %r8b,%r8b
je     1220 <lcd_draw_rectangle+0xf0>
mov    $0x20,%edi
call   1030 <lcd_write_index_register@plt>
mov    %r15d,%edi
call   1040 <lcd_write_wdr@plt>
mov    $0x21,%edi
call   1030 <lcd_write_index_register@plt>
mov    %r12d,%edi
call   1040 <lcd_write_wdr@plt>
mov    $0x50,%edi
call   1030 <lcd_write_index_register@plt>
mov    %r15d,%edi
call   1040 <lcd_write_wdr@plt>
mov    $0x51,%edi
call   1030 <lcd_write_index_register@plt>
mov    %ebp,%edi
call   1040 <lcd_write_wdr@plt>
mov    $0x52,%edi
call   1030 <lcd_write_index_register@plt>
mov    $0xef,%ebx
mov    $0xef,%edi
sub    %r14d,%edi
call   1040 <lcd_write_wdr@plt>
mov    $0x53,%edi
call   1030 <lcd_write_index_register@plt>
sub    %r12d,%ebx
mov    %ebx,%edi
call   1040 <lcd_write_wdr@plt>
mov    $0x22,%edi
call   1030 <lcd_write_index_register@plt>
jmp    11e4 <lcd_draw_rectangle+0xb4>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r12b
movzbl %r12b,%eax
cmp    %r14d,%eax
ja     1211 <lcd_draw_rectangle+0xe1>
cmp    %ebp,%r15d
ja     11e0 <lcd_draw_rectangle+0xb0>
mov    %r15d,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13d,%edi
call   1040 <lcd_write_wdr@plt>
add    $0x1,%ebx
cmp    %ebp,%ebx
jbe    1200 <lcd_draw_rectangle+0xd0>
jmp    11e0 <lcd_draw_rectangle+0xb0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15d,%edi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
mov    %r13d,%r8d
call   1050 <lcd_draw_line@plt>
mov    %ebp,%edi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
mov    %r13d,%r8d
call   1050 <lcd_draw_line@plt>
mov    %ebp,%edi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
mov    %r13d,%r8d
call   1050 <lcd_draw_line@plt>
mov    %r15d,%edi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %r12d,%ecx
mov    %r13d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <lcd_draw_line@plt>

LLVM IR (-O0):
define void @lcd_draw_rectangle(i32 %0, i32 %1, i32 %2, i32 %3, i8 signext %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i8 %4, i8* %11
store i32 %5, i32* %12
%15 = load i8, i8* %11
%16 = icmp ne i8 %15, 0
br i1 %16, label %17, label %63
17: ; preds = %6
%18 = call i32 @lcd_write_index_register(i32 32)
%19 = load i32, i32* %7
%20 = call i32 @lcd_write_wdr(i32 %19)
%21 = call i32 @lcd_write_index_register(i32 33)
%22 = load i32, i32* %8
%23 = call i32 @lcd_write_wdr(i32 %22)
%24 = call i32 @lcd_write_index_register(i32 80)
%25 = load i32, i32* %7
%26 = call i32 @lcd_write_wdr(i32 %25)
%27 = call i32 @lcd_write_index_register(i32 81)
%28 = load i32, i32* %9
%29 = call i32 @lcd_write_wdr(i32 %28)
%30 = call i32 @lcd_write_index_register(i32 82)
%31 = load i32, i32* %10
%32 = sub i32 239, %31
%33 = call i32 @lcd_write_wdr(i32 %32)
%34 = call i32 @lcd_write_index_register(i32 83)
%35 = load i32, i32* %8
%36 = sub i32 239, %35
%37 = call i32 @lcd_write_wdr(i32 %36)
%38 = call i32 @lcd_write_index_register(i32 34)
%39 = load i32, i32* %8
%40 = trunc i32 %39 to i8
store i8 %40, i8* %14
br label %41
41: ; preds = %59, %17
%42 = load i8, i8* %14
%43 = zext i8 %42 to i32
%44 = load i32, i32* %10
%45 = icmp ule i32 %43, %44
br i1 %45, label %46, label %62
46: ; preds = %41
%47 = load i32, i32* %7
store i32 %47, i32* %13
br label %48
48: ; preds = %55, %46
%49 = load i32, i32* %13
%50 = load i32, i32* %9
%51 = icmp ule i32 %49, %50
br i1 %51, label %52, label %58
52: ; preds = %48
%53 = load i32, i32* %12
%54 = call i32 @lcd_write_wdr(i32 %53)
br label %55
55: ; preds = %52
%56 = load i32, i32* %13
%57 = add i32 %56, 1
store i32 %57, i32* %13
br label %48
58: ; preds = %48
br label %59
59: ; preds = %58
%60 = load i8, i8* %14
%61 = add i8 %60, 1
store i8 %61, i8* %14
br label %41
62: ; preds = %41
br label %88
63: ; preds = %6
%64 = load i32, i32* %7
%65 = load i32, i32* %8
%66 = load i32, i32* %9
%67 = load i32, i32* %8
%68 = load i32, i32* %12
%69 = call i32 @lcd_draw_line(i32 %64, i32 %65, i32 %66, i32 %67, i32 %68)
%70 = load i32, i32* %9
%71 = load i32, i32* %8
%72 = load i32, i32* %9
%73 = load i32, i32* %10
%74 = load i32, i32* %12
%75 = call i32 @lcd_draw_line(i32 %70, i32 %71, i32 %72, i32 %73, i32 %74)
%76 = load i32, i32* %9
%77 = load i32, i32* %10
%78 = load i32, i32* %7
%79 = load i32, i32* %10
%80 = load i32, i32* %12
%81 = call i32 @lcd_draw_line(i32 %76, i32 %77, i32 %78, i32 %79, i32 %80)
%82 = load i32, i32* %7
%83 = load i32, i32* %10
%84 = load i32, i32* %7
%85 = load i32, i32* %8
%86 = load i32, i32* %12
%87 = call i32 @lcd_draw_line(i32 %82, i32 %83, i32 %84, i32 %85, i32 %86)
br label %88
88: ; preds = %63, %62
ret void
}

LLVM IR (-O2):
define void @lcd_draw_rectangle(i32 %0, i32 %1, i32 %2, i32 %3, i8 signext %4, i32 %5) {
%7 = icmp eq i8 %4, 0
br i1 %7, label %40, label %8
8: ; preds = %6
%9 = tail call i32 @lcd_write_index_register(i32 32)
%10 = tail call i32 @lcd_write_wdr(i32 %0)
%11 = tail call i32 @lcd_write_index_register(i32 33)
%12 = tail call i32 @lcd_write_wdr(i32 %1)
%13 = tail call i32 @lcd_write_index_register(i32 80)
%14 = tail call i32 @lcd_write_wdr(i32 %0)
%15 = tail call i32 @lcd_write_index_register(i32 81)
%16 = tail call i32 @lcd_write_wdr(i32 %2)
%17 = tail call i32 @lcd_write_index_register(i32 82)
%18 = sub i32 239, %3
%19 = tail call i32 @lcd_write_wdr(i32 %18)
%20 = tail call i32 @lcd_write_index_register(i32 83)
%21 = sub i32 239, %1
%22 = tail call i32 @lcd_write_wdr(i32 %21)
%23 = tail call i32 @lcd_write_index_register(i32 34)
%24 = and i32 %1, 255
%25 = icmp ugt i32 %24, %3
br i1 %25, label %45, label %26
26: ; preds = %8
%27 = trunc i32 %1 to i8
%28 = icmp ugt i32 %0, %2
br label %29
29: ; preds = %26, %36
%30 = phi i8 [ %27, %26 ], [ %37, %36 ]
br i1 %28, label %36, label %31
31: ; preds = %29, %31
%32 = phi i32 [ %34, %31 ], [ %0, %29 ]
%33 = tail call i32 @lcd_write_wdr(i32 %5)
%34 = add i32 %32, 1
%35 = icmp ugt i32 %34, %2
br i1 %35, label %36, label %31
36: ; preds = %31, %29
%37 = add i8 %30, 1
%38 = zext i8 %37 to i32
%39 = icmp ugt i32 %38, %3
br i1 %39, label %45, label %29
40: ; preds = %6
%41 = tail call i32 @lcd_draw_line(i32 %0, i32 %1, i32 %2, i32 %1, i32 %5)
%42 = tail call i32 @lcd_draw_line(i32 %2, i32 %1, i32 %2, i32 %3, i32 %5)
%43 = tail call i32 @lcd_draw_line(i32 %2, i32 %3, i32 %0, i32 %3, i32 %5)
%44 = tail call i32 @lcd_draw_line(i32 %0, i32 %3, i32 %0, i32 %1, i32 %5)
br label %45
45: ; preds = %36, %8, %40
ret void
}