#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*/ DrawHorizontalLine(int, int, int, unsigned short);
void FillRect(int ulx, int uly, int drx, int dry, unsigned short color) {
  int y, lenght = drx - ulx;
  for (y = uly; y <= dry; y++)
    DrawHorizontalLine(ulx, y, lenght, color);
}


x86 assembly (clang, -O0):
<FillRect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %r8w,%ax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1167 <FillRect+0x57>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
movzwl -0x12(%rbp),%ecx
call   1030 <DrawHorizontalLine@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113b <FillRect+0x2b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FillRect>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    %ecx,%esi
jg     1157 <FillRect+0x47>
mov    %ecx,%r12d
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%r15d
sub    %edi,%r14d
add    $0x1,%r12d
movzwl %r8w,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15d,%edi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
call   1030 <DrawHorizontalLine@plt>
add    $0x1,%ebp
cmp    %ebp,%r12d
jne    1140 <FillRect+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @FillRect(i32 %0, i32 %1, i32 %2, i32 %3, i16 zeroext %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i16
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i16 %4, i16* %10
%13 = load i32, i32* %8
%14 = load i32, i32* %6
%15 = sub nsw i32 %13, %14
store i32 %15, i32* %12
%16 = load i32, i32* %7
store i32 %16, i32* %11
br label %17
17: ; preds = %27, %5
%18 = load i32, i32* %11
%19 = load i32, i32* %9
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load i32, i32* %6
%23 = load i32, i32* %11
%24 = load i32, i32* %12
%25 = load i16, i16* %10
%26 = call i32 @DrawHorizontalLine(i32 %22, i32 %23, i32 %24, i16 zeroext %25)
br label %27
27: ; preds = %21
%28 = load i32, i32* %11
%29 = add nsw i32 %28, 1
store i32 %29, i32* %11
br label %17
30: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @FillRect(i32 %0, i32 %1, i32 %2, i32 %3, i16 zeroext %4) {
%6 = sub nsw i32 %2, %0
%7 = icmp sgt i32 %1, %3
br i1 %7, label %13, label %8
8: ; preds = %5, %8
%9 = phi i32 [ %11, %8 ], [ %1, %5 ]
%10 = tail call i32 @DrawHorizontalLine(i32 %0, i32 %9, i32 %6, i16 zeroext %4)
%11 = add i32 %9, 1
%12 = icmp eq i32 %9, %3
br i1 %12, label %13, label %8
13: ; preds = %8, %5
ret void
}