#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*/ setPixel(int, int, unsigned short);
void drawRect(int row, int col, int width, int height, unsigned short color) {
  int r;
  int c;
  for (r = 0; r <= height; r++) {
    for (c = 0; c <= width; c++) {
      setPixel(row + r, col + c, color);
    }
  }
}


x86 assembly (clang, -O0):
<drawRect>:
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)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1188 <drawRect+0x78>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1175 <drawRect+0x65>
mov    -0x4(%rbp),%edi
add    -0x18(%rbp),%edi
mov    -0x8(%rbp),%esi
add    -0x1c(%rbp),%esi
movzwl -0x12(%rbp),%edx
call   1030 <setPixel@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1146 <drawRect+0x36>
jmp    117a <drawRect+0x6a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1133 <drawRect+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawRect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x8(%rsp)
mov    %esi,0x4(%rsp)
mov    %rdi,0x10(%rsp)
test   %ecx,%ecx
js     1198 <drawRect+0x88>
mov    %ecx,%r13d
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %eax,(%rsp)
xor    %r12d,%r12d
movzwl %r8w,%ebp
jmp    115d <drawRect+0x4d>
nopw   0x0(%rax,%rax,1)
lea    0x1(%r12),%eax
cmp    %r13d,%r12d
mov    %eax,%r12d
je     1198 <drawRect+0x88>
cmpl   $0x0,0x8(%rsp)
js     1150 <drawRect+0x40>
mov    0x10(%rsp),%rax
lea    (%r12,%rax,1),%ebx
mov    0x4(%rsp),%r15d
mov    (%rsp),%r14d
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r15d,%esi
mov    %ebp,%edx
call   1030 <setPixel@plt>
add    $0x1,%r15d
add    $0xffffffff,%r14d
jne    1180 <drawRect+0x70>
jmp    1150 <drawRect+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @drawRect(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
store i32 0, i32* %11
br label %13
13: ; preds = %35, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %9
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %38
17: ; preds = %13
store i32 0, i32* %12
br label %18
18: ; preds = %31, %17
%19 = load i32, i32* %12
%20 = load i32, i32* %8
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %34
22: ; preds = %18
%23 = load i32, i32* %6
%24 = load i32, i32* %11
%25 = add nsw i32 %23, %24
%26 = load i32, i32* %7
%27 = load i32, i32* %12
%28 = add nsw i32 %26, %27
%29 = load i16, i16* %10
%30 = call i32 @setPixel(i32 %25, i32 %28, i16 zeroext %29)
br label %31
31: ; preds = %22
%32 = load i32, i32* %12
%33 = add nsw i32 %32, 1
store i32 %33, i32* %12
br label %18
34: ; preds = %18
br label %35
35: ; preds = %34
%36 = load i32, i32* %11
%37 = add nsw i32 %36, 1
store i32 %37, i32* %11
br label %13
38: ; preds = %13
ret void
}

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