#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 COLS;
int LINES;
int /*<<< orphan*/ addch(char);
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ wmove(int /*<<< orphan*/, int, int /*<<< orphan*/);
void screen_clear(void) {
  for (int i = 0; i < LINES; ++i) {
    wmove(stdscr, i, 0);
    for (int j = 0; j < COLS; ++j) {
      addch(' ');
    }
  }
}


x86 assembly (clang, -O0):
<screen_clear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eaf(%rip),%rcx
cmp    (%rcx),%eax
jge    1198 <screen_clear+0x78>
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%esi
xor    %edx,%edx
call   1040 <wmove@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e73(%rip),%rcx
cmp    (%rcx),%eax
jge    1185 <screen_clear+0x65>
mov    $0x20,%edi
call   1030 <addch@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115b <screen_clear+0x3b>
jmp    118a <screen_clear+0x6a>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112f <screen_clear+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<screen_clear>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2eb9(%rip),%r14
cmpl   $0x0,(%r14)
jle    1183 <screen_clear+0x63>
xor    %r12d,%r12d
mov    0x2ea1(%rip),%r15
mov    0x2e92(%rip),%rbx
jmp    1159 <screen_clear+0x39>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12d
cmp    (%r14),%r12d
jge    1183 <screen_clear+0x63>
mov    (%r15),%edi
mov    %r12d,%esi
xor    %edx,%edx
call   1040 <wmove@plt>
cmpl   $0x0,(%rbx)
jle    1150 <screen_clear+0x30>
xor    %ebp,%ebp
nopl   (%rax)
mov    $0x20,%edi
call   1030 <addch@plt>
add    $0x1,%ebp
cmp    (%rbx),%ebp
jl     1170 <screen_clear+0x50>
jmp    1150 <screen_clear+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@LINES = global i32 0
@stdscr = global i32 0
@COLS = global i32 0
define void @screen_clear() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %21, %0
%4 = load i32, i32* %1
%5 = load i32, i32* @LINES
%6 = icmp slt i32 %4, %5
br i1 %6, label %7, label %24
7: ; preds = %3
%8 = load i32, i32* @stdscr
%9 = load i32, i32* %1
%10 = call i32 @wmove(i32 %8, i32 %9, i32 0)
store i32 0, i32* %2
br label %11
11: ; preds = %17, %7
%12 = load i32, i32* %2
%13 = load i32, i32* @COLS
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = call i32 @addch(i8 signext 32)
br label %17
17: ; preds = %15
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %11
20: ; preds = %11
br label %21
21: ; preds = %20
%22 = load i32, i32* %1
%23 = add nsw i32 %22, 1
store i32 %23, i32* %1
br label %3
24: ; preds = %3
ret void
}

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