#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*/ write_pixel(int, int, short);
void drawfilledBox(int x, int y, int lengthx, int lengthy, short colour) {
  int i, j;
  for (i = 0; i < lengthy; i++) {
    for (j = 0; j < lengthx; j++) {
      write_pixel(x + j, y + i, colour);
    }
  }
}


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

x86 assembly (clang, -O2):
<drawfilledBox>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
mov    %edi,0x8(%rsp)
mov    %ecx,0xc(%rsp)
test   %ecx,%ecx
jle    1188 <drawfilledBox+0x78>
mov    %edx,%r12d
xor    %r14d,%r14d
movswl %r8w,%ebx
jmp    114b <drawfilledBox+0x3b>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14d
cmp    0xc(%rsp),%r14d
je     1188 <drawfilledBox+0x78>
test   %r12d,%r12d
jle    1140 <drawfilledBox+0x30>
mov    0x10(%rsp),%rax
lea    (%r14,%rax,1),%ebp
mov    0x8(%rsp),%r15d
mov    %r12d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <write_pixel@plt>
add    $0x1,%r15d
add    $0xffffffff,%r13d
jne    1170 <drawfilledBox+0x60>
jmp    1140 <drawfilledBox+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @drawfilledBox(i32 %0, i32 %1, i32 %2, i32 %3, i16 signext %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 slt 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 slt i32 %19, %20
br i1 %21, label %22, label %34
22: ; preds = %18
%23 = load i32, i32* %6
%24 = load i32, i32* %12
%25 = add nsw i32 %23, %24
%26 = load i32, i32* %7
%27 = load i32, i32* %11
%28 = add nsw i32 %26, %27
%29 = load i16, i16* %10
%30 = call i32 @write_pixel(i32 %25, i32 %28, i16 signext %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 @drawfilledBox(i32 %0, i32 %1, i32 %2, i32 %3, i16 signext %4) {
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %22
7: ; preds = %5
%8 = icmp sgt i32 %2, 0
br label %9
9: ; preds = %7, %19
%10 = phi i32 [ 0, %7 ], [ %20, %19 ]
br i1 %8, label %11, label %19
11: ; preds = %9
%12 = add nsw i32 %10, %1
br label %13
13: ; preds = %11, %13
%14 = phi i32 [ 0, %11 ], [ %17, %13 ]
%15 = add nsw i32 %14, %0
%16 = tail call i32 @write_pixel(i32 %15, i32 %12, i16 signext %4)
%17 = add nuw nsw i32 %14, 1
%18 = icmp eq i32 %17, %2
br i1 %18, label %19, label %13
19: ; preds = %13, %9
%20 = add nuw nsw i32 %10, 1
%21 = icmp eq i32 %20, %3
br i1 %21, label %22, label %9
22: ; preds = %19, %5
ret void
}