#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 */
double INT_MAX;
double INT_MIN;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(double **, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(int *, 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 (;;) {
    double x[4096];
    int 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] < INT_MIN)
          y[i] = INT_MIN;
        else if (x[i] > INT_MAX)
          y[i] = INT_MAX;
        else
          y[i] = (int)x[i];
      }
    }
    fwrite(y, sizeof(int), r, stdout);
  }
  fprintf(stderr, "%s: done\n", argv[0]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    118d <main+0x5d>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xe9a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ff <main+0x1cf>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
lea    -0x8010(%rbp),%rdi
mov    0x2e2f(%rip),%rax
mov    (%rax),%ecx
mov    $0x8,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %eax,-0xc014(%rbp)
cmpl   $0x0,-0xc014(%rbp)
jne    11e2 <main+0xb2>
jmp    12e1 <main+0x1b1>
movl   $0x0,-0xc018(%rbp)
mov    -0xc018(%rbp),%eax
cmp    -0xc014(%rbp),%eax
jge    12bc <main+0x18c>
movslq -0xc018(%rbp),%rax
movsd  -0x8010(%rbp,%rax,8),%xmm1
ff ff
mov    0x2dc3(%rip),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    1241 <main+0x111>
mov    0x2dae(%rip),%rax
cvttsd2si (%rax),%ecx
movslq -0xc018(%rbp),%rax
mov    %ecx,-0xc010(%rbp,%rax,4)
jmp    12a3 <main+0x173>
movslq -0xc018(%rbp),%rax
movsd  -0x8010(%rbp,%rax,8),%xmm0
ff ff
mov    0x2d88(%rip),%rax
ucomisd (%rax),%xmm0
jbe    1280 <main+0x150>
mov    0x2d77(%rip),%rax
cvttsd2si (%rax),%ecx
movslq -0xc018(%rbp),%rax
mov    %ecx,-0xc010(%rbp,%rax,4)
jmp    129e <main+0x16e>
movslq -0xc018(%rbp),%rax
cvttsd2si -0x8010(%rbp,%rax,8),%ecx
ff ff
movslq -0xc018(%rbp),%rax
mov    %ecx,-0xc010(%rbp,%rax,4)
jmp    12a3 <main+0x173>
jmp    12a8 <main+0x178>
mov    -0xc018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc018(%rbp)
jmp    11ec <main+0xbc>
lea    -0xc010(%rbp),%rdi
mov    -0xc014(%rbp),%edx
mov    0x2cf0(%rip),%rax
mov    (%rax),%ecx
mov    $0x4,%esi
call   1050 <fwrite@plt>
jmp    11ab <main+0x7b>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd46(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0xc020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc018,%rsp
mov    %edi,%eax
mov    0x2e7e(%rip),%rbx
mov    (%rbx),%edi
cmp    $0x2,%eax
jl     1179 <main+0x49>
lea    0xea8(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xeac(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    12ee <main+0x1be>
mov    %rsi,0x8(%rsp)
mov    (%rsi),%rdx
lea    0xea9(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2e52(%rip),%r13
mov    0x0(%r13),%ecx
lea    0x4010(%rsp),%rdi
mov    $0x8,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
test   %eax,%eax
je     12cd <main+0x19d>
mov    0x2e18(%rip),%r12
mov    0x2e19(%rip),%r14
mov    0x2df2(%rip),%r15
lea    0x10(%rsp),%rbp
lea    0x4010(%rsp),%rbx
jmp    1218 <main+0xe8>
nopl   (%rax)
cvttsd2si %xmm0,%edx
mov    %edx,0x10(%rsp,%rcx,4)
mov    (%r15),%ecx
mov    %rbp,%rdi
mov    $0x4,%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>
test   %eax,%eax
je     12cd <main+0x19d>
test   %eax,%eax
jle    11e8 <main+0xb8>
movsd  (%r12),%xmm0
movsd  (%r14),%xmm1
mov    %eax,%edx
cmp    $0x1,%eax
jne    1260 <main+0x130>
xor    %ecx,%ecx
test   $0x1,%dl
je     11e8 <main+0xb8>
movsd  0x4010(%rsp,%rcx,8),%xmm2
ucomisd %xmm2,%xmm0
ja     11e0 <main+0xb0>
ucomisd %xmm1,%xmm2
movapd %xmm1,%xmm0
ja     11e0 <main+0xb0>
movapd %xmm2,%xmm0
jmp    11e0 <main+0xb0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %edx,%esi
and    $0xfffffffe,%esi
xor    %ecx,%ecx
jmp    1281 <main+0x151>
nopl   0x0(%rax)
cvttsd2si %xmm3,%edi
mov    %edi,0x14(%rsp,%rcx,4)
add    $0x2,%rcx
cmp    %rcx,%rsi
je     1230 <main+0x100>
movsd  0x4010(%rsp,%rcx,8),%xmm2
ucomisd %xmm2,%xmm0
movapd %xmm0,%xmm3
ja     12a2 <main+0x172>
ucomisd %xmm1,%xmm2
movapd %xmm1,%xmm3
ja     12a2 <main+0x172>
movapd %xmm2,%xmm3
cvttsd2si %xmm3,%edi
mov    %edi,0x10(%rsp,%rcx,4)
movsd  0x4018(%rsp,%rcx,8),%xmm2
ucomisd %xmm2,%xmm0
movapd %xmm0,%xmm3
ja     1270 <main+0x140>
ucomisd %xmm1,%xmm2
movapd %xmm1,%xmm3
ja     1270 <main+0x140>
movapd %xmm2,%xmm3
jmp    1270 <main+0x140>
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%rax
mov    (%rax),%rdx
lea    0xd59(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0xc018,%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
@INT_MIN = global double 0.000000e+00
@INT_MAX = global double 0.000000e+00
@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 double]
%7 = alloca [4096 x i32]
%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 %86
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 = %75, %17
%24 = bitcast [4096 x double]* %6 to double**
%25 = load i32, i32* @stdin
%26 = call i32 @fread(double** %24, i32 8, 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 %80
30: ; preds = %23
store i32 0, i32* %9
br label %31
31: ; preds = %72, %30
%32 = load i32, i32* %9
%33 = load i32, i32* %8
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %75
35: ; preds = %31
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [4096 x double], [4096 x double]* %6, i64 0, i64 %37
%39 = load double, double* %38
%40 = load double, double* @INT_MIN
%41 = fcmp olt double %39, %40
br i1 %41, label %42, label %48
42: ; preds = %35
%43 = load double, double* @INT_MIN
%44 = fptosi double %43 to i32
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [4096 x i32], [4096 x i32]* %7, i64 0, i64 %46
store i32 %44, i32* %47
br label %71
48: ; preds = %35
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [4096 x double], [4096 x double]* %6, i64 0, i64 %50
%52 = load double, double* %51
%53 = load double, double* @INT_MAX
%54 = fcmp ogt double %52, %53
br i1 %54, label %55, label %61
55: ; preds = %48
%56 = load double, double* @INT_MAX
%57 = fptosi double %56 to i32
%58 = load i32, i32* %9
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [4096 x i32], [4096 x i32]* %7, i64 0, i64 %59
store i32 %57, i32* %60
br label %70
61: ; preds = %48
%62 = load i32, i32* %9
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [4096 x double], [4096 x double]* %6, i64 0, i64 %63
%65 = load double, double* %64
%66 = fptosi double %65 to i32
%67 = load i32, i32* %9
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [4096 x i32], [4096 x i32]* %7, i64 0, i64 %68
store i32 %66, i32* %69
br label %70
70: ; preds = %61, %55
br label %71
71: ; preds = %70, %42
br label %72
72: ; preds = %71
%73 = load i32, i32* %9
%74 = add nsw i32 %73, 1
store i32 %74, i32* %9
br label %31
75: ; preds = %31
%76 = getelementptr inbounds [4096 x i32], [4096 x i32]* %7, i64 0, i64 0
%77 = load i32, i32* %8
%78 = load i32, i32* @stdout
%79 = call i32 @fwrite(i32* %76, i32 4, i32 %77, i32 %78)
br label %23
80: ; preds = %29
%81 = load i32, i32* @stderr
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 0
%84 = load i8*, i8** %83
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %84)
br label %86
86: ; preds = %80, %12
%87 = load i32, i32* %3
ret i32 %87
}

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