#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*/ free(unsigned char *);
int /*<<< orphan*/ goto_xy(int /*<<< orphan*/, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, int);
int /*<<< orphan*/ send_data(unsigned char *, int);
void clear_screen() {
  int y;
  unsigned char *data;
  data = (unsigned char *)malloc(84);
  memset((void *)data, 0, 84);
  for (y = 0; y < 6; y++) {
    goto_xy(0, y);
    send_data(data, 84);
  }
  free(data);
}


x86 assembly (clang, -O0):
<clear_screen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x54,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x54,%edx
call   1040 <memset@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x6,-0x4(%rbp)
jge    11ad <clear_screen+0x5d>
mov    -0x4(%rbp),%esi
xor    %edi,%edi
call   1070 <goto_xy@plt>
mov    -0x10(%rbp),%rdi
mov    $0x54,%esi
call   1050 <send_data@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    117d <clear_screen+0x2d>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_screen>:
push   %rbx
mov    $0x54,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x54,%edx
call   1040 <memset@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1070 <goto_xy@plt>
mov    %rbx,%rdi
mov    $0x54,%esi
call   1050 <send_data@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1070 <goto_xy@plt>
mov    %rbx,%rdi
mov    $0x54,%esi
call   1050 <send_data@plt>
xor    %edi,%edi
mov    $0x2,%esi
call   1070 <goto_xy@plt>
mov    %rbx,%rdi
mov    $0x54,%esi
call   1050 <send_data@plt>
xor    %edi,%edi
mov    $0x3,%esi
call   1070 <goto_xy@plt>
mov    %rbx,%rdi
mov    $0x54,%esi
call   1050 <send_data@plt>
xor    %edi,%edi
mov    $0x4,%esi
call   1070 <goto_xy@plt>
mov    %rbx,%rdi
mov    $0x54,%esi
call   1050 <send_data@plt>
xor    %edi,%edi
mov    $0x5,%esi
call   1070 <goto_xy@plt>
mov    %rbx,%rdi
mov    $0x54,%esi
call   1050 <send_data@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @clear_screen() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i64 @malloc(i32 84)
%4 = inttoptr i64 %3 to i8*
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @memset(i8* %5, i32 0, i32 84)
store i32 0, i32* %1
br label %7
7: ; preds = %15, %0
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 6
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = load i32, i32* %1
%12 = call i32 @goto_xy(i32 0, i32 %11)
%13 = load i8*, i8** %2
%14 = call i32 @send_data(i8* %13, i32 84)
br label %15
15: ; preds = %10
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
br label %7
18: ; preds = %7
%19 = load i8*, i8** %2
%20 = call i32 @free(i8* %19)
ret void
}

LLVM IR (-O2):
define void @clear_screen() {
%1 = tail call i64 @malloc(i32 84)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i32 @memset(i8* %2, i32 0, i32 84)
%4 = tail call i32 @goto_xy(i32 0, i32 0)
%5 = tail call i32 @send_data(i8* %2, i32 84)
%6 = tail call i32 @goto_xy(i32 0, i32 1)
%7 = tail call i32 @send_data(i8* %2, i32 84)
%8 = tail call i32 @goto_xy(i32 0, i32 2)
%9 = tail call i32 @send_data(i8* %2, i32 84)
%10 = tail call i32 @goto_xy(i32 0, i32 3)
%11 = tail call i32 @send_data(i8* %2, i32 84)
%12 = tail call i32 @goto_xy(i32 0, i32 4)
%13 = tail call i32 @send_data(i8* %2, i32 84)
%14 = tail call i32 @goto_xy(i32 0, i32 5)
%15 = tail call i32 @send_data(i8* %2, i32 84)
%16 = tail call i32 @free(i8* %2)
ret void
}