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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x6020,%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   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12cb <main+0x19b>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
lea    -0x4010(%rbp),%rdi
mov    0x2e46(%rip),%rax
mov    (%rax),%ecx
mov    $0x4,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %eax,-0x6014(%rbp)
cmpl   $0x0,-0x6014(%rbp)
jne    11cb <main+0x9b>
jmp    12a6 <main+0x176>
movl   $0x0,-0x6018(%rbp)
mov    -0x6018(%rbp),%eax
cmp    -0x6014(%rbp),%eax
jge    1281 <main+0x151>
movslq -0x6018(%rbp),%rax
cmpl   $0x0,-0x4010(%rbp,%rax,4)
jge    1212 <main+0xe2>
movslq -0x6018(%rbp),%rax
movw   $0x0,-0x6010(%rbp,%rax,2)
jmp    1268 <main+0x138>
movslq -0x6018(%rbp),%rax
cmpl   $0xffff,-0x4010(%rbp,%rax,4)
jle    1240 <main+0x110>
movslq -0x6018(%rbp),%rax
movw   $0xffff,-0x6010(%rbp,%rax,2)
ff ff ff
jmp    1263 <main+0x133>
movslq -0x6018(%rbp),%rax
mov    -0x4010(%rbp,%rax,4),%eax
movzbl %al,%eax
mov    %ax,%cx
movslq -0x6018(%rbp),%rax
mov    %cx,-0x6010(%rbp,%rax,2)
ff
jmp    1268 <main+0x138>
jmp    126d <main+0x13d>
mov    -0x6018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6018(%rbp)
jmp    11d5 <main+0xa5>
lea    -0x6010(%rbp),%rdi
mov    -0x6014(%rbp),%edx
mov    0x2d3b(%rip),%rax
mov    (%rax),%ecx
mov    $0x2,%esi
call   1050 <fwrite@plt>
jmp    1194 <main+0x64>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd68(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x6020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x6008,%rsp
mov    %edi,%eax
mov    0x2e8e(%rip),%rcx
mov    (%rcx),%edi
cmp    $0x2,%eax
jl     116a <main+0x3a>
lea    0xec8(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%r14d
jmp    132a <main+0x1fa>
mov    %rsi,%r15
mov    (%rsi),%rdx
lea    0xebd(%rip),%rsi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e60(%rip),%r13
mov    0x0(%r13),%ecx
lea    0x2000(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
test   %eax,%eax
je     1310 <main+0x1e0>
movdqa 0xe4d(%rip),%xmm6
movdqa 0xe55(%rip),%xmm7
mov    0x2e0e(%rip),%r12
mov    %rsp,%rbp
lea    0x2000(%rsp),%rbx
jmp    1211 <main+0xe1>
nop
mov    (%r12),%ecx
mov    %rbp,%rdi
mov    $0x2,%esi
mov    %eax,%edx
call   1050 <fwrite@plt>
mov    0x0(%r13),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
movdqa 0xe0f(%rip),%xmm7
movdqa 0xdf7(%rip),%xmm6
test   %eax,%eax
je     1310 <main+0x1e0>
test   %eax,%eax
jle    11d0 <main+0xa0>
mov    %eax,%ecx
cmp    $0x8,%eax
jae    1230 <main+0x100>
xor    %edx,%edx
jmp    12f3 <main+0x1c3>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ecx,%edx
and    $0xfffffff8,%edx
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
movdqa 0x2000(%rsp,%rsi,4),%xmm1
movdqa 0x2010(%rsp,%rsi,4),%xmm0
pxor   %xmm2,%xmm2
pcmpgtd %xmm1,%xmm2
packssdw %xmm2,%xmm2
pxor   %xmm3,%xmm3
pcmpgtd %xmm0,%xmm3
packssdw %xmm3,%xmm3
pshuflw $0xe8,%xmm1,%xmm4
pshufhw $0xe8,%xmm4,%xmm4
pshufd $0xe8,%xmm4,%xmm4
pshuflw $0xe8,%xmm0,%xmm5
pshufhw $0xe8,%xmm5,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pand   %xmm6,%xmm4
pandn  %xmm4,%xmm2
pand   %xmm6,%xmm5
pandn  %xmm5,%xmm3
pcmpgtd %xmm7,%xmm1
packssdw %xmm1,%xmm1
pcmpgtd %xmm7,%xmm0
packssdw %xmm0,%xmm0
movdqa %xmm1,%xmm4
pandn  %xmm2,%xmm4
por    %xmm1,%xmm4
movdqa %xmm0,%xmm1
pandn  %xmm3,%xmm1
por    %xmm0,%xmm1
punpcklqdq %xmm1,%xmm4
movdqa %xmm4,(%rsp,%rsi,2)
add    $0x8,%rsi
cmp    %rsi,%rdx
jne    1240 <main+0x110>
cmp    %rcx,%rdx
jne    12f3 <main+0x1c3>
jmp    11d0 <main+0xa0>
xor    %esi,%esi
mov    %si,(%rsp,%rdx,2)
add    $0x1,%rdx
cmp    %rdx,%rcx
je     11d0 <main+0xa0>
mov    0x2000(%rsp,%rdx,4),%edi
test   %edi,%edi
js     12e0 <main+0x1b0>
mov    $0xffff,%si
cmp    $0xffff,%edi
ja     12e2 <main+0x1b2>
movzbl %dil,%esi
jmp    12e2 <main+0x1b2>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xd22(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r14d,%eax
add    $0x6008,%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
@stdout = global i32 0
@.str.2 = [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 i32]
%7 = alloca [4096 x i16]
%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* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %79
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %68, %15
%22 = getelementptr inbounds [4096 x i32], [4096 x i32]* %6, i64 0, i64 0
%23 = load i32, i32* @stdin
%24 = call i32 @fread(i32* %22, i32 4, i32 4096, i32 %23)
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %21
br label %73
28: ; preds = %21
store i32 0, i32* %9
br label %29
29: ; preds = %65, %28
%30 = load i32, i32* %9
%31 = load i32, i32* %8
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %68
33: ; preds = %29
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [4096 x i32], [4096 x i32]* %6, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %33
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [4096 x i16], [4096 x i16]* %7, i64 0, i64 %41
store i16 0, i16* %42
br label %64
43: ; preds = %33
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [4096 x i32], [4096 x i32]* %6, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = icmp sgt i32 %47, 65535
br i1 %48, label %49, label %53
49: ; preds = %43
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [4096 x i16], [4096 x i16]* %7, i64 0, i64 %51
store i16 -1, i16* %52
br label %63
53: ; preds = %43
%54 = load i32, i32* %9
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [4096 x i32], [4096 x i32]* %6, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = trunc i32 %57 to i8
%59 = zext i8 %58 to i16
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [4096 x i16], [4096 x i16]* %7, i64 0, i64 %61
store i16 %59, i16* %62
br label %63
63: ; preds = %53, %49
br label %64
64: ; preds = %63, %39
br label %65
65: ; preds = %64
%66 = load i32, i32* %9
%67 = add nsw i32 %66, 1
store i32 %67, i32* %9
br label %29
68: ; preds = %29
%69 = getelementptr inbounds [4096 x i16], [4096 x i16]* %7, i64 0, i64 0
%70 = load i32, i32* %8
%71 = load i32, i32* @stdout
%72 = call i32 @fwrite(i16* %69, i32 2, i32 %70, i32 %71)
br label %21
73: ; preds = %27
%74 = load i32, i32* @stderr
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 0
%77 = load i8*, i8** %76
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %77)
store i32 0, i32* %3
br label %79
79: ; preds = %73, %12
%80 = load i32, i32* %3
ret i32 %80
}

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
@stdout = global i32 0
@.str.2 = [10 x i8] c"%s: done\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i32]
%4 = alloca [4096 x i16]
%5 = icmp sgt i32 %0, 1
%6 = load i32, i32* @stderr
br i1 %5, label %7, label %9
7: ; preds = %2
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %83
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = bitcast [4096 x i32]* %3 to i8*
%13 = bitcast [4096 x i16]* %4 to i8*
%14 = getelementptr inbounds [4096 x i32], [4096 x i32]* %3, i64 0, i64 0
%15 = load i32, i32* @stdin
%16 = call i32 @fread(i32* %14, i32 4, i32 4096, i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %79, label %18
18: ; preds = %9
%19 = getelementptr inbounds [4096 x i16], [4096 x i16]* %4, i64 0, i64 0
br label %20
20: ; preds = %18, %73
%21 = phi i32 [ %16, %18 ], [ %77, %73 ]
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %73
23: ; preds = %20
%24 = zext i32 %21 to i64
%25 = icmp ult i32 %21, 8
br i1 %25, label %56, label %26
26: ; preds = %23
%27 = and i64 %24, 4294967288
br label %28
28: ; preds = %28, %26
%29 = phi i64 [ 0, %26 ], [ %52, %28 ]
%30 = getelementptr inbounds [4096 x i32], [4096 x i32]* %3, i64 0, i64 %29
%31 = bitcast i32* %30 to <4 x i32>*
%32 = load <4 x i32>, <4 x i32>* %31
%33 = getelementptr inbounds i32, i32* %30, i64 4
%34 = bitcast i32* %33 to <4 x i32>*
%35 = load <4 x i32>, <4 x i32>* %34
%36 = icmp slt <4 x i32> %32, zeroinitializer
%37 = icmp slt <4 x i32> %35, zeroinitializer
%38 = trunc <4 x i32> %32 to <4 x i16>
%39 = trunc <4 x i32> %35 to <4 x i16>
%40 = and <4 x i16> %38, <i16 255, i16 255, i16 255, i16 255>
%41 = and <4 x i16> %39, <i16 255, i16 255, i16 255, i16 255>
%42 = icmp sgt <4 x i32> %32, <i32 65535, i32 65535, i32 65535, i32 65535>
%43 = icmp sgt <4 x i32> %35, <i32 65535, i32 65535, i32 65535, i32 65535>
%44 = select <4 x i1> %36, <4 x i16> zeroinitializer, <4 x i16> %40
%45 = select <4 x i1> %37, <4 x i16> zeroinitializer, <4 x i16> %41
%46 = select <4 x i1> %42, <4 x i16> <i16 -1, i16 -1, i16 -1, i16 -1>, <4 x i16> %44
%47 = select <4 x i1> %43, <4 x i16> <i16 -1, i16 -1, i16 -1, i16 -1>, <4 x i16> %45
%48 = getelementptr inbounds [4096 x i16], [4096 x i16]* %4, i64 0, i64 %29
%49 = bitcast i16* %48 to <4 x i16>*
store <4 x i16> %46, <4 x i16>* %49
%50 = getelementptr inbounds i16, i16* %48, i64 4
%51 = bitcast i16* %50 to <4 x i16>*
store <4 x i16> %47, <4 x i16>* %51
%52 = add nuw i64 %29, 8
%53 = icmp eq i64 %52, %27
br i1 %53, label %54, label %28
54: ; preds = %28
%55 = icmp eq i64 %27, %24
br i1 %55, label %73, label %56
56: ; preds = %23, %54
%57 = phi i64 [ 0, %23 ], [ %27, %54 ]
br label %58
58: ; preds = %56, %68
%59 = phi i64 [ %71, %68 ], [ %57, %56 ]
%60 = getelementptr inbounds [4096 x i32], [4096 x i32]* %3, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = icmp slt i32 %61, 0
br i1 %62, label %68, label %63
63: ; preds = %58
%64 = icmp ugt i32 %61, 65535
br i1 %64, label %68, label %65
65: ; preds = %63
%66 = trunc i32 %61 to i16
%67 = and i16 %66, 255
br label %68
68: ; preds = %63, %58, %65
%69 = phi i16 [ %67, %65 ], [ 0, %58 ], [ -1, %63 ]
%70 = getelementptr inbounds [4096 x i16], [4096 x i16]* %4, i64 0, i64 %59
store i16 %69, i16* %70
%71 = add nuw nsw i64 %59, 1
%72 = icmp eq i64 %71, %24
br i1 %72, label %73, label %58
73: ; preds = %68, %54, %20
%74 = load i32, i32* @stdout
%75 = call i32 @fwrite(i16* %19, i32 2, i32 %21, i32 %74)
%76 = load i32, i32* @stdin
%77 = call i32 @fread(i32* %14, i32 4, i32 4096, i32 %76)
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %20
79: ; preds = %73, %9
%80 = load i32, i32* @stderr
%81 = load i8*, i8** %1
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %81)
br label %83
83: ; preds = %79, %7
%84 = phi i32 [ 1, %7 ], [ 0, %79 ]
ret i32 %84
}