#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 */

/* Variables and functions */
int /*<<< orphan*/ InsertionSort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ PrintVet(int *, int /*<<< orphan*/, int);
int atoi(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  srand(time(NULL));
  int n = 10;
  if (argc > 1)
    n = atoi(argv[1]);
  int i, *vet;
  vet = (int *)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++)
    vet[i] = rand() % n;
  InsertionSort(vet, 0, n);
  printf("PRONTO\n");
  PrintVet(vet, 0, n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0xa,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11c7 <main+0x47>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1211 <main+0x91>
mov    $0x0,%al
call   10a0 <rand@plt>
cltd
idivl  -0x14(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e1 <main+0x61>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1070 <InsertionSort@plt>
lea    0xdda(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1040 <PrintVet@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
cmp    $0x1,%ebp
jle    11c2 <main+0x42>
mov    0x8(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%r14d
lea    0x0(,%r14,4),%edi
call   1080 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jg     11d5 <main+0x55>
jmp    11f8 <main+0x78>
mov    $0x28,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
mov    $0xa,%r14d
mov    %r14d,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <rand@plt>
cltd
idiv   %r14d
mov    %edx,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11e0 <main+0x60>
mov    %r15,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1070 <InsertionSort@plt>
lea    0xdf4(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1040 <PrintVet@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"PRONTO\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
store i32 10, i32* %6
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %6
br label %18
18: ; preds = %13, %2
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = mul i64 4, %20
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i32*
store i32* %24, i32** %8
store i32 0, i32* %7
br label %25
25: ; preds = %37, %18
%26 = load i32, i32* %7
%27 = load i32, i32* %6
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %40
29: ; preds = %25
%30 = call i32 (...) @rand()
%31 = load i32, i32* %6
%32 = srem i32 %30, %31
%33 = load i32*, i32** %8
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
store i32 %32, i32* %36
br label %37
37: ; preds = %29
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %25
40: ; preds = %25
%41 = load i32*, i32** %8
%42 = load i32, i32* %6
%43 = call i32 @InsertionSort(i32* %41, i32 0, i32 %42)
%44 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%45 = load i32*, i32** %8
%46 = load i32, i32* %6
%47 = call i32 @PrintVet(i32* %45, i32 0, i32 %46)
ret i32 0
}

LLVM IR (-O2):
@str = [7 x i8] c"PRONTO\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 sgt i32 %0, 1
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i64 @malloc(i32 40)
%8 = inttoptr i64 %7 to i32*
br label %17
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = shl i32 %12, 2
%14 = tail call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
%16 = icmp sgt i32 %12, 0
br i1 %16, label %17, label %28
17: ; preds = %6, %9
%18 = phi i32* [ %8, %6 ], [ %15, %9 ]
%19 = phi i32 [ 10, %6 ], [ %12, %9 ]
%20 = zext i32 %19 to i64
br label %21
21: ; preds = %17, %21
%22 = phi i64 [ 0, %17 ], [ %26, %21 ]
%23 = tail call i32 (...) @rand()
%24 = srem i32 %23, %19
%25 = getelementptr inbounds i32, i32* %18, i64 %22
store i32 %24, i32* %25
%26 = add nuw nsw i64 %22, 1
%27 = icmp eq i64 %26, %20
br i1 %27, label %28, label %21
28: ; preds = %21, %9
%29 = phi i32* [ %15, %9 ], [ %18, %21 ]
%30 = phi i32 [ %12, %9 ], [ %19, %21 ]
%31 = tail call i32 @InsertionSort(i32* %29, i32 0, i32 %30)
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%33 = tail call i32 @PrintVet(i32* %29, i32 0, i32 %30)
ret i32 0
}