#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 draw_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 - 1;
  draw_line(x, y, x2, y, c);
  draw_line(x, y2, x2, y2, c);
  draw_line(x, y, x, y2, c);
  draw_line(x2, y, x2, y2, c);
}


x86 assembly (clang, -O0):
<draw_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 <draw_rect+0x2e>
cmpl   $0x1,-0x10(%rbp)
jge    1143 <draw_rect+0x33>
jmp    11b3 <draw_rect+0xa3>
mov    -0x4(%rbp),%eax
add    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
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    -0x4(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
movsbl -0x11(%rbp),%r8d
call   1030 <draw_line@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x1c(%rbp),%ecx
movsbl -0x11(%rbp),%r8d
call   1030 <draw_line@plt>
mov    -0x18(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
movsbl -0x11(%rbp),%r8d
call   1030 <draw_line@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_rect>:
test   %edx,%edx
jle    1181 <draw_rect+0x71>
test   %ecx,%ecx
jle    1181 <draw_rect+0x71>
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebx
lea    -0x1(%rbx,%rdx,1),%r15d
lea    -0x1(%r14,%rcx,1),%r12d
movsbl %r8b,%ebp
mov    %r15d,%edx
mov    %esi,%ecx
mov    %ebp,%r8d
call   1030 <draw_line@plt>
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %r12d,%ecx
mov    %ebp,%r8d
call   1030 <draw_line@plt>
mov    %ebx,%edi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %r12d,%ecx
mov    %ebp,%r8d
call   1030 <draw_line@plt>
mov    %r15d,%edi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %r12d,%ecx
mov    %ebp,%r8d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <draw_line@plt>
ret

LLVM IR (-O0):
define void @draw_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 %52
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
%27 = sub nsw i32 %26, 1
store i32 %27, i32* %12
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = load i32, i32* %11
%31 = load i32, i32* %7
%32 = load i8, i8* %10
%33 = call i32 @draw_line(i32 %28, i32 %29, i32 %30, i32 %31, i8 signext %32)
%34 = load i32, i32* %6
%35 = load i32, i32* %12
%36 = load i32, i32* %11
%37 = load i32, i32* %12
%38 = load i8, i8* %10
%39 = call i32 @draw_line(i32 %34, i32 %35, i32 %36, i32 %37, i8 signext %38)
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = load i32, i32* %6
%43 = load i32, i32* %12
%44 = load i8, i8* %10
%45 = call i32 @draw_line(i32 %40, i32 %41, i32 %42, i32 %43, i8 signext %44)
%46 = load i32, i32* %11
%47 = load i32, i32* %7
%48 = load i32, i32* %11
%49 = load i32, i32* %12
%50 = load i8, i8* %10
%51 = call i32 @draw_line(i32 %46, i32 %47, i32 %48, i32 %49, i8 signext %50)
br label %52
52: ; preds = %19, %18
ret void
}

LLVM IR (-O2):
define void @draw_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 i32 %1, -1
%13 = add i32 %12, %3
%14 = tail call i32 @draw_line(i32 %0, i32 %1, i32 %11, i32 %1, i8 signext %4)
%15 = tail call i32 @draw_line(i32 %0, i32 %13, i32 %11, i32 %13, i8 signext %4)
%16 = tail call i32 @draw_line(i32 %0, i32 %1, i32 %0, i32 %13, i8 signext %4)
%17 = tail call i32 @draw_line(i32 %11, i32 %1, i32 %11, i32 %13, i8 signext %4)
br label %18
18: ; preds = %5, %9
ret void
}