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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3020,%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    1297 <main+0x167>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
lea    -0x2010(%rbp),%rdi
mov    0x2e46(%rip),%rax
mov    (%rax),%ecx
mov    $0x2,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %eax,-0x3014(%rbp)
cmpl   $0x0,-0x3014(%rbp)
jne    11cb <main+0x9b>
jmp    1272 <main+0x142>
movl   $0x0,-0x3018(%rbp)
mov    -0x3018(%rbp),%eax
cmp    -0x3014(%rbp),%eax
jge    124d <main+0x11d>
movslq -0x3018(%rbp),%rax
movzwl -0x2010(%rbp,%rax,2),%eax
ff
cmp    $0xff,%eax
jle    1215 <main+0xe5>
movslq -0x3018(%rbp),%rax
movb   $0xff,-0x3010(%rbp,%rax,1)
ff
jmp    1234 <main+0x104>
movslq -0x3018(%rbp),%rax
mov    -0x2010(%rbp,%rax,2),%ax
ff
mov    %al,%cl
movslq -0x3018(%rbp),%rax
mov    %cl,-0x3010(%rbp,%rax,1)
jmp    1239 <main+0x109>
mov    -0x3018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3018(%rbp)
jmp    11d5 <main+0xa5>
lea    -0x3010(%rbp),%rdi
mov    -0x3014(%rbp),%edx
mov    0x2d6f(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1050 <fwrite@plt>
jmp    1194 <main+0x64>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd9a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x3020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3018,%rsp
mov    %edi,%eax
mov    0x2e8e(%rip),%rcx
mov    (%rcx),%edi
cmp    $0x2,%eax
jl     1169 <main+0x39>
lea    0xeb8(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    1360 <main+0x230>
mov    %rsi,0x8(%rsp)
mov    (%rsi),%rdx
lea    0xeaa(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e62(%rip),%r13
mov    0x0(%r13),%ecx
lea    0x1010(%rsp),%rdi
mov    $0x2,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
test   %eax,%eax
je     133f <main+0x20f>
mov    $0xff,%r12d
movdqa 0xe49(%rip),%xmm5
mov    0x2e12(%rip),%r14
lea    0x10(%rsp),%r15
lea    0x1010(%rsp),%rbx
jmp    1208 <main+0xd8>
nopl   (%rax)
mov    (%r14),%ecx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1050 <fwrite@plt>
mov    0x0(%r13),%ecx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
movdqa 0xe00(%rip),%xmm5
test   %eax,%eax
je     133f <main+0x20f>
test   %eax,%eax
jle    11d0 <main+0xa0>
mov    %eax,%ecx
cmp    $0x10,%eax
jae    1220 <main+0xf0>
xor    %edx,%edx
jmp    1310 <main+0x1e0>
nopw   0x0(%rax,%rax,1)
mov    %ecx,%edx
and    $0xfffffff0,%edx
lea    -0x10(%rdx),%rsi
mov    %rsi,%rbp
shr    $0x4,%rbp
add    $0x1,%rbp
test   %rsi,%rsi
je     1335 <main+0x205>
mov    %rbp,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
movdqa 0x1010(%rsp,%rsi,2),%xmm0
movdqa 0x1020(%rsp,%rsi,2),%xmm1
movdqa 0x1030(%rsp,%rsi,2),%xmm2
movdqa 0x1040(%rsp,%rsi,2),%xmm3
movdqa %xmm0,%xmm4
psubusw %xmm5,%xmm4
psubw  %xmm4,%xmm0
movdqa %xmm1,%xmm4
psubusw %xmm5,%xmm4
psubw  %xmm4,%xmm1
packuswb %xmm1,%xmm0
movdqa %xmm0,0x10(%rsp,%rsi,1)
movdqa %xmm2,%xmm0
psubusw %xmm5,%xmm0
psubw  %xmm0,%xmm2
movdqa %xmm3,%xmm0
psubusw %xmm5,%xmm0
psubw  %xmm0,%xmm3
packuswb %xmm3,%xmm2
movdqa %xmm2,0x20(%rsp,%rsi,1)
add    $0x20,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1250 <main+0x120>
test   $0x1,%bpl
je     12fc <main+0x1cc>
movdqa 0x1010(%rsp,%rsi,2),%xmm0
movdqa 0x1020(%rsp,%rsi,2),%xmm1
movdqa %xmm0,%xmm2
psubusw %xmm5,%xmm2
psubw  %xmm2,%xmm0
movdqa %xmm1,%xmm2
psubusw %xmm5,%xmm2
psubw  %xmm2,%xmm1
packuswb %xmm1,%xmm0
movdqa %xmm0,0x10(%rsp,%rsi,1)
cmp    %rcx,%rdx
je     11d0 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
nop
movzwl 0x1010(%rsp,%rdx,2),%esi
cmp    $0xff,%esi
cmovae %r12d,%esi
mov    %sil,0x10(%rsp,%rdx,1)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1310 <main+0x1e0>
jmp    11d0 <main+0xa0>
xor    %esi,%esi
test   $0x1,%bpl
jne    12c8 <main+0x198>
jmp    12fc <main+0x1cc>
mov    0x2c92(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rax
mov    (%rax),%rdx
lea    0xcdc(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x3018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c"< input > output\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 i16]
%7 = alloca [4096 x i8]
%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 ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %68
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 = %57, %15
%22 = getelementptr inbounds [4096 x i16], [4096 x i16]* %6, i64 0, i64 0
%23 = load i32, i32* @stdin
%24 = call i32 @fread(i16* %22, i32 2, 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 %62
28: ; preds = %21
store i32 0, i32* %9
br label %29
29: ; preds = %54, %28
%30 = load i32, i32* %9
%31 = load i32, i32* %8
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %57
33: ; preds = %29
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [4096 x i16], [4096 x i16]* %6, i64 0, i64 %35
%37 = load i16, i16* %36
%38 = zext i16 %37 to i32
%39 = icmp sgt i32 %38, 255
br i1 %39, label %40, label %44
40: ; preds = %33
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %42
store i8 -1, i8* %43
br label %53
44: ; preds = %33
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [4096 x i16], [4096 x i16]* %6, i64 0, i64 %46
%48 = load i16, i16* %47
%49 = trunc i16 %48 to i8
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %51
store i8 %49, i8* %52
br label %53
53: ; preds = %44, %40
br label %54
54: ; preds = %53
%55 = load i32, i32* %9
%56 = add nsw i32 %55, 1
store i32 %56, i32* %9
br label %29
57: ; preds = %29
%58 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%59 = load i32, i32* %8
%60 = load i32, i32* @stdout
%61 = call i32 @fwrite(i8* %58, i32 1, i32 %59, i32 %60)
br label %21
62: ; preds = %27
%63 = load i32, i32* @stderr
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 0
%66 = load i8*, i8** %65
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %66)
store i32 0, i32* %3
br label %68
68: ; preds = %62, %12
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"< input > output\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 i16]
%4 = alloca [4096 x i8]
%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 ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %116
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 i16]* %3 to i8*
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%14 = getelementptr inbounds [4096 x i16], [4096 x i16]* %3, i64 0, i64 0
%15 = load i32, i32* @stdin
%16 = call i32 @fread(i16* %14, i32 2, i32 4096, i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %112, label %18
18: ; preds = %9, %106
%19 = phi i32 [ %110, %106 ], [ %16, %9 ]
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %106
21: ; preds = %18
%22 = zext i32 %19 to i64
%23 = icmp ult i32 %19, 16
br i1 %23, label %94, label %24
24: ; preds = %21
%25 = and i64 %22, 4294967280
%26 = add nsw i64 %25, -16
%27 = lshr exact i64 %26, 4
%28 = add nuw nsw i64 %27, 1
%29 = and i64 %28, 1
%30 = icmp eq i64 %26, 0
br i1 %30, label %72, label %31
31: ; preds = %24
%32 = and i64 %28, 2305843009213693950
br label %33
33: ; preds = %33, %31
%34 = phi i64 [ 0, %31 ], [ %69, %33 ]
%35 = phi i64 [ 0, %31 ], [ %70, %33 ]
%36 = getelementptr inbounds [4096 x i16], [4096 x i16]* %3, i64 0, i64 %34
%37 = bitcast i16* %36 to <8 x i16>*
%38 = load <8 x i16>, <8 x i16>* %37
%39 = getelementptr inbounds i16, i16* %36, i64 8
%40 = bitcast i16* %39 to <8 x i16>*
%41 = load <8 x i16>, <8 x i16>* %40
%42 = icmp ult <8 x i16> %38, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
%43 = icmp ult <8 x i16> %41, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
%44 = select <8 x i1> %42, <8 x i16> %38, <8 x i16> <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
%45 = select <8 x i1> %43, <8 x i16> %41, <8 x i16> <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
%46 = trunc <8 x i16> %44 to <8 x i8>
%47 = trunc <8 x i16> %45 to <8 x i8>
%48 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %34
%49 = bitcast i8* %48 to <8 x i8>*
store <8 x i8> %46, <8 x i8>* %49
%50 = getelementptr inbounds i8, i8* %48, i64 8
%51 = bitcast i8* %50 to <8 x i8>*
store <8 x i8> %47, <8 x i8>* %51
%52 = or i64 %34, 16
%53 = getelementptr inbounds [4096 x i16], [4096 x i16]* %3, i64 0, i64 %52
%54 = bitcast i16* %53 to <8 x i16>*
%55 = load <8 x i16>, <8 x i16>* %54
%56 = getelementptr inbounds i16, i16* %53, i64 8
%57 = bitcast i16* %56 to <8 x i16>*
%58 = load <8 x i16>, <8 x i16>* %57
%59 = icmp ult <8 x i16> %55, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
%60 = icmp ult <8 x i16> %58, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
%61 = select <8 x i1> %59, <8 x i16> %55, <8 x i16> <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
%62 = select <8 x i1> %60, <8 x i16> %58, <8 x i16> <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
%63 = trunc <8 x i16> %61 to <8 x i8>
%64 = trunc <8 x i16> %62 to <8 x i8>
%65 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %52
%66 = bitcast i8* %65 to <8 x i8>*
store <8 x i8> %63, <8 x i8>* %66
%67 = getelementptr inbounds i8, i8* %65, i64 8
%68 = bitcast i8* %67 to <8 x i8>*
store <8 x i8> %64, <8 x i8>* %68
%69 = add nuw i64 %34, 32
%70 = add i64 %35, 2
%71 = icmp eq i64 %70, %32
br i1 %71, label %72, label %33
72: ; preds = %33, %24
%73 = phi i64 [ 0, %24 ], [ %69, %33 ]
%74 = icmp eq i64 %29, 0
br i1 %74, label %92, label %75
75: ; preds = %72
%76 = getelementptr inbounds [4096 x i16], [4096 x i16]* %3, i64 0, i64 %73
%77 = bitcast i16* %76 to <8 x i16>*
%78 = load <8 x i16>, <8 x i16>* %77
%79 = getelementptr inbounds i16, i16* %76, i64 8
%80 = bitcast i16* %79 to <8 x i16>*
%81 = load <8 x i16>, <8 x i16>* %80
%82 = icmp ult <8 x i16> %78, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
%83 = icmp ult <8 x i16> %81, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
%84 = select <8 x i1> %82, <8 x i16> %78, <8 x i16> <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
%85 = select <8 x i1> %83, <8 x i16> %81, <8 x i16> <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
%86 = trunc <8 x i16> %84 to <8 x i8>
%87 = trunc <8 x i16> %85 to <8 x i8>
%88 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %73
%89 = bitcast i8* %88 to <8 x i8>*
store <8 x i8> %86, <8 x i8>* %89
%90 = getelementptr inbounds i8, i8* %88, i64 8
%91 = bitcast i8* %90 to <8 x i8>*
store <8 x i8> %87, <8 x i8>* %91
br label %92
92: ; preds = %72, %75
%93 = icmp eq i64 %25, %22
br i1 %93, label %106, label %94
94: ; preds = %21, %92
%95 = phi i64 [ 0, %21 ], [ %25, %92 ]
br label %96
96: ; preds = %94, %96
%97 = phi i64 [ %104, %96 ], [ %95, %94 ]
%98 = getelementptr inbounds [4096 x i16], [4096 x i16]* %3, i64 0, i64 %97
%99 = load i16, i16* %98
%100 = icmp ult i16 %99, 255
%101 = select i1 %100, i16 %99, i16 255
%102 = trunc i16 %101 to i8
%103 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %97
store i8 %102, i8* %103
%104 = add nuw nsw i64 %97, 1
%105 = icmp eq i64 %104, %22
br i1 %105, label %106, label %96
106: ; preds = %96, %92, %18
%107 = load i32, i32* @stdout
%108 = call i32 @fwrite(i8* %13, i32 1, i32 %19, i32 %107)
%109 = load i32, i32* @stdin
%110 = call i32 @fread(i16* %14, i32 2, i32 4096, i32 %109)
%111 = icmp eq i32 %110, 0
br i1 %111, label %112, label %18
112: ; preds = %106, %9
%113 = load i32, i32* @stderr
%114 = load i8*, i8** %1
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %114)
br label %116
116: ; preds = %112, %7
%117 = phi i32 [ 1, %7 ], [ 0, %112 ]
ret i32 %117
}