#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*/ bubble_sort(long *, int);
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 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);
  bubble_sort(numeros, i);
  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   1070 <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),%esi
call   1080 <bubble_sort@plt>
lea    0xde6(%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    1274 <main+0x114>
mov    -0x18(%rbp),%rax
mov    -0x360(%rbp,%rax,8),%rsi
ff
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1238 <main+0xd8>
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   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe69(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    %r14,%rdi
call   1070 <feof@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    11f8 <main+0x88>
xor    %ebx,%ebx
lea    0xe45(%rip),%r15
lea    0xc(%rsp),%r12
nopl   0x0(%rax)
movslq 0xc(%rsp),%rax
mov    %rax,0x10(%rsp,%rbx,8)
add    $0x1,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <fscanf@plt>
mov    %r14,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11d0 <main+0x60>
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    0x10(%rsp),%rdi
mov    %ebx,%esi
call   1090 <bubble_sort@plt>
lea    0xe01(%rip),%rdi
call   1030 <puts@plt>
test   %ebx,%ebx
je     1248 <main+0xd8>
mov    %ebx,%r15d
lea    0xde9(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
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 = call i32 @bubble_sort(i64* %32, i32 %33)
%35 = 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 %36
36: ; preds = %46, %29
%37 = load i64, i64* %3
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = icmp slt i64 %37, %39
br i1 %40, label %41, label %49
41: ; preds = %36
%42 = load i64, i64* %3
%43 = getelementptr inbounds [100 x i64], [100 x i64]* %9, i64 0, i64 %42
%44 = load i64, i64* %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 %44)
br label %46
46: ; preds = %41
%47 = load i64, i64* %3
%48 = add nsw i64 %47, 1
store i64 %48, i64* %3
br label %36
49: ; preds = %36
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 = call i32 @bubble_sort(i64* %23, i32 %21)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%26 = zext i32 %21 to i64
%27 = icmp eq i32 %21, 0
br i1 %27, label %35, label %28
28: ; preds = %20, %28
%29 = phi i64 [ %33, %28 ], [ 0, %20 ]
%30 = getelementptr inbounds [100 x i64], [100 x i64]* %2, i64 0, i64 %29
%31 = load i64, i64* %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 %31)
%33 = add nuw nsw i64 %29, 1
%34 = icmp eq i64 %33, %26
br i1 %34, label %35, label %28
35: ; preds = %28, %20
ret i32 0
}