#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(char *, int, int, int, int);
void draw_rect(char *fbp, int x, int y, int w, int h) {
  int i = 0;
  for (i = 0; i < w; i++) {
    draw_line(fbp, x + i, y, x + i, y + h);
  }
}


x86 assembly (clang, -O0):
<draw_rect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1171 <draw_rect+0x61>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
add    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%r8d
add    -0x18(%rbp),%r8d
call   1030 <draw_line@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <draw_rect+0x27>
add    $0x20,%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    %rdi,%r12
add    %edx,%r14d
nopl   0x0(%rax)
mov    %r12,%rdi
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(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store i32 0, i32* %11
store i32 0, i32* %11
br label %12
12: ; preds = %29, %5
%13 = load i32, i32* %11
%14 = load i32, i32* %9
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %32
16: ; preds = %12
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = load i32, i32* %11
%20 = add nsw i32 %18, %19
%21 = load i32, i32* %8
%22 = load i32, i32* %7
%23 = load i32, i32* %11
%24 = add nsw i32 %22, %23
%25 = load i32, i32* %8
%26 = load i32, i32* %10
%27 = add nsw i32 %25, %26
%28 = call i32 @draw_line(i8* %17, i32 %20, i32 %21, i32 %24, i32 %27)
br label %29
29: ; preds = %16
%30 = load i32, i32* %11
%31 = add nsw i32 %30, 1
store i32 %31, i32* %11
br label %12
32: ; preds = %12
ret void
}

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