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

/* Variables and functions */
int /*<<< orphan*/ bubble_sort(long *, int);
double difftime(int /*<<< orphan*/, int /*<<< orphan*/);
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 *, double);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  long n, c, d, swap;
  int lectura = 0;
  int i = 0;
  int j;
  long numeros[400000];
  time_t start_t, end_t;
  double diff_t;
  FILE *input;
  input = fopen("muestra400.txt", "r");
  fscanf(input, "%d", &lectura);
  while (!feof(input)) {
    numeros[i] = lectura;
    i++;
    fscanf(input, "%d", &lectura);
  }
  fclose(input);
  time(&start_t);
  bubble_sort(numeros, i);
  time(&end_t);
  diff_t = difftime(end_t, start_t);
  printf("Execution time = %f\n", diff_t);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30d460,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xe59(%rip),%rdi
lea    0xe61(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x30d458(%rbp)
mov    -0x30d458(%rbp),%rdi
lea    0xe49(%rip),%rsi
lea    -0x2c(%rbp),%rdx
call   1060 <fscanf@plt>
mov    -0x30d458(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11f2 <main+0x72>
jmp    1227 <main+0xa7>
movslq -0x2c(%rbp),%rcx
movslq -0x30(%rbp),%rax
mov    %rcx,-0x30d440(%rbp,%rax,8)
ff
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30d458(%rbp),%rdi
lea    0xdf8(%rip),%rsi
lea    -0x2c(%rbp),%rdx
call   1060 <fscanf@plt>
jmp    11d1 <main+0x51>
mov    -0x30d458(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x30d444(%rbp),%rdi
call   1080 <time@plt>
lea    -0x30d440(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   10a0 <bubble_sort@plt>
lea    -0x30d448(%rbp),%rdi
call   1080 <time@plt>
mov    -0x30d448(%rbp),%edi
mov    -0x30d444(%rbp),%esi
call   1050 <difftime@plt>
movsd  %xmm0,-0x30d450(%rbp)
ff
movsd  -0x30d450(%rbp),%xmm0
ff
lea    0xd92(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30d460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30d418,%rsp
movl   $0x0,0x4(%rsp)
lea    0xe63(%rip),%rdi
lea    0xe6b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
lea    0xe5e(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1060 <fscanf@plt>
mov    %r14,%rdi
call   1070 <feof@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    1208 <main+0x88>
xor    %ebx,%ebx
lea    0xe3a(%rip),%r15
lea    0x4(%rsp),%r12
nopl   0x0(%rax)
movslq 0x4(%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     11e0 <main+0x60>
mov    %r14,%rdi
call   1030 <fclose@plt>
lea    0xc(%rsp),%rdi
call   1080 <time@plt>
lea    0x10(%rsp),%rdi
mov    %ebx,%esi
call   10a0 <bubble_sort@plt>
lea    0x8(%rsp),%rdi
call   1080 <time@plt>
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%esi
call   1050 <difftime@plt>
lea    0xdd0(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30d418,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"muestra400.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [21 x i8] c"Execution time = %f\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 [400000 x i64]
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %6
store i32 0, i32* %7
%14 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %13
%15 = load i32*, i32** %13
%16 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
br label %17
17: ; preds = %22, %0
%18 = load i32*, i32** %13
%19 = call i32 @feof(i32* %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %22, label %32
22: ; preds = %17
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [400000 x i64], [400000 x i64]* %9, i64 0, i64 %26
store i64 %24, i64* %27
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
%30 = load i32*, i32** %13
%31 = call i32 @fscanf(i32* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
br label %17
32: ; preds = %17
%33 = load i32*, i32** %13
%34 = call i32 @fclose(i32* %33)
%35 = call i32 @time(i32* %10)
%36 = getelementptr inbounds [400000 x i64], [400000 x i64]* %9, i64 0, i64 0
%37 = load i32, i32* %7
%38 = call i32 @bubble_sort(i64* %36, i32 %37)
%39 = call i32 @time(i32* %11)
%40 = load i32, i32* %11
%41 = load i32, i32* %10
%42 = call double @difftime(i32 %40, i32 %41)
store double %42, double* %12
%43 = load double, double* %12
%44 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), double %43)
ret i32 0
}

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