#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 double clock_t;

/* Variables and functions */
float CLOCKS_PER_SEC;
int atoi(char *);
double clock();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int *strcmp(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  clock_t t;
  time_t timer;
  srand(time(NULL));
  if (argc < 3) {
    printf("Entre com o tamanho do vetor\n");
    return 1;
  }
  int tmp, i, j, r, n = atoi(argv[1]);
  int *v = NULL;
  v = strcmp(argv[2], "entrada100.txt");
  t = clock();
  for (i = n; i > 0; i--) {
    for (j = 1; j < i; j++) {
      if (v[j - 1] > v[j]) {
        tmp = v[j - 1];
        v[j - 1] = v[j];
        v[j] = tmp;
      }
    }
  }
  printf("%f time \n", t, ((float)t) / CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
cmpl   $0x3,-0x8(%rbp)
jge    11aa <main+0x4a>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12be <main+0x15e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe4d(%rip),%rsi
call   1060 <strcmp@plt>
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    128c <main+0x12c>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1279 <main+0x119>
mov    -0x38(%rbp),%rax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x38(%rbp),%rcx
movslq -0x28(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    1266 <main+0x106>
mov    -0x38(%rbp),%rax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x38(%rbp),%rax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%edx
mov    -0x38(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    126b <main+0x10b>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11fd <main+0x9d>
jmp    127e <main+0x11e>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    11ec <main+0x8c>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
cvtsd2ss %xmm1,%xmm1
mov    0x2d47(%rip),%rax
divss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd7d(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
cmp    $0x2,%ebp
jg     11a3 <main+0x33>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
jmp    123c <main+0xcc>
mov    0x8(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
lea    0xe47(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <clock@plt>
test   %ebp,%ebp
jle    121b <main+0xab>
mov    %ebp,%eax
jmp    11ed <main+0x7d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x1(%rax),%rcx
cmp    $0x1,%rax
mov    %rcx,%rax
jbe    121b <main+0xab>
cmp    $0x2,%rax
jb     121b <main+0xab>
mov    (%rbx),%edx
mov    $0x1,%ecx
jmp    1210 <main+0xa0>
nopl   0x0(%rax)
mov    %esi,-0x4(%rbx,%rcx,4)
mov    %edx,(%rbx,%rcx,4)
add    $0x1,%rcx
cmp    %rcx,%rax
je     11e0 <main+0x70>
mov    (%rbx,%rcx,4),%esi
cmp    %esi,%edx
jg     1200 <main+0x90>
mov    %esi,%edx
jmp    1207 <main+0x97>
cvtsd2ss %xmm0,%xmm1
mov    0x2dc2(%rip),%rax
divss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdda(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Entre com o tamanho do vetor\0A\00"
@.str.1 = [15 x i8] c"entrada100.txt\00"
@.str.2 = [10 x i8] c"%f time \0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32 @time(i32* null)
%15 = call i32 @srand(i32 %14)
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %90
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %12
store i32* null, i32** %13
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32* @strcmp(i8* %27, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %13
%29 = call double (...) @clock()
store double %29, double* %6
%30 = load i32, i32* %12
store i32 %30, i32* %9
br label %31
31: ; preds = %79, %20
%32 = load i32, i32* %9
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %82
34: ; preds = %31
store i32 1, i32* %10
br label %35
35: ; preds = %75, %34
%36 = load i32, i32* %10
%37 = load i32, i32* %9
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %78
39: ; preds = %35
%40 = load i32*, i32** %13
%41 = load i32, i32* %10
%42 = sub nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %40, i64 %43
%45 = load i32, i32* %44
%46 = load i32*, i32** %13
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
%51 = icmp sgt i32 %45, %50
br i1 %51, label %52, label %74
52: ; preds = %39
%53 = load i32*, i32** %13
%54 = load i32, i32* %10
%55 = sub nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %53, i64 %56
%58 = load i32, i32* %57
store i32 %58, i32* %8
%59 = load i32*, i32** %13
%60 = load i32, i32* %10
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %59, i64 %61
%63 = load i32, i32* %62
%64 = load i32*, i32** %13
%65 = load i32, i32* %10
%66 = sub nsw i32 %65, 1
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i32, i32* %64, i64 %67
store i32 %63, i32* %68
%69 = load i32, i32* %8
%70 = load i32*, i32** %13
%71 = load i32, i32* %10
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i32, i32* %70, i64 %72
store i32 %69, i32* %73
br label %74
74: ; preds = %52, %39
br label %75
75: ; preds = %74
%76 = load i32, i32* %10
%77 = add nsw i32 %76, 1
store i32 %77, i32* %10
br label %35
78: ; preds = %35
br label %79
79: ; preds = %78
%80 = load i32, i32* %9
%81 = add nsw i32 %80, -1
store i32 %81, i32* %9
br label %31
82: ; preds = %31
%83 = load double, double* %6
%84 = load double, double* %6
%85 = fptrunc double %84 to float
%86 = load float, float* @CLOCKS_PER_SEC
%87 = fdiv float %85, %86
%88 = fpext float %87 to double
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %83, double %88)
store i32 0, i32* %3
br label %90
90: ; preds = %82, %18
%91 = load i32, i32* %3
ret i32 %91
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c"entrada100.txt\00"
@.str.2 = [10 x i8] c"%f time \0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@str = [29 x i8] c"Entre com o tamanho do vetor\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %45
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32* @strcmp(i8* %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call double (...) @clock()
%16 = icmp sgt i32 %11, 0
br i1 %16, label %17, label %39
17: ; preds = %8
%18 = zext i32 %11 to i64
br label %19
19: ; preds = %17, %37
%20 = phi i64 [ %18, %17 ], [ %38, %37 ]
%21 = icmp ugt i64 %20, 1
br i1 %21, label %22, label %39
22: ; preds = %19
%23 = load i32, i32* %14
br label %24
24: ; preds = %22, %33
%25 = phi i32 [ %23, %22 ], [ %34, %33 ]
%26 = phi i64 [ 1, %22 ], [ %35, %33 ]
%27 = getelementptr inbounds i32, i32* %14, i64 %26
%28 = load i32, i32* %27
%29 = icmp sgt i32 %25, %28
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = add nsw i64 %26, -1
%32 = getelementptr inbounds i32, i32* %14, i64 %31
store i32 %28, i32* %32
store i32 %25, i32* %27
br label %33
33: ; preds = %24, %30
%34 = phi i32 [ %28, %24 ], [ %25, %30 ]
%35 = add nuw nsw i64 %26, 1
%36 = icmp eq i64 %35, %20
br i1 %36, label %37, label %24
37: ; preds = %33
%38 = add nsw i64 %20, -1
br i1 %21, label %19, label %39
39: ; preds = %19, %37, %8
%40 = fptrunc double %15 to float
%41 = load float, float* @CLOCKS_PER_SEC
%42 = fdiv float %40, %41
%43 = fpext float %42 to double
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %15, double %43)
br label %45
45: ; preds = %39, %6
%46 = phi i32 [ 1, %6 ], [ 0, %39 ]
ret i32 %46
}