#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(short **, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, short);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
main(int argc, char *argv[]) {
  if (argc > 1) {
    fprintf(stderr, "< entrada > salida\n");
    return 1;
  }
  fprintf(stderr, "%s: running ...\n", argv[0]);
  for (;;) {
    short x[4096];
    int r = fread(&x, sizeof(short), 1, stdin);
    if (r == 0)
      break;
    {
      int i;
      for (i = 0; i < r; i++) {
        printf("%d\n", x[i]);
      }
    }
  }
  fprintf(stderr, "%s: done\n", argv[0]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1176 <main+0x46>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1240 <main+0x110>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    -0x2010(%rbp),%rdi
mov    0x2e46(%rip),%rax
mov    (%rax),%ecx
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,-0x2014(%rbp)
cmpl   $0x0,-0x2014(%rbp)
jne    11cb <main+0x9b>
jmp    121b <main+0xeb>
movl   $0x0,-0x2018(%rbp)
mov    -0x2018(%rbp),%eax
cmp    -0x2014(%rbp),%eax
jge    1216 <main+0xe6>
movslq -0x2018(%rbp),%rax
lea    0xe30(%rip),%rdi
movswl -0x2010(%rbp,%rax,2),%esi
ff
call   1040 <printf@plt>
mov    -0x2018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2018(%rbp)
jmp    11d5 <main+0xa5>
jmp    1194 <main+0x64>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdf7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2008,%rsp
mov    %edi,%eax
mov    0x2e8e(%rip),%rcx
mov    (%rcx),%edi
cmp    $0x2,%eax
jl     1169 <main+0x39>
lea    0xea8(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    1214 <main+0xe4>
mov    %rsi,%r15
mov    (%rsi),%rdx
lea    0xe9e(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2e64(%rip),%r13
mov    0x0(%r13),%ecx
mov    %rsp,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
test   %eax,%eax
je     11f8 <main+0xc8>
lea    0xe80(%rip),%rbp
mov    %rsp,%rbx
jmp    11ca <main+0x9a>
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%ecx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
test   %eax,%eax
je     11f8 <main+0xc8>
test   %eax,%eax
jle    11b0 <main+0x80>
mov    %eax,%r12d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movswl (%rsp,%r14,2),%esi
mov    %rbp,%rdi
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%r12
jne    11e0 <main+0xb0>
jmp    11b0 <main+0x80>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xe1e(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x2008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"< entrada > salida\0A\00"
@.str.1 = [17 x i8] c"%s: running ...\0A\00"
@stdin = global i32 0
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [10 x i8] c"%s: done\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4096 x i16]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %48
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %41, %14
%21 = bitcast [4096 x i16]* %6 to i16**
%22 = load i32, i32* @stdin
%23 = call i32 @fread(i16** %21, i32 2, i32 1, i32 %22)
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %20
br label %42
27: ; preds = %20
store i32 0, i32* %8
br label %28
28: ; preds = %38, %27
%29 = load i32, i32* %8
%30 = load i32, i32* %7
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %41
32: ; preds = %28
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [4096 x i16], [4096 x i16]* %6, i64 0, i64 %34
%36 = load i16, i16* %35
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i16 signext %36)
br label %38
38: ; preds = %32
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %28
41: ; preds = %28
br label %20
42: ; preds = %26
%43 = load i32, i32* @stderr
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %46)
store i32 0, i32* %3
br label %48
48: ; preds = %42, %11
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"< entrada > salida\0A\00"
@.str.1 = [17 x i8] c"%s: running ...\0A\00"
@stdin = global i32 0
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [10 x i8] c"%s: done\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i16]
%4 = icmp sgt i32 %0, 1
%5 = load i32, i32* @stderr
br i1 %4, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %36
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = bitcast [4096 x i16]* %3 to i8*
%12 = bitcast [4096 x i16]* %3 to i16**
%13 = load i32, i32* @stdin
%14 = call i32 @fread(i16** %12, i32 2, i32 1, i32 %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %32, label %16
16: ; preds = %8, %28
%17 = phi i32 [ %30, %28 ], [ %14, %8 ]
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = zext i32 %17 to i64
br label %21
21: ; preds = %19, %21
%22 = phi i64 [ 0, %19 ], [ %26, %21 ]
%23 = getelementptr inbounds [4096 x i16], [4096 x i16]* %3, i64 0, i64 %22
%24 = load i16, i16* %23
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i16 signext %24)
%26 = add nuw nsw i64 %22, 1
%27 = icmp eq i64 %26, %20
br i1 %27, label %28, label %21
28: ; preds = %21, %16
%29 = load i32, i32* @stdin
%30 = call i32 @fread(i16** %12, i32 2, i32 1, i32 %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %16
32: ; preds = %28, %8
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %1
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %32, %6
%37 = phi i32 [ 1, %6 ], [ 0, %32 ]
ret i32 %37
}