#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 EXIT_FAILURE;
int /*<<< orphan*/ O_RDONLY;
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ system(char *);
int main(int argc, char const *argv[]) {
  char tmp[1944];
  int i;
  int index = open("/dev/asciistreamer", O_RDONLY);
  if (index == -1) {
    printf("Cannot open device!");
    return EXIT_FAILURE;
  }
  int result;
  while ((result = read(index, tmp, 1944)) > 0) {
    system("clear");
    for (i = 0; i < 1944; i++) {
      printf("%c", tmp[i]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
lea    0xe97(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x7b8(%rbp)
cmpl   $0xffffffff,-0x7b8(%rbp)
jne    11a0 <main+0x60>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    122e <main+0xee>
jmp    11a5 <main+0x65>
mov    -0x7b8(%rbp),%edi
lea    -0x7b0(%rbp),%rsi
mov    $0x798,%edx
call   1050 <read@plt>
mov    %eax,-0x7bc(%rbp)
cmp    $0x0,%eax
jle    1227 <main+0xe7>
lea    0xe55(%rip),%rdi
call   1030 <system@plt>
movl   $0x0,-0x7b4(%rbp)
cmpl   $0x798,-0x7b4(%rbp)
jge    1222 <main+0xe2>
movslq -0x7b4(%rbp),%rax
movsbl -0x7b0(%rbp,%rax,1),%esi
ff
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x7b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7b4(%rbp)
jmp    11e1 <main+0xa1>
jmp    11a5 <main+0x65>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x7c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x798,%rsp
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
lea    0xe93(%rip),%rdi
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     11dd <main+0x8d>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x798,%edx
call   1060 <read@plt>
test   %eax,%eax
jle    11d9 <main+0x89>
lea    0xe94(%rip),%r14
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <system@plt>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl (%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x798,%rbx
jne    11b0 <main+0x60>
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x798,%edx
call   1060 <read@plt>
test   %eax,%eax
jg     11a0 <main+0x50>
xor    %eax,%eax
jmp    11f4 <main+0xa4>
lea    0xe2f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%eax
add    $0x798,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"/dev/asciistreamer\00"
@O_RDONLY = global i32 0
@.str.1 = [20 x i8] c"Cannot open device!\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [6 x i8] c"clear\00"
@.str.3 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1944 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @O_RDONLY
%11 = call i32 @open(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %10)
store i32 %11, i32* %8
%12 = load i32, i32* %8
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
store i32 %16, i32* %3
br label %40
17: ; preds = %2
br label %18
18: ; preds = %38, %17
%19 = load i32, i32* %8
%20 = getelementptr inbounds [1944 x i8], [1944 x i8]* %6, i64 0, i64 0
%21 = call i32 @read(i32 %19, i8* %20, i32 1944)
store i32 %21, i32* %9
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %39
23: ; preds = %18
%24 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %7
br label %25
25: ; preds = %35, %23
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 1944
br i1 %27, label %28, label %38
28: ; preds = %25
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1944 x i8], [1944 x i8]* %6, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %28
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %25
38: ; preds = %25
br label %18
39: ; preds = %18
store i32 0, i32* %3
br label %40
40: ; preds = %39, %14
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [19 x i8] c"/dev/asciistreamer\00"
@O_RDONLY = global i32 0
@.str.1 = [20 x i8] c"Cannot open device!\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [6 x i8] c"clear\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1944 x i8]
%4 = getelementptr inbounds [1944 x i8], [1944 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @O_RDONLY
%6 = tail call i32 @open(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = call i32 @read(i32 %6, i8* %4, i32 1944)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %17, label %27
11: ; preds = %2
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
br label %27
14: ; preds = %19
%15 = call i32 @read(i32 %6, i8* %4, i32 1944)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %8, %14
%18 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %19
%20 = phi i64 [ 0, %17 ], [ %25, %19 ]
%21 = getelementptr inbounds [1944 x i8], [1944 x i8]* %3, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = tail call i32 @putchar(i32 %23)
%25 = add nuw nsw i64 %20, 1
%26 = icmp eq i64 %25, 1944
br i1 %26, label %14, label %19
27: ; preds = %14, %8, %11
%28 = phi i32 [ %13, %11 ], [ 0, %8 ], [ 0, %14 ]
ret i32 %28
}