#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, int);
void draw_rect(int _x0, int _y0, int _width, int _height, int value) {
  int PosX = _x0;
  int PosY = _y0;
  int width = _width;
  int height = _height;
  int EndX = PosX + width;
  for (int i = 0; i < height; i++) {
    int row = PosY + i;
    draw_line(PosX, row, EndX, row, value);
  }
}


x86 assembly (clang, -O0):
<draw_rect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1188 <draw_rect+0x78>
mov    -0x1c(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x14(%rbp),%r8d
call   1030 <draw_line@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1150 <draw_rect+0x40>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_rect>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %ecx,%ecx
jle    114a <draw_rect+0x3a>
mov    %r8d,%r14d
mov    %ecx,%ebp
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%r12d
add    %edi,%r15d
nopl   0x0(%rax)
mov    %r12d,%edi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %r14d,%r8d
call   1030 <draw_line@plt>
add    $0x1,%ebx
add    $0xffffffff,%ebp
jne    1130 <draw_rect+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @draw_rect(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = add nsw i32 %2, %0
%7 = icmp sgt i32 %3, 0
br i1 %7, label %9, label %8
8: ; preds = %9, %5
ret void
9: ; preds = %5, %9
%10 = phi i32 [ %13, %9 ], [ 0, %5 ]
%11 = add nsw i32 %10, %1
%12 = tail call i32 @draw_line(i32 %0, i32 %11, i32 %6, i32 %11, i32 %4)
%13 = add nuw nsw i32 %10, 1
%14 = icmp eq i32 %13, %3
br i1 %14, label %8, label %9
}