#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 */
typedef double clock_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ CLOCKS_PER_SEC;
int /*<<< orphan*/ _IOFBF;
double clock();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputs(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ procesar_linea(char *, int);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
                           int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
int main(int argc, char *argv[]) {
  char buf[(65536)];
  char ifbuf[(65536)];
  char ofbuf[(65536)];
  int lineas = 0;
  FILE *archivo_entrada;
  FILE *archivo_salida;
  clock_t start = clock();
  clock_t end;
  if (argc < 2) {
    fprintf(stderr, "Uso: ordena_vector archivo_entrada [archivo_salida]");
    return -1;
  }
  archivo_entrada = argc < 2 ? stdin : fopen(argv[1], "rt");
  archivo_salida = argc < 3 ? stdout : fopen(argv[2], "wt");
  setvbuf(archivo_entrada, ifbuf, _IOFBF, (65536));
  setvbuf(archivo_salida, ofbuf, _IOFBF, (65536));
  while (fgets(buf, (65536), archivo_entrada)) {
    fputs(procesar_linea(buf, ++lineas), archivo_salida);
  }
  end = clock();
  printf("Tiempo ocupado: %.2f segundos\n",
         (end - start) / (double)CLOCKS_PER_SEC);
  exit(0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x30014(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x30030(%rbp)
ff
cmpl   $0x2,-0x8(%rbp)
jge    11ef <main+0x5f>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x30050,%rsp
pop    %rbp
ret
cmpl   $0x2,-0x8(%rbp)
jge    120f <main+0x7f>
mov    0x2de8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30040(%rbp)
jmp    122a <main+0x9a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe16(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30040(%rbp)
mov    -0x30040(%rbp),%rax
mov    %rax,-0x30020(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1258 <main+0xc8>
mov    0x2d7f(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30048(%rbp)
jmp    1273 <main+0xe3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdd0(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30048(%rbp)
mov    -0x30048(%rbp),%rax
mov    %rax,-0x30028(%rbp)
mov    -0x30020(%rbp),%rdi
lea    -0x20010(%rbp),%rsi
mov    0x2d2a(%rip),%rax
mov    (%rax),%edx
mov    $0x10000,%ecx
call   1090 <setvbuf@plt>
mov    -0x30028(%rbp),%rdi
lea    -0x30010(%rbp),%rsi
mov    0x2d09(%rip),%rax
mov    (%rax),%edx
mov    $0x10000,%ecx
call   1090 <setvbuf@plt>
lea    -0x10010(%rbp),%rdi
mov    -0x30020(%rbp),%rdx
mov    $0x10000,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1313 <main+0x183>
lea    -0x10010(%rbp),%rdi
mov    -0x30014(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x30014(%rbp)
call   1080 <procesar_linea@plt>
mov    %eax,%edi
mov    -0x30028(%rbp),%rsi
call   1050 <fputs@plt>
jmp    12c3 <main+0x133>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x30038(%rbp)
ff
movsd  -0x30038(%rbp),%xmm0
ff
subsd  -0x30030(%rbp),%xmm0
ff
mov    0x2ca7(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xcf1(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x30018,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <clock@plt>
cmp    $0x1,%ebp
jg     11d6 <main+0x46>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
lea    0xe42(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x30018,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
movsd  %xmm0,0x8(%rsp)
mov    0x8(%rbx),%rdi
lea    0xe4d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
cmp    $0x2,%ebp
jne    1200 <main+0x70>
mov    0x2dd5(%rip),%rax
mov    (%rax),%r15
jmp    1213 <main+0x83>
mov    0x10(%rbx),%rdi
lea    0xe2c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r15
mov    0x2dae(%rip),%rbx
mov    (%rbx),%edx
lea    0x20010(%rsp),%rsi
mov    %r14,%rdi
mov    $0x10000,%ecx
call   1090 <setvbuf@plt>
mov    (%rbx),%edx
lea    0x10010(%rsp),%rsi
mov    %r15,%rdi
mov    $0x10000,%ecx
call   1090 <setvbuf@plt>
lea    0x10(%rsp),%rdi
mov    $0x10000,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     129c <main+0x10c>
mov    $0x1,%ebp
lea    0x10(%rsp),%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1080 <procesar_linea@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   1050 <fputs@plt>
mov    %rbx,%rdi
mov    $0x10000,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
add    $0x1,%ebp
test   %rax,%rax
jne    1270 <main+0xe0>
xor    %eax,%eax
call   1030 <clock@plt>
subsd  0x8(%rsp),%xmm0
mov    0x2d38(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xd7a(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [52 x i8] c"Uso: ordena_vector archivo_entrada [archivo_salida]\00"
@stdin = global i32* null
@.str.1 = [3 x i8] c"rt\00"
@stdout = global i32* null
@.str.2 = [3 x i8] c"wt\00"
@_IOFBF = global i32 0
@.str.3 = [31 x i8] c"Tiempo ocupado: %.2f segundos\0A\00"
@CLOCKS_PER_SEC = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [65536 x i8]
%7 = alloca [65536 x i8]
%8 = alloca [65536 x i8]
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca double
%13 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%14 = call double (...) @clock()
store double %14, double* %12
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
ret i32 -1
20: ; preds = %2
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 2
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = load i32*, i32** @stdin
br label %30
25: ; preds = %20
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %25, %23
%31 = phi i32* [ %24, %23 ], [ %29, %25 ]
store i32* %31, i32** %10
%32 = load i32, i32* %4
%33 = icmp slt i32 %32, 3
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load i32*, i32** @stdout
br label %41
36: ; preds = %30
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32* @fopen(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %41
41: ; preds = %36, %34
%42 = phi i32* [ %35, %34 ], [ %40, %36 ]
store i32* %42, i32** %11
%43 = load i32*, i32** %10
%44 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%45 = load i32, i32* @_IOFBF
%46 = call i32 @setvbuf(i32* %43, i8* %44, i32 %45, i32 65536)
%47 = load i32*, i32** %11
%48 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%49 = load i32, i32* @_IOFBF
%50 = call i32 @setvbuf(i32* %47, i8* %48, i32 %49, i32 65536)
br label %51
51: ; preds = %56, %41
%52 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%53 = load i32*, i32** %10
%54 = call i64 @fgets(i8* %52, i32 65536, i32* %53)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %63
56: ; preds = %51
%57 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 1
store i32 %59, i32* %9
%60 = call i32 @procesar_linea(i8* %57, i32 %59)
%61 = load i32*, i32** %11
%62 = call i32 @fputs(i32 %60, i32* %61)
br label %51
63: ; preds = %51
%64 = call double (...) @clock()
store double %64, double* %13
%65 = load double, double* %13
%66 = load double, double* %12
%67 = fsub double %65, %66
%68 = load i64, i64* @CLOCKS_PER_SEC
%69 = sitofp i64 %68 to double
%70 = fdiv double %67, %69
%71 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), double %70)
%72 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [52 x i8] c"Uso: ordena_vector archivo_entrada [archivo_salida]\00"
@stdin = global i32* null
@.str.1 = [3 x i8] c"rt\00"
@stdout = global i32* null
@.str.2 = [3 x i8] c"wt\00"
@_IOFBF = global i32 0
@.str.3 = [31 x i8] c"Tiempo ocupado: %.2f segundos\0A\00"
@CLOCKS_PER_SEC = global i64 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [65536 x i8]
%4 = alloca [65536 x i8]
%5 = alloca [65536 x i8]
%6 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [65536 x i8], [65536 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [65536 x i8], [65536 x i8]* %5, i64 0, i64 0
%9 = tail call double (...) @clock()
%10 = icmp slt i32 %0, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
ret i32 -1
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i32 %0, 2
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = load i32*, i32** @stdout
br label %25
21: ; preds = %14
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %21, %19
%26 = phi i32* [ %20, %19 ], [ %24, %21 ]
%27 = load i32, i32* @_IOFBF
%28 = call i32 @setvbuf(i32* %17, i8* %7, i32 %27, i32 65536)
%29 = load i32, i32* @_IOFBF
%30 = call i32 @setvbuf(i32* %26, i8* %8, i32 %29, i32 65536)
%31 = call i64 @fgets(i8* %6, i32 65536, i32* %17)
%32 = icmp eq i64 %31, 0
br i1 %32, label %40, label %33
33: ; preds = %25, %33
%34 = phi i32 [ %35, %33 ], [ 0, %25 ]
%35 = add nuw nsw i32 %34, 1
%36 = call i32 @procesar_linea(i8* %6, i32 %35)
%37 = call i32 @fputs(i32 %36, i32* %26)
%38 = call i64 @fgets(i8* %6, i32 65536, i32* %17)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %33
40: ; preds = %33, %25
%41 = call double (...) @clock()
%42 = fsub double %41, %9
%43 = load i64, i64* @CLOCKS_PER_SEC
%44 = sitofp i64 %43 to double
%45 = fdiv double %42, %44
%46 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), double %45)
%47 = call i32 @exit(i32 0)
unreachable
}