#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*/ mergeSort(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int vetor[100];
  srand(time(NULL));
  for (int i = 0; i < 100; i++) {
    vetor[i] = rand() % 1000;
    printf("%d, ", vetor[i]);
  }
  printf("\n\n");
  mergeSort(vetor, 100);
  for (int i = 0; i < 100; i++) {
    printf("%d, ", vetor[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x1a4(%rbp)
cmpl   $0x64,-0x1a4(%rbp)
jge    11d6 <main+0x86>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
movslq -0x1a4(%rbp),%rax
mov    %edx,-0x1a0(%rbp,%rax,4)
movslq -0x1a4(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    117c <main+0x2c>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1a0(%rbp),%rdi
mov    $0x64,%esi
call   1050 <mergeSort@plt>
movl   $0x0,-0x1a8(%rbp)
cmpl   $0x64,-0x1a8(%rbp)
jge    123c <main+0xec>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    11ff <main+0xaf>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x198,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe81(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0x10624dd3,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0x3e8,%eax,%eax
sub    %eax,%esi
mov    %esi,(%rsp,%rbx,4)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1190 <main+0x30>
lea    0xe31(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
mov    $0x64,%esi
call   1060 <mergeSort@plt>
lea    0xe13(%rip),%r14
xor    %ebx,%ebx
nop
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    11f0 <main+0x90>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%d, \00"
@str = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
br label %9
5: ; preds = %9
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%8 = call i32 @mergeSort(i32* %7, i32 100)
br label %18
9: ; preds = %0, %9
%10 = phi i64 [ 0, %0 ], [ %15, %9 ]
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 1000
%13 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %10
store i32 %12, i32* %13
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %12)
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, 100
br i1 %16, label %5, label %9
17: ; preds = %18
ret i32 0
18: ; preds = %5, %18
%19 = phi i64 [ 0, %5 ], [ %23, %18 ]
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = add nuw nsw i64 %19, 1
%24 = icmp eq i64 %23, 100
br i1 %24, label %17, label %18
}