#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 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;
  }
  for (;;) {
    int x[4096];
    unsigned char 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] > 255)
          y[i] = 255;
        else
          y[i] = (unsigned char)x[i];
      }
    }
    fwrite(y, sizeof(unsigned char), r, stdout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1174 <main+0x44>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1289 <main+0x159>
jmp    1179 <main+0x49>
lea    -0x4010(%rbp),%rdi
mov    0x2e61(%rip),%rax
mov    (%rax),%ecx
mov    $0x4,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %eax,-0x5014(%rbp)
cmpl   $0x0,-0x5014(%rbp)
jne    11b0 <main+0x80>
jmp    1282 <main+0x152>
movl   $0x0,-0x5018(%rbp)
mov    -0x5018(%rbp),%eax
cmp    -0x5014(%rbp),%eax
jge    125d <main+0x12d>
movslq -0x5018(%rbp),%rax
cmpl   $0x0,-0x4010(%rbp,%rax,4)
jge    11f5 <main+0xc5>
movslq -0x5018(%rbp),%rax
movb   $0x0,-0x5010(%rbp,%rax,1)
jmp    1244 <main+0x114>
movslq -0x5018(%rbp),%rax
cmpl   $0xff,-0x4010(%rbp,%rax,4)
jle    1221 <main+0xf1>
movslq -0x5018(%rbp),%rax
movb   $0xff,-0x5010(%rbp,%rax,1)
ff
jmp    123f <main+0x10f>
movslq -0x5018(%rbp),%rax
mov    -0x4010(%rbp,%rax,4),%eax
mov    %al,%cl
movslq -0x5018(%rbp),%rax
mov    %cl,-0x5010(%rbp,%rax,1)
jmp    1244 <main+0x114>
jmp    1249 <main+0x119>
mov    -0x5018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5018(%rbp)
jmp    11ba <main+0x8a>
lea    -0x5010(%rbp),%rdi
mov    -0x5014(%rbp),%edx
mov    0x2d5f(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1050 <fwrite@plt>
jmp    1179 <main+0x49>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x5020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x5000,%rsp
cmp    $0x1,%edi
jle    1164 <main+0x34>
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
lea    0xedb(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    130e <main+0x1de>
mov    0x2e7d(%rip),%r15
mov    (%r15),%ecx
lea    0x1000(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
test   %eax,%eax
je     130c <main+0x1dc>
xor    %ebx,%ebx
movdqa 0xe69(%rip),%xmm6
movdqa 0xe71(%rip),%xmm7
movdqa 0xe78(%rip),%xmm8
mov    0x2e21(%rip),%r13
mov    %rsp,%r14
lea    0x1000(%rsp),%r12
jmp    1209 <main+0xd9>
nopl   0x0(%rax)
mov    0x0(%r13),%ecx
mov    %r14,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1050 <fwrite@plt>
mov    (%r15),%ecx
mov    %r12,%rdi
mov    $0x4,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
movdqa 0xe2f(%rip),%xmm8
movdqa 0xe17(%rip),%xmm7
movdqa 0xdff(%rip),%xmm6
test   %eax,%eax
je     130c <main+0x1dc>
test   %eax,%eax
jle    11c0 <main+0x90>
mov    %eax,%ecx
cmp    $0x8,%eax
jae    1220 <main+0xf0>
xor    %edx,%edx
jmp    12e0 <main+0x1b0>
nopl   0x0(%rax,%rax,1)
mov    %ecx,%edx
and    $0xfffffff8,%edx
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
movdqa 0x1000(%rsp,%rsi,4),%xmm2
movdqa 0x1010(%rsp,%rsi,4),%xmm3
pxor   %xmm0,%xmm0
pcmpgtd %xmm2,%xmm0
packssdw %xmm0,%xmm0
packsswb %xmm0,%xmm0
pxor   %xmm1,%xmm1
pcmpgtd %xmm3,%xmm1
packssdw %xmm1,%xmm1
packsswb %xmm1,%xmm1
movdqa %xmm2,%xmm4
pxor   %xmm7,%xmm4
movdqa %xmm8,%xmm5
pcmpgtd %xmm4,%xmm5
pand   %xmm5,%xmm2
pandn  %xmm6,%xmm5
por    %xmm2,%xmm5
movdqa %xmm3,%xmm2
pxor   %xmm7,%xmm2
movdqa %xmm8,%xmm4
pcmpgtd %xmm2,%xmm4
pand   %xmm4,%xmm3
pandn  %xmm6,%xmm4
por    %xmm3,%xmm4
pand   %xmm6,%xmm5
packuswb %xmm5,%xmm5
packuswb %xmm5,%xmm5
pandn  %xmm5,%xmm0
pand   %xmm6,%xmm4
packuswb %xmm4,%xmm4
packuswb %xmm4,%xmm4
pandn  %xmm4,%xmm1
movd   %xmm0,(%rsp,%rsi,1)
movd   %xmm1,0x4(%rsp,%rsi,1)
add    $0x8,%rsi
cmp    %rsi,%rdx
jne    1230 <main+0x100>
cmp    %rcx,%rdx
je     11c0 <main+0x90>
nopl   (%rax)
mov    0x1000(%rsp,%rdx,4),%esi
cmp    $0xff,%esi
mov    $0xff,%edi
cmovb  %esi,%edi
test   %esi,%esi
cmovs  %ebx,%edi
mov    %dil,(%rsp,%rdx,1)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    12e0 <main+0x1b0>
jmp    11c0 <main+0x90>
xor    %eax,%eax
add    $0x5000,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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