#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(double *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(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 (;;) {
    double x[4096];
    short y[4096];
    int r = fread(x, sizeof(double), 4096, stdin);
    if (r == 0)
      break;
    {
      int i;
      for (i = 0; i < r; i++) {
        if (x[i] < -32768.0)
          y[i] = -32768;
        else if (x[i] > 32767.0)
          y[i] = 32767;
        else
          y[i] = (short)x[i];
      }
    }
    fwrite(y, sizeof(short), r, stdout);
  }
  fprintf(stderr, "%s: done\n", argv[0]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa020,%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    0xead(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12da <main+0x1aa>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe97(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
lea    -0x8010(%rbp),%rdi
mov    0x2e46(%rip),%rax
mov    (%rax),%ecx
mov    $0x8,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %eax,-0xa014(%rbp)
cmpl   $0x0,-0xa014(%rbp)
jne    11cb <main+0x9b>
jmp    12bc <main+0x18c>
movl   $0x0,-0xa018(%rbp)
mov    -0xa018(%rbp),%eax
cmp    -0xa014(%rbp),%eax
jge    1297 <main+0x167>
movslq -0xa018(%rbp),%rax
movsd  0xe0a(%rip),%xmm0
ucomisd -0x8010(%rbp,%rax,8),%xmm0
ff ff
jbe    121b <main+0xeb>
movslq -0xa018(%rbp),%rax
movw   $0x8000,-0xa010(%rbp,%rax,2)
jmp    127e <main+0x14e>
movslq -0xa018(%rbp),%rax
movsd  -0x8010(%rbp,%rax,8),%xmm0
ff ff
movsd  0xdd5(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1253 <main+0x123>
movslq -0xa018(%rbp),%rax
movw   $0x7fff,-0xa010(%rbp,%rax,2)
ff ff 7f
jmp    1279 <main+0x149>
movslq -0xa018(%rbp),%rax
movsd  -0x8010(%rbp,%rax,8),%xmm0
ff ff
cvttsd2si %xmm0,%eax
mov    %ax,%cx
movslq -0xa018(%rbp),%rax
mov    %cx,-0xa010(%rbp,%rax,2)
ff
jmp    127e <main+0x14e>
jmp    1283 <main+0x153>
mov    -0xa018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa018(%rbp)
jmp    11d5 <main+0xa5>
lea    -0xa010(%rbp),%rdi
mov    -0xa014(%rbp),%edx
mov    0x2d25(%rip),%rax
mov    (%rax),%ecx
mov    $0x2,%esi
call   1050 <fwrite@plt>
jmp    1194 <main+0x64>
mov    0x2d15(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd5e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0xa020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa008,%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    12d2 <main+0x1a2>
mov    %rsi,%r15
mov    (%rsi),%rdx
lea    0xeae(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e64(%rip),%r13
mov    0x0(%r13),%ecx
lea    0x2000(%rsp),%rdi
mov    $0x8,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
test   %eax,%eax
je     12b6 <main+0x186>
movsd  0xe51(%rip),%xmm1
movsd  0xe51(%rip),%xmm2
mov    0x2e12(%rip),%r12
mov    %rsp,%r14
lea    0x2000(%rsp),%rbx
jmp    1215 <main+0xe5>
nopl   0x0(%rax,%rax,1)
mov    %dx,(%rsp,%rcx,2)
mov    (%r12),%ecx
mov    %r14,%rdi
mov    $0x2,%esi
mov    %eax,%edx
call   1050 <fwrite@plt>
mov    0x0(%r13),%ecx
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
movsd  0xe03(%rip),%xmm2
movsd  0xdf3(%rip),%xmm1
test   %eax,%eax
je     12b6 <main+0x186>
test   %eax,%eax
jle    11d4 <main+0xa4>
mov    %eax,%edx
cmp    $0x1,%eax
jne    1250 <main+0x120>
xor    %ecx,%ecx
test   $0x1,%dl
je     11d4 <main+0xa4>
movsd  0x2000(%rsp,%rcx,8),%xmm0
mov    $0x8000,%dx
ucomisd %xmm0,%xmm1
ja     11d0 <main+0xa0>
mov    $0x7fff,%dx
ucomisd %xmm2,%xmm0
ja     11d0 <main+0xa0>
cvttsd2si %xmm0,%edx
jmp    11d0 <main+0xa0>
nopw   0x0(%rax,%rax,1)
mov    %edx,%esi
and    $0xfffffffe,%esi
xor    %ecx,%ecx
jmp    126e <main+0x13e>
nopl   0x0(%rax)
mov    %di,0x2(%rsp,%rcx,2)
add    $0x2,%rcx
cmp    %rcx,%rsi
je     1222 <main+0xf2>
movsd  0x2000(%rsp,%rcx,8),%xmm0
mov    $0x8000,%di
ucomisd %xmm0,%xmm1
mov    $0x8000,%bp
ja     1293 <main+0x163>
mov    $0x7fff,%bp
ucomisd %xmm2,%xmm0
ja     1293 <main+0x163>
cvttsd2si %xmm0,%ebp
mov    %bp,(%rsp,%rcx,2)
movsd  0x2008(%rsp,%rcx,8),%xmm0
ucomisd %xmm0,%xmm1
ja     1260 <main+0x130>
mov    $0x7fff,%di
ucomisd %xmm2,%xmm0
ja     1260 <main+0x130>
cvttsd2si %xmm0,%edi
jmp    1260 <main+0x130>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xd68(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0xa008,%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 = [13 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 double]
%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 %78
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 ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %67, %15
%22 = getelementptr inbounds [4096 x double], [4096 x double]* %6, i64 0, i64 0
%23 = load i32, i32* @stdin
%24 = call i32 @fread(double* %22, i32 8, 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 %72
28: ; preds = %21
store i32 0, i32* %9
br label %29
29: ; preds = %64, %28
%30 = load i32, i32* %9
%31 = load i32, i32* %8
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %67
33: ; preds = %29
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [4096 x double], [4096 x double]* %6, i64 0, i64 %35
%37 = load double, double* %36
%38 = fcmp olt double %37, -3.276800e+04
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 -32768, i16* %42
br label %63
43: ; preds = %33
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [4096 x double], [4096 x double]* %6, i64 0, i64 %45
%47 = load double, double* %46
%48 = fcmp ogt double %47, 3.276700e+04
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 32767, i16* %52
br label %62
53: ; preds = %43
%54 = load i32, i32* %9
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [4096 x double], [4096 x double]* %6, i64 0, i64 %55
%57 = load double, double* %56
%58 = fptosi double %57 to i16
%59 = load i32, i32* %9
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [4096 x i16], [4096 x i16]* %7, i64 0, i64 %60
store i16 %58, i16* %61
br label %62
62: ; preds = %53, %49
br label %63
63: ; preds = %62, %39
br label %64
64: ; preds = %63
%65 = load i32, i32* %9
%66 = add nsw i32 %65, 1
store i32 %66, i32* %9
br label %29
67: ; preds = %29
%68 = getelementptr inbounds [4096 x i16], [4096 x i16]* %7, i64 0, i64 0
%69 = load i32, i32* %8
%70 = load i32, i32* @stdout
%71 = call i32 @fwrite(i16* %68, i32 2, i32 %69, i32 %70)
br label %21
72: ; preds = %27
%73 = load i32, i32* @stderr
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 0
%76 = load i8*, i8** %75
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %76)
br label %78
78: ; preds = %72, %12
%79 = load i32, i32* %3
ret i32 %79
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"< entrada > salida\0A\00"
@.str.1 = [13 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 double]
%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 %80
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = bitcast [4096 x double]* %3 to i8*
%13 = bitcast [4096 x i16]* %4 to i8*
%14 = getelementptr inbounds [4096 x double], [4096 x double]* %3, i64 0, i64 0
%15 = load i32, i32* @stdin
%16 = call i32 @fread(double* %14, i32 8, i32 4096, i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %76, 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, %70
%21 = phi i32 [ %16, %18 ], [ %74, %70 ]
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %70
23: ; preds = %20
%24 = zext i32 %21 to i64
%25 = and i64 %24, 1
%26 = icmp eq i32 %21, 1
br i1 %26, label %56, label %27
27: ; preds = %23
%28 = and i64 %24, 4294967294
br label %29
29: ; preds = %50, %27
%30 = phi i64 [ 0, %27 ], [ %53, %50 ]
%31 = phi i64 [ 0, %27 ], [ %54, %50 ]
%32 = getelementptr inbounds [4096 x double], [4096 x double]* %3, i64 0, i64 %30
%33 = load double, double* %32
%34 = fcmp olt double %33, -3.276800e+04
br i1 %34, label %39, label %35
35: ; preds = %29
%36 = fcmp ogt double %33, 3.276700e+04
br i1 %36, label %39, label %37
37: ; preds = %35
%38 = fptosi double %33 to i16
br label %39
39: ; preds = %35, %29, %37
%40 = phi i16 [ %38, %37 ], [ -32768, %29 ], [ 32767, %35 ]
%41 = getelementptr inbounds [4096 x i16], [4096 x i16]* %4, i64 0, i64 %30
store i16 %40, i16* %41
%42 = or i64 %30, 1
%43 = getelementptr inbounds [4096 x double], [4096 x double]* %3, i64 0, i64 %42
%44 = load double, double* %43
%45 = fcmp olt double %44, -3.276800e+04
br i1 %45, label %50, label %46
46: ; preds = %39
%47 = fcmp ogt double %44, 3.276700e+04
br i1 %47, label %50, label %48
48: ; preds = %46
%49 = fptosi double %44 to i16
br label %50
50: ; preds = %48, %46, %39
%51 = phi i16 [ %49, %48 ], [ -32768, %39 ], [ 32767, %46 ]
%52 = getelementptr inbounds [4096 x i16], [4096 x i16]* %4, i64 0, i64 %42
store i16 %51, i16* %52
%53 = add nuw nsw i64 %30, 2
%54 = add i64 %31, 2
%55 = icmp eq i64 %54, %28
br i1 %55, label %56, label %29
56: ; preds = %50, %23
%57 = phi i64 [ 0, %23 ], [ %53, %50 ]
%58 = icmp eq i64 %25, 0
br i1 %58, label %70, label %59
59: ; preds = %56
%60 = getelementptr inbounds [4096 x double], [4096 x double]* %3, i64 0, i64 %57
%61 = load double, double* %60
%62 = fcmp olt double %61, -3.276800e+04
br i1 %62, label %67, label %63
63: ; preds = %59
%64 = fcmp ogt double %61, 3.276700e+04
br i1 %64, label %67, label %65
65: ; preds = %63
%66 = fptosi double %61 to i16
br label %67
67: ; preds = %65, %63, %59
%68 = phi i16 [ %66, %65 ], [ -32768, %59 ], [ 32767, %63 ]
%69 = getelementptr inbounds [4096 x i16], [4096 x i16]* %4, i64 0, i64 %57
store i16 %68, i16* %69
br label %70
70: ; preds = %67, %56, %20
%71 = load i32, i32* @stdout
%72 = call i32 @fwrite(i16* %19, i32 2, i32 %21, i32 %71)
%73 = load i32, i32* @stdin
%74 = call i32 @fread(double* %14, i32 8, i32 4096, i32 %73)
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %20
76: ; preds = %70, %9
%77 = load i32, i32* @stderr
%78 = load i8*, i8** %1
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %78)
br label %80
80: ; preds = %76, %7
%81 = phi i32 [ 1, %7 ], [ 0, %76 ]
ret i32 %81
}