#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 /*<<< orphan*/);
int /*<<< orphan*/ set_cursor(int /*<<< orphan*/);
void clear_screen() {
  int row, col;
  for (row = 0; row < 25; row++) {
    for (col = 0; col < 80; col++) {
      print_char(' ', row, col, 0);
    }
  }
  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)
cmpl   $0x19,-0x4(%rbp)
jge    118d <clear_screen+0x5d>
movl   $0x0,-0x8(%rbp)
cmpl   $0x50,-0x8(%rbp)
jge    117a <clear_screen+0x4a>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    $0x20,%edi
xor    %ecx,%ecx
call   1050 <print_char@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1150 <clear_screen+0x20>
jmp    117f <clear_screen+0x4f>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113f <clear_screen+0xf>
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    %ebx,%esi
mov    %ebp,%edx
xor    %ecx,%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
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* %1
%12 = load i32, i32* %2
%13 = call i32 @print_char(i8 signext 32, i32 %11, i32 %12, i32 0)
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 %2, i32 %4, i32 0)
%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
}