#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*/ ansiescape_setcursor(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ ansiescape_setgraphics(char *);
int /*<<< orphan*/ ansiescape_winsize(int *, int *);
int /*<<< orphan*/ printf(char *);
void ansiescape_clear() {
  int i, j;
  int rows, columns;
  if (!ansiescape_winsize(&rows, &columns))
    return;
  if (rows > 1)
    rows -= 1;
  ansiescape_setgraphics("");
  ansiescape_setcursor(0, 0);
  for (i = 0; i < rows; i++) {
    for (j = 0; j < columns; j++) {
      printf(" ");
    }
    printf("\n\r");
  }
  ansiescape_setcursor(0, 0);
}


x86 assembly (clang, -O0):
<ansiescape_clear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <ansiescape_winsize@plt>
cmp    $0x0,%eax
jne    1163 <ansiescape_clear+0x23>
jmp    11ee <ansiescape_clear+0xae>
cmpl   $0x1,-0xc(%rbp)
jle    1176 <ansiescape_clear+0x36>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    0xe87(%rip),%rdi
call   1050 <ansiescape_setgraphics@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1060 <ansiescape_setcursor@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e5 <ansiescape_clear+0xa5>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11cb <ansiescape_clear+0x8b>
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a5 <ansiescape_clear+0x65>
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1192 <ansiescape_clear+0x52>
xor    %esi,%esi
mov    %esi,%edi
call   1060 <ansiescape_setcursor@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ansiescape_clear>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1040 <ansiescape_winsize@plt>
test   %eax,%eax
je     11ee <ansiescape_clear+0x9e>
mov    0x8(%rsp),%eax
cmp    $0x2,%eax
jl     117f <ansiescape_clear+0x2f>
add    $0xffffffff,%eax
mov    %eax,0x8(%rsp)
lea    0xe7c(%rip),%rdi
call   1060 <ansiescape_setgraphics@plt>
xor    %ebp,%ebp
xor    %edi,%edi
xor    %esi,%esi
call   1070 <ansiescape_setcursor@plt>
cmpl   $0x0,0x8(%rsp)
jle    11e5 <ansiescape_clear+0x95>
lea    0xe5c(%rip),%r14
jmp    11c1 <ansiescape_clear+0x71>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jge    11e5 <ansiescape_clear+0x95>
cmpl   $0x0,0xc(%rsp)
jle    11b0 <ansiescape_clear+0x60>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    0xc(%rsp),%ebx
jl     11d0 <ansiescape_clear+0x80>
jmp    11b0 <ansiescape_clear+0x60>
xor    %edi,%edi
xor    %esi,%esi
call   1070 <ansiescape_setcursor@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c" \00"
@.str.2 = [3 x i8] c"\0A\0D\00"
define void @ansiescape_clear() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 @ansiescape_winsize(i32* %3, i32* %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %0
br label %38
8: ; preds = %0
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %3
br label %14
14: ; preds = %11, %8
%15 = call i32 @ansiescape_setgraphics(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @ansiescape_setcursor(i32 0, i32 0)
store i32 0, i32* %1
br label %17
17: ; preds = %33, %14
%18 = load i32, i32* %1
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %36
21: ; preds = %17
store i32 0, i32* %2
br label %22
22: ; preds = %28, %21
%23 = load i32, i32* %2
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %26
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %22
31: ; preds = %22
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %31
%34 = load i32, i32* %1
%35 = add nsw i32 %34, 1
store i32 %35, i32* %1
br label %17
36: ; preds = %17
%37 = call i32 @ansiescape_setcursor(i32 0, i32 0)
br label %38
38: ; preds = %36, %7
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"\0A\0D\00"
define void @ansiescape_clear() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @ansiescape_winsize(i32* %1, i32* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %34, label %7
7: ; preds = %0
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = add nsw i32 %8, -1
store i32 %11, i32* %1
br label %12
12: ; preds = %10, %7
%13 = call i32 @ansiescape_setgraphics(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @ansiescape_setcursor(i32 0, i32 0)
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %32
17: ; preds = %12, %27
%18 = phi i32 [ %29, %27 ], [ 0, %12 ]
%19 = load i32, i32* %2
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %17, %21
%22 = phi i32 [ %24, %21 ], [ 0, %17 ]
%23 = call i32 @putchar(i32 32)
%24 = add nuw nsw i32 %22, 1
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %21, label %27
27: ; preds = %21, %17
%28 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%29 = add nuw nsw i32 %18, 1
%30 = load i32, i32* %1
%31 = icmp slt i32 %29, %30
br i1 %31, label %17, label %32
32: ; preds = %27, %12
%33 = call i32 @ansiescape_setcursor(i32 0, i32 0)
br label %34
34: ; preds = %0, %32
ret void
}