#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*/ fwrite(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int 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];
    char y[4096];
    int r = fread(x, sizeof(short), 4096, stdin);
    if (r == 0)
      break;
    {
      int i;
      for (i = 0; i < r; i++) {
        if (x[i] < -128)
          y[i] = -128;
        else if (x[i] > 127)
          y[i] = 127;
        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    12c6 <main+0x196>
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    -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    12a1 <main+0x171>
movl   $0x0,-0x3018(%rbp)
mov    -0x3018(%rbp),%eax
cmp    -0x3014(%rbp),%eax
jge    127c <main+0x14c>
movslq -0x3018(%rbp),%rax
movswl -0x2010(%rbp,%rax,2),%eax
ff
cmp    $0xffffff80,%eax
jge    1213 <main+0xe3>
movslq -0x3018(%rbp),%rax
movb   $0x80,-0x3010(%rbp,%rax,1)
80
jmp    1263 <main+0x133>
movslq -0x3018(%rbp),%rax
movswl -0x2010(%rbp,%rax,2),%eax
ff
cmp    $0x7f,%eax
jle    123f <main+0x10f>
movslq -0x3018(%rbp),%rax
movb   $0x7f,-0x3010(%rbp,%rax,1)
7f
jmp    125e <main+0x12e>
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    1263 <main+0x133>
jmp    1268 <main+0x138>
mov    -0x3018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3018(%rbp)
jmp    11d5 <main+0xa5>
lea    -0x3010(%rbp),%rdi
mov    -0x3014(%rbp),%edx
mov    0x2d40(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1050 <fwrite@plt>
jmp    1194 <main+0x64>
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd6d(%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    0xea8(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    129c <main+0x16c>
mov    %rsi,0x8(%rsp)
mov    (%rsi),%rdx
lea    0xe9c(%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     127b <main+0x14b>
mov    $0x7f,%r12d
mov    $0x80,%r14d
mov    0x2e14(%rip),%r15
lea    0x10(%rsp),%rbp
lea    0x1010(%rsp),%rbx
jmp    11fc <main+0xcc>
nopl   0x0(%rax,%rax,1)
mov    (%r15),%ecx
mov    %rbp,%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>
test   %eax,%eax
je     127b <main+0x14b>
test   %eax,%eax
jle    11d0 <main+0xa0>
mov    %eax,%ecx
cmp    $0x10,%eax
jae    1210 <main+0xe0>
xor    %edx,%edx
jmp    1250 <main+0x120>
nopl   0x0(%rax,%rax,1)
mov    %ecx,%edx
and    $0xfffffff0,%edx
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
movdqa 0x1010(%rsp,%rsi,2),%xmm0
packsswb 0x1020(%rsp,%rsi,2),%xmm0
movdqa %xmm0,0x10(%rsp,%rsi,1)
add    $0x10,%rsi
cmp    %rsi,%rdx
jne    1220 <main+0xf0>
cmp    %rcx,%rdx
je     11d0 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
movzwl 0x1010(%rsp,%rdx,2),%esi
cmp    $0x7f,%si
cmovge %r12d,%esi
cmp    $0xff81,%si
cmovl  %r14d,%esi
mov    %sil,0x10(%rsp,%rdx,1)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1250 <main+0x120>
jmp    11d0 <main+0xa0>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rax
mov    (%rax),%rdx
lea    0xd92(%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 = [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 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 ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %80
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 = %69, %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 %74
28: ; preds = %21
store i32 0, i32* %9
br label %29
29: ; preds = %66, %28
%30 = load i32, i32* %9
%31 = load i32, i32* %8
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %69
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 = sext i16 %37 to i32
%39 = icmp slt i32 %38, -128
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 -128, i8* %43
br label %65
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 = sext i16 %48 to i32
%50 = icmp sgt i32 %49, 127
br i1 %50, label %51, label %55
51: ; preds = %44
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %53
store i8 127, i8* %54
br label %64
55: ; preds = %44
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [4096 x i16], [4096 x i16]* %6, i64 0, i64 %57
%59 = load i16, i16* %58
%60 = trunc i16 %59 to i8
%61 = load i32, i32* %9
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 %62
store i8 %60, i8* %63
br label %64
64: ; preds = %55, %51
br label %65
65: ; preds = %64, %40
br label %66
66: ; preds = %65
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
br label %29
69: ; preds = %29
%70 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%71 = load i32, i32* %8
%72 = load i32, i32* @stdout
%73 = call i32 @fwrite(i8* %70, i32 1, i32 %71, i32 %72)
br label %21
74: ; preds = %27
%75 = load i32, i32* @stderr
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 0
%78 = load i8*, i8** %77
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %78)
store i32 0, i32* %3
br label %80
80: ; preds = %74, %12
%81 = load i32, i32* %3
ret i32 %81
}

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 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 ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %76
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 %72, label %18
18: ; preds = %9, %66
%19 = phi i32 [ %70, %66 ], [ %16, %9 ]
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %66
21: ; preds = %18
%22 = zext i32 %19 to i64
%23 = icmp ult i32 %19, 16
br i1 %23, label %52, label %24
24: ; preds = %21
%25 = and i64 %22, 4294967280
br label %26
26: ; preds = %26, %24
%27 = phi i64 [ 0, %24 ], [ %48, %26 ]
%28 = getelementptr inbounds [4096 x i16], [4096 x i16]* %3, i64 0, i64 %27
%29 = bitcast i16* %28 to <8 x i16>*
%30 = load <8 x i16>, <8 x i16>* %29
%31 = getelementptr inbounds i16, i16* %28, i64 8
%32 = bitcast i16* %31 to <8 x i16>*
%33 = load <8 x i16>, <8 x i16>* %32
%34 = icmp slt <8 x i16> %30, <i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127>
%35 = icmp slt <8 x i16> %33, <i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127>
%36 = select <8 x i1> %34, <8 x i16> %30, <8 x i16> <i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127>
%37 = select <8 x i1> %35, <8 x i16> %33, <8 x i16> <i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127>
%38 = icmp sgt <8 x i16> %36, <i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128>
%39 = icmp sgt <8 x i16> %37, <i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128>
%40 = select <8 x i1> %38, <8 x i16> %36, <8 x i16> <i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128>
%41 = select <8 x i1> %39, <8 x i16> %37, <8 x i16> <i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128>
%42 = trunc <8 x i16> %40 to <8 x i8>
%43 = trunc <8 x i16> %41 to <8 x i8>
%44 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %27
%45 = bitcast i8* %44 to <8 x i8>*
store <8 x i8> %42, <8 x i8>* %45
%46 = getelementptr inbounds i8, i8* %44, i64 8
%47 = bitcast i8* %46 to <8 x i8>*
store <8 x i8> %43, <8 x i8>* %47
%48 = add nuw i64 %27, 16
%49 = icmp eq i64 %48, %25
br i1 %49, label %50, label %26
50: ; preds = %26
%51 = icmp eq i64 %25, %22
br i1 %51, label %66, label %52
52: ; preds = %21, %50
%53 = phi i64 [ 0, %21 ], [ %25, %50 ]
br label %54
54: ; preds = %52, %54
%55 = phi i64 [ %64, %54 ], [ %53, %52 ]
%56 = getelementptr inbounds [4096 x i16], [4096 x i16]* %3, i64 0, i64 %55
%57 = load i16, i16* %56
%58 = icmp slt i16 %57, 127
%59 = select i1 %58, i16 %57, i16 127
%60 = icmp sgt i16 %59, -128
%61 = select i1 %60, i16 %59, i16 -128
%62 = trunc i16 %61 to i8
%63 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %55
store i8 %62, i8* %63
%64 = add nuw nsw i64 %55, 1
%65 = icmp eq i64 %64, %22
br i1 %65, label %66, label %54
66: ; preds = %54, %50, %18
%67 = load i32, i32* @stdout
%68 = call i32 @fwrite(i8* %13, i32 1, i32 %19, i32 %67)
%69 = load i32, i32* @stdin
%70 = call i32 @fread(i16* %14, i32 2, i32 4096, i32 %69)
%71 = icmp eq i32 %70, 0
br i1 %71, label %72, label %18
72: ; preds = %66, %9
%73 = load i32, i32* @stderr
%74 = load i8*, i8** %1
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %74)
br label %76
76: ; preds = %72, %7
%77 = phi i32 [ 1, %7 ], [ 0, %72 ]
ret i32 %77
}