#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 */
typedef int /*<<< orphan*/ WINDOW;

/* Variables and functions */
int /*<<< orphan*/ delwin(int /*<<< orphan*/ *);
int /*<<< orphan*/ mvwaddch(int /*<<< orphan*/ *, int, int, char);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
void erase_window(WINDOW *win, int height, int width) {
  int i, j;
  for (i = 0; i < height; ++i) {
    for (j = 0; j < width; j++) {
      mvwaddch(win, i, j, ' ');
    }
  }
  wrefresh(win);
  delwin(win);
}


x86 assembly (clang, -O0):
<erase_window>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119d <erase_window+0x6d>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    118a <erase_window+0x5a>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    $0x20,%ecx
call   1050 <mvwaddch@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115c <erase_window+0x2c>
jmp    118f <erase_window+0x5f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <erase_window+0x19>
mov    -0x8(%rbp),%rdi
call   1030 <wrefresh@plt>
mov    -0x8(%rbp),%rdi
call   1040 <delwin@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<erase_window>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
test   %esi,%esi
jle    117b <erase_window+0x4b>
mov    %edx,%r12d
mov    %esi,%r14d
xor    %ebx,%ebx
jmp    1158 <erase_window+0x28>
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    %r14d,%ebx
je     117b <erase_window+0x4b>
test   %r12d,%r12d
jle    1150 <erase_window+0x20>
xor    %ebp,%ebp
nop
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    $0x20,%ecx
call   1050 <mvwaddch@plt>
add    $0x1,%ebp
cmp    %ebp,%r12d
jne    1160 <erase_window+0x30>
jmp    1150 <erase_window+0x20>
mov    %r15,%rdi
call   1030 <wrefresh@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <delwin@plt>

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

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