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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ quick_sort(long *, int /*<<< orphan*/, int);
int main() {
  long n, c, d, swap;
  int lectura = 0;
  int i = 0;
  int j;
  long numeros[100];
  FILE *input;
  input = fopen("trail.txt", "r");
  fscanf(input, "%d", &lectura);
  while (!feof(input)) {
    numeros[i] = lectura;
    i++;
    fscanf(input, "%d", &lectura);
  }
  fclose(input);
  quick_sort(numeros, 0, i - 1);
  printf("Lista en orden ascendente:\n");
  for (c = 0; c < i; c++)
    printf("%ld\n", numeros[c]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x370,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xe79(%rip),%rdi
lea    0xe7c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x368(%rbp)
mov    -0x368(%rbp),%rdi
lea    0xe64(%rip),%rsi
lea    -0x2c(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x368(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d2 <main+0x72>
jmp    1207 <main+0xa7>
movslq -0x2c(%rbp),%rcx
movslq -0x30(%rbp),%rax
mov    %rcx,-0x360(%rbp,%rax,8)
ff
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x368(%rbp),%rdi
lea    0xe13(%rip),%rsi
lea    -0x2c(%rbp),%rdx
call   1050 <fscanf@plt>
jmp    11b1 <main+0x51>
mov    -0x368(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x360(%rbp),%rdi
mov    -0x30(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1070 <quick_sort@plt>
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
cmp    %rcx,%rax
jge    1279 <main+0x119>
mov    -0x18(%rbp),%rax
mov    -0x360(%rbp,%rax,8),%rsi
ff
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    123d <main+0xdd>
xor    %eax,%eax
add    $0x370,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x338,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe73(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
lea    0xe69(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    %r12,%rdi
call   1070 <feof@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    11f8 <main+0x88>
xor    %ebx,%ebx
lea    0xe45(%rip),%r14
lea    0xc(%rsp),%r15
nopl   0x0(%rax)
movslq 0xc(%rsp),%rax
mov    %rax,0x10(%rsp,%rbx,8)
add    $0x1,%rbx
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <fscanf@plt>
mov    %r12,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11d0 <main+0x60>
mov    %r12,%rdi
call   1040 <fclose@plt>
lea    -0x1(%rbx),%edx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1080 <quick_sort@plt>
lea    0xdfe(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x1,%ebx
jb     1248 <main+0xd8>
mov    %ebx,%r15d
lea    0xde5(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x10(%rsp,%rbx,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1230 <main+0xc0>
xor    %eax,%eax
add    $0x338,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"trail.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [28 x i8] c"Lista en orden ascendente:\0A\00"
@.str.4 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [100 x i64]
%10 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %6
store i32 0, i32* %7
%11 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %10
%12 = load i32*, i32** %10
%13 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
br label %14
14: ; preds = %19, %0
%15 = load i32*, i32** %10
%16 = call i32 @feof(i32* %15)
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [100 x i64], [100 x i64]* %9, i64 0, i64 %23
store i64 %21, i64* %24
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
%27 = load i32*, i32** %10
%28 = call i32 @fscanf(i32* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
br label %14
29: ; preds = %14
%30 = load i32*, i32** %10
%31 = call i32 @fclose(i32* %30)
%32 = getelementptr inbounds [100 x i64], [100 x i64]* %9, i64 0, i64 0
%33 = load i32, i32* %7
%34 = sub nsw i32 %33, 1
%35 = call i32 @quick_sort(i64* %32, i32 0, i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
store i64 0, i64* %3
br label %37
37: ; preds = %47, %29
%38 = load i64, i64* %3
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = icmp slt i64 %38, %40
br i1 %41, label %42, label %50
42: ; preds = %37
%43 = load i64, i64* %3
%44 = getelementptr inbounds [100 x i64], [100 x i64]* %9, i64 0, i64 %43
%45 = load i64, i64* %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 %45)
br label %47
47: ; preds = %42
%48 = load i64, i64* %3
%49 = add nsw i64 %48, 1
store i64 %49, i64* %3
br label %37
50: ; preds = %37
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"trail.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [5 x i8] c"%ld\0A\00"
@str = [27 x i8] c"Lista en orden ascendente:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i64]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast [100 x i64]* %2 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%7 = call i32 @feof(i32* %5)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %0, %9
%10 = phi i64 [ %14, %9 ], [ 0, %0 ]
%11 = load i32, i32* %1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [100 x i64], [100 x i64]* %2, i64 0, i64 %10
store i64 %12, i64* %13
%14 = add nuw i64 %10, 1
%15 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%16 = call i32 @feof(i32* %5)
%17 = icmp eq i32 %16, 0
br i1 %17, label %9, label %18
18: ; preds = %9
%19 = trunc i64 %14 to i32
br label %20
20: ; preds = %18, %0
%21 = phi i32 [ 0, %0 ], [ %19, %18 ]
%22 = call i32 @fclose(i32* %5)
%23 = getelementptr inbounds [100 x i64], [100 x i64]* %2, i64 0, i64 0
%24 = add nsw i32 %21, -1
%25 = call i32 @quick_sort(i64* %23, i32 0, i32 %24)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%27 = zext i32 %21 to i64
%28 = icmp eq i32 %21, 0
br i1 %28, label %36, label %29
29: ; preds = %20, %29
%30 = phi i64 [ %34, %29 ], [ 0, %20 ]
%31 = getelementptr inbounds [100 x i64], [100 x i64]* %2, i64 0, i64 %30
%32 = load i64, i64* %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 %32)
%34 = add nuw nsw i64 %30, 1
%35 = icmp eq i64 %34, %27
br i1 %35, label %36, label %29
36: ; preds = %29, %20
ret i32 0
}