#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*/ EXIT_FAILURE;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *,
                           int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
void clear_screen() {
  printf("%s\e[1;1H\e[2J\n", "\x1B[0m");
  printf(">> ");
  do {
    if ((fflush(stdout) < 0)) {
      fprintf(stderr, "%s%s: %s\n", "\x1B[31m", "Errore fflush",
              strerror(errno));
      exit(EXIT_FAILURE);
    }
  } while (0);
}


x86 assembly (clang, -O0):
<clear_screen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
cmp    $0x0,%rax
jge    11db <clear_screen+0x8b>
mov    0x2e46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x4(%rbp),%edi
mov    %eax,%r8d
lea    0xe5d(%rip),%rsi
lea    0xe60(%rip),%rdx
lea    0xe5f(%rip),%rcx
call   1040 <fprintf@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    11e0 <clear_screen+0x90>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_screen>:
push   %rbx
lea    0xea8(%rip),%rdi
lea    0xeaf(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
test   %rax,%rax
js     1189 <clear_screen+0x39>
pop    %rbx
ret
mov    0x2e50(%rip),%rax
mov    (%rax),%ebx
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe70(%rip),%rsi
lea    0xe73(%rip),%rdx
lea    0xe72(%rip),%rcx
mov    %ebx,%edi
mov    %eax,%r8d
call   1040 <fprintf@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"%s\1B[1;1H\1B[2J\0A\00"
@.str.1 = [5 x i8] c"\1B[0m\00"
@.str.2 = [4 x i8] c">> \00"
@stdout = global i32 0
@stderr = global i32 0
@.str.3 = [10 x i8] c"%s%s: %s\0A\00"
@.str.4 = [6 x i8] c"\1B[31m\00"
@.str.5 = [14 x i8] c"Errore fflush\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define void @clear_screen() {
%1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %3
3: ; preds = %0
%4 = load i32, i32* @stdout
%5 = call i64 @fflush(i32 %4)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = call i32 @strerror(i32 %9)
%11 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %3
br label %15
15: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"%s\1B[1;1H\1B[2J\0A\00"
@.str.1 = [5 x i8] c"\1B[0m\00"
@.str.2 = [4 x i8] c">> \00"
@stdout = global i32 0
@stderr = global i32 0
@.str.3 = [10 x i8] c"%s%s: %s\0A\00"
@.str.4 = [6 x i8] c"\1B[31m\00"
@.str.5 = [14 x i8] c"Errore fflush\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define void @clear_screen() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%3 = load i32, i32* @stdout
%4 = tail call i64 @fflush(i32 %3)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = load i32, i32* @errno
%9 = tail call i32 @strerror(i32 %8)
%10 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %0
ret void
}