#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*/ Plot(int, int, int, int *, int, int);
void DrawRect(int x, int y, int width, int height, int color, int *buffer,
              int bufferWidth, int bufferHeight) {
  for (int i = 0; i < height; i++) {
    for (int i2 = 0; i2 < width; i2++) {
      Plot(x + i2, y + i, color, buffer, bufferWidth, bufferHeight);
    }
  }
}


x86 assembly (clang, -O0):
<DrawRect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1199 <DrawRect+0x89>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1186 <DrawRect+0x76>
mov    -0x4(%rbp),%edi
add    -0x28(%rbp),%edi
mov    -0x8(%rbp),%esi
add    -0x24(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    0x10(%rbp),%r8d
mov    0x18(%rbp),%r9d
call   1030 <Plot@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114c <DrawRect+0x3c>
jmp    118b <DrawRect+0x7b>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1139 <DrawRect+0x29>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DrawRect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,0x4(%rsp)
mov    %rsi,0x20(%rsp)
mov    %edi,0x14(%rsp)
mov    %ecx,0x18(%rsp)
test   %ecx,%ecx
jle    11b4 <DrawRect+0xa4>
mov    %r9,%rbp
mov    %r8d,%r14d
mov    0x68(%rsp),%r13d
mov    0x60(%rsp),%ebx
xor    %eax,%eax
mov    %rax,0x8(%rsp)
jmp    1163 <DrawRect+0x53>
nop
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
cmp    0x18(%rsp),%eax
je     11b4 <DrawRect+0xa4>
cmpl   $0x0,0x4(%rsp)
jle    1150 <DrawRect+0x40>
mov    0x20(%rsp),%rax
mov    0x8(%rsp),%rcx
add    %ecx,%eax
mov    %eax,0x1c(%rsp)
mov    0x14(%rsp),%r15d
mov    0x4(%rsp),%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15d,%edi
mov    0x1c(%rsp),%esi
mov    %r14d,%edx
mov    %rbp,%rcx
mov    %ebx,%r8d
mov    %r13d,%r9d
call   1030 <Plot@plt>
add    $0x1,%r15d
add    $0xffffffff,%r12d
jne    1190 <DrawRect+0x80>
jmp    1150 <DrawRect+0x40>
add    $0x28,%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, i32 %4, i32* %5, i32 %6, i32 %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32* %5, i32** %14
store i32 %6, i32* %15
store i32 %7, i32* %16
store i32 0, i32* %17
br label %19
19: ; preds = %44, %8
%20 = load i32, i32* %17
%21 = load i32, i32* %12
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %47
23: ; preds = %19
store i32 0, i32* %18
br label %24
24: ; preds = %40, %23
%25 = load i32, i32* %18
%26 = load i32, i32* %11
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %43
28: ; preds = %24
%29 = load i32, i32* %9
%30 = load i32, i32* %18
%31 = add nsw i32 %29, %30
%32 = load i32, i32* %10
%33 = load i32, i32* %17
%34 = add nsw i32 %32, %33
%35 = load i32, i32* %13
%36 = load i32*, i32** %14
%37 = load i32, i32* %15
%38 = load i32, i32* %16
%39 = call i32 @Plot(i32 %31, i32 %34, i32 %35, i32* %36, i32 %37, i32 %38)
br label %40
40: ; preds = %28
%41 = load i32, i32* %18
%42 = add nsw i32 %41, 1
store i32 %42, i32* %18
br label %24
43: ; preds = %24
br label %44
44: ; preds = %43
%45 = load i32, i32* %17
%46 = add nsw i32 %45, 1
store i32 %46, i32* %17
br label %19
47: ; preds = %19
ret void
}

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