#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*/ draw_line(int, int, int, int, char);
void fill_rect(int x, int y, int width, int height, char c) {
  if ((width < 1) || (height < 1)) {
    return;
  }
  int x2 = x + width - 1;
  int y2 = y + height;
  for (; y < y2; y++) {
    draw_line(x, y, x2, y, c);
  }
}


x86 assembly (clang, -O0):
<fill_rect>:
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)
cmpl   $0x1,-0xc(%rbp)
jl     113e <fill_rect+0x2e>
cmpl   $0x1,-0x10(%rbp)
jge    1143 <fill_rect+0x33>
jmp    1188 <fill_rect+0x78>
mov    -0x4(%rbp),%eax
add    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1188 <fill_rect+0x78>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%ecx
movsbl -0x11(%rbp),%r8d
call   1030 <draw_line@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1158 <fill_rect+0x48>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_rect>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
jle    115a <fill_rect+0x4a>
mov    %ecx,%r15d
test   %ecx,%ecx
jle    115a <fill_rect+0x4a>
mov    %esi,%ebp
mov    %edi,%r14d
lea    (%r14,%rdx,1),%r12d
add    $0xffffffff,%r12d
add    %esi,%r15d
movsbl %r8b,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
call   1030 <draw_line@plt>
add    $0x1,%ebp
cmp    %r15d,%ebp
jl     1140 <fill_rect+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @fill_rect(i32 %0, i32 %1, i32 %2, i32 %3, i8 signext %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%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 i8 %4, i8* %10
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 1
br i1 %14, label %18, label %15
15: ; preds = %5
%16 = load i32, i32* %9
%17 = icmp slt i32 %16, 1
br i1 %17, label %18, label %19
18: ; preds = %15, %5
br label %41
19: ; preds = %15
%20 = load i32, i32* %6
%21 = load i32, i32* %8
%22 = add nsw i32 %20, %21
%23 = sub nsw i32 %22, 1
store i32 %23, i32* %11
%24 = load i32, i32* %7
%25 = load i32, i32* %9
%26 = add nsw i32 %24, %25
store i32 %26, i32* %12
br label %27
27: ; preds = %38, %19
%28 = load i32, i32* %7
%29 = load i32, i32* %12
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %41
31: ; preds = %27
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = load i32, i32* %11
%35 = load i32, i32* %7
%36 = load i8, i8* %10
%37 = call i32 @draw_line(i32 %32, i32 %33, i32 %34, i32 %35, i8 signext %36)
br label %38
38: ; preds = %31
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %27
41: ; preds = %18, %27
ret void
}

LLVM IR (-O2):
define void @fill_rect(i32 %0, i32 %1, i32 %2, i32 %3, i8 signext %4) {
%6 = icmp slt i32 %2, 1
%7 = icmp slt i32 %3, 1
%8 = or i1 %6, %7
br i1 %8, label %18, label %9
9: ; preds = %5
%10 = add i32 %0, -1
%11 = add i32 %10, %2
%12 = add nsw i32 %3, %1
br label %13
13: ; preds = %9, %13
%14 = phi i32 [ %16, %13 ], [ %1, %9 ]
%15 = tail call i32 @draw_line(i32 %0, i32 %14, i32 %11, i32 %14, i8 signext %4)
%16 = add nsw i32 %14, 1
%17 = icmp slt i32 %16, %12
br i1 %17, label %13, label %18
18: ; preds = %13, %5
ret void
}