#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*/ addch(char);
int /*<<< orphan*/ move(int, int);
void draw_rect(int x, int y, unsigned w, unsigned h) {
  for (unsigned i = 0; i < h; ++i) {
    if (y + (int)i < 0)
      continue;
    move(y + i, x);
    for (unsigned j = 0; j < w; ++j) {
      addch(' ');
    }
  }
}


x86 assembly (clang, -O0):
<draw_rect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    11a7 <draw_rect+0x87>
mov    -0x8(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    $0x0,%eax
jge    115b <draw_rect+0x3b>
jmp    1199 <draw_rect+0x79>
mov    -0x8(%rbp),%edi
add    -0x14(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1040 <move@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1194 <draw_rect+0x74>
mov    $0x20,%edi
call   1030 <addch@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1170 <draw_rect+0x50>
jmp    1199 <draw_rect+0x79>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113b <draw_rect+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_rect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %ecx,%ecx
je     1171 <draw_rect+0x51>
mov    %ecx,%r13d
mov    %edx,%r14d
mov    %esi,%r12d
mov    %edi,%r15d
xor    %ebp,%ebp
jmp    1148 <draw_rect+0x28>
nop
add    $0x1,%ebp
cmp    %r13d,%ebp
je     1171 <draw_rect+0x51>
mov    %ebp,%edi
add    %r12d,%edi
js     1140 <draw_rect+0x20>
mov    %r15d,%esi
call   1040 <move@plt>
test   %r14d,%r14d
je     1140 <draw_rect+0x20>
mov    %r14d,%ebx
nop
mov    $0x20,%edi
call   1030 <addch@plt>
add    $0xffffffff,%ebx
jne    1160 <draw_rect+0x40>
jmp    1140 <draw_rect+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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