#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*/ get_screen_offset(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ print_char(char, int, int, int);
int /*<<< orphan*/ set_cursor(int /*<<< orphan*/);
void clear_screen() {
  int row = 0;
  int col = 0;
  for (row = 0; row < 25; row++)
    for (col = 0; col < 80; col++)
      print_char(' ', col, row, 0x0f);
  set_cursor(get_screen_offset(0, 0));
}


x86 assembly (clang, -O0):
<clear_screen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x19,-0x4(%rbp)
jge    119e <clear_screen+0x6e>
movl   $0x0,-0x8(%rbp)
cmpl   $0x50,-0x8(%rbp)
jge    118b <clear_screen+0x5b>
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    $0x20,%edi
mov    $0xf,%ecx
call   1050 <print_char@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115e <clear_screen+0x2e>
jmp    1190 <clear_screen+0x60>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114d <clear_screen+0x1d>
xor    %esi,%esi
mov    %esi,%edi
call   1030 <get_screen_offset@plt>
mov    %eax,%edi
call   1040 <set_cursor@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_screen>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x20,%edi
mov    %ebp,%esi
mov    %ebx,%edx
mov    $0xf,%ecx
call   1050 <print_char@plt>
add    $0x1,%ebp
cmp    $0x50,%ebp
jne    1150 <clear_screen+0x20>
add    $0x1,%ebx
cmp    $0x19,%ebx
jne    1140 <clear_screen+0x10>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <get_screen_offset@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <set_cursor@plt>

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

LLVM IR (-O2):
define void @clear_screen() {
br label %1
1: ; preds = %0, %8
%2 = phi i32 [ 0, %0 ], [ %9, %8 ]
br label %3
3: ; preds = %1, %3
%4 = phi i32 [ 0, %1 ], [ %6, %3 ]
%5 = tail call i32 @print_char(i8 signext 32, i32 %4, i32 %2, i32 15)
%6 = add nuw nsw i32 %4, 1
%7 = icmp eq i32 %6, 80
br i1 %7, label %8, label %3
8: ; preds = %3
%9 = add nuw nsw i32 %2, 1
%10 = icmp eq i32 %9, 25
br i1 %10, label %11, label %1
11: ; preds = %8
%12 = tail call i32 @get_screen_offset(i32 0, i32 0)
%13 = tail call i32 @set_cursor(i32 %12)
ret void
}