#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*/ ks0108_putpixel(unsigned char, unsigned char, unsigned char);
void ks0108_rectangle(unsigned char x1, unsigned char y1, unsigned char x2,
                      unsigned char y2, unsigned char color) {
  unsigned char i;
  for (i = x1; i <= x2; i++) {
    ks0108_putpixel(i, y1, color);
    ks0108_putpixel(i, y2, color);
  }
  for (i = y1 + 1; i < y2; i++) {
    ks0108_putpixel(x1, i, color);
    ks0108_putpixel(x2, i, color);
  }
}


x86 assembly (clang, -O0):
<ks0108_rectangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %r8b,%al
mov    %dil,-0x1(%rbp)
mov    %sil,-0x2(%rbp)
mov    %dl,-0x3(%rbp)
mov    %cl,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    -0x1(%rbp),%al
mov    %al,-0x6(%rbp)
movzbl -0x6(%rbp),%eax
movzbl -0x3(%rbp),%ecx
cmp    %ecx,%eax
jg     1179 <ks0108_rectangle+0x69>
mov    -0x6(%rbp),%cl
mov    -0x2(%rbp),%al
movzbl %cl,%edi
movzbl %al,%esi
movzbl -0x5(%rbp),%edx
call   1030 <ks0108_putpixel@plt>
mov    -0x6(%rbp),%cl
mov    -0x4(%rbp),%al
movzbl %cl,%edi
movzbl %al,%esi
movzbl -0x5(%rbp),%edx
call   1030 <ks0108_putpixel@plt>
mov    -0x6(%rbp),%al
add    $0x1,%al
mov    %al,-0x6(%rbp)
jmp    1132 <ks0108_rectangle+0x22>
movzbl -0x2(%rbp),%eax
add    $0x1,%eax
mov    %al,-0x6(%rbp)
movzbl -0x6(%rbp),%eax
movzbl -0x4(%rbp),%ecx
cmp    %ecx,%eax
jge    11ca <ks0108_rectangle+0xba>
mov    -0x1(%rbp),%cl
mov    -0x6(%rbp),%al
movzbl %cl,%edi
movzbl %al,%esi
movzbl -0x5(%rbp),%edx
call   1030 <ks0108_putpixel@plt>
mov    -0x3(%rbp),%cl
mov    -0x6(%rbp),%al
movzbl %cl,%edi
movzbl %al,%esi
movzbl -0x5(%rbp),%edx
call   1030 <ks0108_putpixel@plt>
mov    -0x6(%rbp),%al
add    $0x1,%al
mov    %al,-0x6(%rbp)
jmp    1183 <ks0108_rectangle+0x73>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ks0108_rectangle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,0x10(%rsp)
mov    %ecx,0x14(%rsp)
mov    %edx,%r13d
mov    %esi,%ebp
mov    %edi,0xc(%rsp)
cmp    %r13b,%dil
ja     1178 <ks0108_rectangle+0x68>
movzbl %bpl,%ebx
movzbl 0x10(%rsp),%r14d
movzbl 0x14(%rsp),%r12d
mov    0xc(%rsp),%r15d
nopw   0x0(%rax,%rax,1)
movzbl %r15b,%r15d
mov    %r15d,%edi
mov    %ebx,%esi
mov    %r14d,%edx
call   1030 <ks0108_putpixel@plt>
mov    %r15d,%edi
mov    %r12d,%esi
mov    %r14d,%edx
call   1030 <ks0108_putpixel@plt>
add    $0x1,%r15b
cmp    %r13b,%r15b
jbe    1150 <ks0108_rectangle+0x40>
add    $0x1,%bpl
mov    0x14(%rsp),%r15d
cmp    %r15b,%bpl
jae    11c5 <ks0108_rectangle+0xb5>
movzbl 0xc(%rsp),%r14d
movzbl 0x10(%rsp),%ebx
movzbl %r13b,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
movzbl %bpl,%ebp
mov    %r14d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <ks0108_putpixel@plt>
mov    %r12d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <ks0108_putpixel@plt>
add    $0x1,%bpl
cmp    %bpl,%r15b
jne    11a0 <ks0108_rectangle+0x90>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ks0108_rectangle(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i8 zeroext %4) {
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = 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
%12 = load i8, i8* %6
store i8 %12, i8* %11
br label %13
13: ; preds = %28, %5
%14 = load i8, i8* %11
%15 = zext i8 %14 to i32
%16 = load i8, i8* %8
%17 = zext i8 %16 to i32
%18 = icmp sle i32 %15, %17
br i1 %18, label %19, label %31
19: ; preds = %13
%20 = load i8, i8* %11
%21 = load i8, i8* %7
%22 = load i8, i8* %10
%23 = call i32 @ks0108_putpixel(i8 zeroext %20, i8 zeroext %21, i8 zeroext %22)
%24 = load i8, i8* %11
%25 = load i8, i8* %9
%26 = load i8, i8* %10
%27 = call i32 @ks0108_putpixel(i8 zeroext %24, i8 zeroext %25, i8 zeroext %26)
br label %28
28: ; preds = %19
%29 = load i8, i8* %11
%30 = add i8 %29, 1
store i8 %30, i8* %11
br label %13
31: ; preds = %13
%32 = load i8, i8* %7
%33 = zext i8 %32 to i32
%34 = add nsw i32 %33, 1
%35 = trunc i32 %34 to i8
store i8 %35, i8* %11
br label %36
36: ; preds = %51, %31
%37 = load i8, i8* %11
%38 = zext i8 %37 to i32
%39 = load i8, i8* %9
%40 = zext i8 %39 to i32
%41 = icmp slt i32 %38, %40
br i1 %41, label %42, label %54
42: ; preds = %36
%43 = load i8, i8* %6
%44 = load i8, i8* %11
%45 = load i8, i8* %10
%46 = call i32 @ks0108_putpixel(i8 zeroext %43, i8 zeroext %44, i8 zeroext %45)
%47 = load i8, i8* %8
%48 = load i8, i8* %11
%49 = load i8, i8* %10
%50 = call i32 @ks0108_putpixel(i8 zeroext %47, i8 zeroext %48, i8 zeroext %49)
br label %51
51: ; preds = %42
%52 = load i8, i8* %11
%53 = add i8 %52, 1
store i8 %53, i8* %11
br label %36
54: ; preds = %36
ret void
}

LLVM IR (-O2):
define void @ks0108_rectangle(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i8 zeroext %4) {
%6 = icmp ugt i8 %0, %2
br i1 %6, label %7, label %10
7: ; preds = %10, %5
%8 = add i8 %1, 1
%9 = icmp ult i8 %8, %3
br i1 %9, label %16, label %22
10: ; preds = %5, %10
%11 = phi i8 [ %14, %10 ], [ %0, %5 ]
%12 = tail call i32 @ks0108_putpixel(i8 zeroext %11, i8 zeroext %1, i8 zeroext %4)
%13 = tail call i32 @ks0108_putpixel(i8 zeroext %11, i8 zeroext %3, i8 zeroext %4)
%14 = add i8 %11, 1
%15 = icmp ugt i8 %14, %2
br i1 %15, label %7, label %10
16: ; preds = %7, %16
%17 = phi i8 [ %20, %16 ], [ %8, %7 ]
%18 = tail call i32 @ks0108_putpixel(i8 zeroext %0, i8 zeroext %17, i8 zeroext %4)
%19 = tail call i32 @ks0108_putpixel(i8 zeroext %2, i8 zeroext %17, i8 zeroext %4)
%20 = add i8 %17, 1
%21 = icmp eq i8 %20, %3
br i1 %21, label %22, label %16
22: ; preds = %16, %7
ret void
}