#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(float *, 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");
    fprintf(stderr, "Transforma float's en int's\n");
    return 1;
  }
  fprintf(stderr, "%s: running\n", argv[0]);
  for (;;) {
    float x[4096];
    short y[4096];
    int r = fread(x, sizeof(float), 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]);
  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    118d <main+0x5d>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xead(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1304 <main+0x1d4>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
lea    -0x4010(%rbp),%rdi
mov    0x2e2f(%rip),%rax
mov    (%rax),%ecx
mov    $0x4,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %eax,-0x6014(%rbp)
cmpl   $0x0,-0x6014(%rbp)
jne    11e2 <main+0xb2>
jmp    12df <main+0x1af>
movl   $0x0,-0x6018(%rbp)
mov    -0x6018(%rbp),%eax
cmp    -0x6014(%rbp),%eax
jge    12ba <main+0x18a>
movslq -0x6018(%rbp),%rax
movss  -0x4010(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm1
movsd  0xde6(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    123a <main+0x10a>
movslq -0x6018(%rbp),%rax
movw   $0x8000,-0x6010(%rbp,%rax,2)
jmp    12a1 <main+0x171>
movslq -0x6018(%rbp),%rax
movss  -0x4010(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
movsd  0xdb2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1276 <main+0x146>
movslq -0x6018(%rbp),%rax
movw   $0x7fff,-0x6010(%rbp,%rax,2)
ff ff 7f
jmp    129c <main+0x16c>
movslq -0x6018(%rbp),%rax
movss  -0x4010(%rbp,%rax,4),%xmm0
ff ff
cvttss2si %xmm0,%eax
mov    %ax,%cx
movslq -0x6018(%rbp),%rax
mov    %cx,-0x6010(%rbp,%rax,2)
ff
jmp    12a1 <main+0x171>
jmp    12a6 <main+0x176>
mov    -0x6018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6018(%rbp)
jmp    11ec <main+0xbc>
lea    -0x6010(%rbp),%rdi
mov    -0x6014(%rbp),%edx
mov    0x2d02(%rip),%rax
mov    (%rax),%ecx
mov    $0x2,%esi
call   1050 <fwrite@plt>
jmp    11ab <main+0x7b>
mov    0x2cf2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd58(%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),%rbx
mov    (%rbx),%edi
cmp    $0x2,%eax
jl     117a <main+0x4a>
lea    0xee0(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xee4(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%r14d
jmp    138e <main+0x25e>
mov    %rsi,%r15
mov    (%rsi),%rdx
lea    0xee2(%rip),%rsi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e50(%rip),%r13
mov    0x0(%r13),%ecx
lea    0x2000(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
test   %eax,%eax
je     1374 <main+0x244>
movss  0xe6c(%rip),%xmm8
movss  0xe67(%rip),%xmm9
movaps 0xe2b(%rip),%xmm10
movaps 0xe33(%rip),%xmm11
movdqa 0xe3a(%rip),%xmm12
mov    0x2de3(%rip),%r12
mov    %rsp,%rbp
lea    0x2000(%rsp),%rbx
jmp    125c <main+0x12c>
nopw   0x0(%rax,%rax,1)
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 0xdee(%rip),%xmm12
movaps 0xdd6(%rip),%xmm11
movaps 0xdbe(%rip),%xmm10
movss  0xde9(%rip),%xmm9
movss  0xddc(%rip),%xmm8
test   %eax,%eax
je     1374 <main+0x244>
test   %eax,%eax
jle    1200 <main+0xd0>
mov    %eax,%ecx
cmp    $0x8,%eax
jae    1270 <main+0x140>
xor    %edx,%edx
jmp    1351 <main+0x221>
xchg   %ax,%ax
mov    %ecx,%edx
and    $0xfffffff8,%edx
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
movaps 0x2000(%rsp,%rsi,4),%xmm0
movaps 0x2010(%rsp,%rsi,4),%xmm1
movaps %xmm11,%xmm2
cmpnltps %xmm0,%xmm2
movaps %xmm0,%xmm3
cmpleps %xmm10,%xmm3
movaps %xmm10,%xmm4
andps  %xmm3,%xmm4
andnps %xmm0,%xmm3
cmpltps %xmm10,%xmm0
movaps %xmm11,%xmm5
cmpnltps %xmm1,%xmm5
movaps %xmm1,%xmm6
cmpleps %xmm10,%xmm6
movaps %xmm10,%xmm7
andps  %xmm6,%xmm7
andnps %xmm1,%xmm6
cmpltps %xmm10,%xmm1
orps   %xmm0,%xmm2
orps   %xmm1,%xmm5
orps   %xmm4,%xmm3
cvttps2dq %xmm3,%xmm0
andps  %xmm2,%xmm0
packssdw %xmm2,%xmm2
orps   %xmm7,%xmm6
cvttps2dq %xmm6,%xmm1
andps  %xmm5,%xmm1
packssdw %xmm5,%xmm5
pshuflw $0xe8,%xmm0,%xmm0
pshufhw $0xe8,%xmm0,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pandn  %xmm12,%xmm2
pshuflw $0xe8,%xmm1,%xmm1
pshufhw $0xe8,%xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpcklqdq %xmm1,%xmm0
pandn  %xmm12,%xmm5
punpcklqdq %xmm5,%xmm2
por    %xmm0,%xmm2
movdqa %xmm2,(%rsp,%rsi,2)
add    $0x8,%rsi
cmp    %rsi,%rdx
jne    1280 <main+0x150>
cmp    %rcx,%rdx
jne    1351 <main+0x221>
jmp    1200 <main+0xd0>
mov    %si,(%rsp,%rdx,2)
add    $0x1,%rdx
cmp    %rdx,%rcx
je     1200 <main+0xd0>
movss  0x2000(%rsp,%rdx,4),%xmm0
mov    $0x8000,%si
ucomiss %xmm0,%xmm8
ja     1340 <main+0x210>
mov    $0x7fff,%si
ucomiss %xmm9,%xmm0
ja     1340 <main+0x210>
cvttss2si %xmm0,%esi
jmp    1340 <main+0x210>
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xcef(%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 = [29 x i8] c"Transforma float's en int's\0A\00"
@.str.2 = [13 x i8] c"%s: running\0A\00"
@stdin = global i32 0
@stdout = global i32 0
@.str.3 = [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 float]
%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 %17
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))
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %82
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %71, %17
%24 = getelementptr inbounds [4096 x float], [4096 x float]* %6, i64 0, i64 0
%25 = load i32, i32* @stdin
%26 = call i32 @fread(float* %24, i32 4, i32 4096, i32 %25)
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %23
br label %76
30: ; preds = %23
store i32 0, i32* %9
br label %31
31: ; preds = %68, %30
%32 = load i32, i32* %9
%33 = load i32, i32* %8
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %71
35: ; preds = %31
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [4096 x float], [4096 x float]* %6, i64 0, i64 %37
%39 = load float, float* %38
%40 = fpext float %39 to double
%41 = fcmp olt double %40, -3.276800e+04
br i1 %41, label %42, label %46
42: ; preds = %35
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [4096 x i16], [4096 x i16]* %7, i64 0, i64 %44
store i16 -32768, i16* %45
br label %67
46: ; preds = %35
%47 = load i32, i32* %9
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [4096 x float], [4096 x float]* %6, i64 0, i64 %48
%50 = load float, float* %49
%51 = fpext float %50 to double
%52 = fcmp ogt double %51, 3.276700e+04
br i1 %52, label %53, label %57
53: ; preds = %46
%54 = load i32, i32* %9
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [4096 x i16], [4096 x i16]* %7, i64 0, i64 %55
store i16 32767, i16* %56
br label %66
57: ; preds = %46
%58 = load i32, i32* %9
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [4096 x float], [4096 x float]* %6, i64 0, i64 %59
%61 = load float, float* %60
%62 = fptosi float %61 to i16
%63 = load i32, i32* %9
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [4096 x i16], [4096 x i16]* %7, i64 0, i64 %64
store i16 %62, i16* %65
br label %66
66: ; preds = %57, %53
br label %67
67: ; preds = %66, %42
br label %68
68: ; preds = %67
%69 = load i32, i32* %9
%70 = add nsw i32 %69, 1
store i32 %70, i32* %9
br label %31
71: ; preds = %31
%72 = getelementptr inbounds [4096 x i16], [4096 x i16]* %7, i64 0, i64 0
%73 = load i32, i32* %8
%74 = load i32, i32* @stdout
%75 = call i32 @fwrite(i16* %72, i32 2, i32 %73, i32 %74)
br label %23
76: ; preds = %29
%77 = load i32, i32* @stderr
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 0
%80 = load i8*, i8** %79
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %80)
store i32 0, i32* %3
br label %82
82: ; preds = %76, %12
%83 = load i32, i32* %3
ret i32 %83
}

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