#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*/ writeFastHLine(short, short, short, short);
int /*<<< orphan*/ writeFastVLine(short, short, short, short);
void drawRect(short x, short y, short w, short h, short color) {
  writeFastHLine(x, y, w, color);
  writeFastHLine(x, y + h - 1, w, color);
  writeFastVLine(x, y, h, color);
  writeFastVLine(x + w - 1, y, h, color);
}


x86 assembly (clang, -O0):
<drawRect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %r8w,%ax
mov    %di,-0x2(%rbp)
mov    %si,-0x4(%rbp)
mov    %dx,-0x6(%rbp)
mov    %cx,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    -0x2(%rbp),%dx
mov    -0x4(%rbp),%cx
mov    -0x6(%rbp),%ax
movswl %dx,%edi
movswl %cx,%esi
movswl %ax,%edx
movswl -0xa(%rbp),%ecx
call   1040 <writeFastHLine@plt>
mov    -0x2(%rbp),%dx
movswl -0x4(%rbp),%eax
movswl -0x8(%rbp),%ecx
add    %ecx,%eax
sub    $0x1,%eax
mov    %ax,%cx
mov    -0x6(%rbp),%ax
movswl %dx,%edi
movswl %cx,%esi
movswl %ax,%edx
movswl -0xa(%rbp),%ecx
call   1040 <writeFastHLine@plt>
mov    -0x2(%rbp),%dx
mov    -0x4(%rbp),%cx
mov    -0x8(%rbp),%ax
movswl %dx,%edi
movswl %cx,%esi
movswl %ax,%edx
movswl -0xa(%rbp),%ecx
call   1030 <writeFastVLine@plt>
movswl -0x2(%rbp),%eax
movswl -0x6(%rbp),%ecx
add    %ecx,%eax
sub    $0x1,%eax
mov    %ax,%dx
mov    -0x4(%rbp),%cx
mov    -0x8(%rbp),%ax
movswl %dx,%edi
movswl %cx,%esi
movswl %ax,%edx
movswl -0xa(%rbp),%ecx
call   1030 <writeFastVLine@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawRect>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r12d
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%ebp
mov    %r8d,%ecx
call   1040 <writeFastHLine@plt>
lea    (%rbx,%r14,1),%eax
add    $0xffffffff,%eax
movswl %ax,%esi
mov    %ebp,%edi
mov    %r15d,%edx
mov    %r12d,%ecx
call   1040 <writeFastHLine@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %r12d,%ecx
call   1030 <writeFastVLine@plt>
lea    (%r15,%rbp,1),%eax
add    $0xffffffff,%eax
movswl %ax,%edi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %r12d,%ecx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <writeFastVLine@plt>

LLVM IR (-O0):
define void @drawRect(i16 signext %0, i16 signext %1, i16 signext %2, i16 signext %3, i16 signext %4) {
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
%9 = alloca i16
%10 = alloca i16
store i16 %0, i16* %6
store i16 %1, i16* %7
store i16 %2, i16* %8
store i16 %3, i16* %9
store i16 %4, i16* %10
%11 = load i16, i16* %6
%12 = load i16, i16* %7
%13 = load i16, i16* %8
%14 = load i16, i16* %10
%15 = call i32 @writeFastHLine(i16 signext %11, i16 signext %12, i16 signext %13, i16 signext %14)
%16 = load i16, i16* %6
%17 = load i16, i16* %7
%18 = sext i16 %17 to i32
%19 = load i16, i16* %9
%20 = sext i16 %19 to i32
%21 = add nsw i32 %18, %20
%22 = sub nsw i32 %21, 1
%23 = trunc i32 %22 to i16
%24 = load i16, i16* %8
%25 = load i16, i16* %10
%26 = call i32 @writeFastHLine(i16 signext %16, i16 signext %23, i16 signext %24, i16 signext %25)
%27 = load i16, i16* %6
%28 = load i16, i16* %7
%29 = load i16, i16* %9
%30 = load i16, i16* %10
%31 = call i32 @writeFastVLine(i16 signext %27, i16 signext %28, i16 signext %29, i16 signext %30)
%32 = load i16, i16* %6
%33 = sext i16 %32 to i32
%34 = load i16, i16* %8
%35 = sext i16 %34 to i32
%36 = add nsw i32 %33, %35
%37 = sub nsw i32 %36, 1
%38 = trunc i32 %37 to i16
%39 = load i16, i16* %7
%40 = load i16, i16* %9
%41 = load i16, i16* %10
%42 = call i32 @writeFastVLine(i16 signext %38, i16 signext %39, i16 signext %40, i16 signext %41)
ret void
}

LLVM IR (-O2):
define void @drawRect(i16 signext %0, i16 signext %1, i16 signext %2, i16 signext %3, i16 signext %4) {
%6 = tail call i32 @writeFastHLine(i16 signext %0, i16 signext %1, i16 signext %2, i16 signext %4)
%7 = add i16 %1, -1
%8 = add i16 %7, %3
%9 = tail call i32 @writeFastHLine(i16 signext %0, i16 signext %8, i16 signext %2, i16 signext %4)
%10 = tail call i32 @writeFastVLine(i16 signext %0, i16 signext %1, i16 signext %3, i16 signext %4)
%11 = add i16 %0, -1
%12 = add i16 %11, %2
%13 = tail call i32 @writeFastVLine(i16 signext %12, i16 signext %1, i16 signext %3, i16 signext %4)
ret void
}