#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*/ displayElements(int *, int);
int /*<<< orphan*/ mergeSort(int *, int);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int array[10];
  int i;
  srand(time(NULL));
  for (i = 0; i < 10; i++)
    array[i] = rand() % 90 + 10;
  printf("Unsorted array:\n");
  displayElements(array, 10);
  printf("\n\n");
  mergeSort(array, 10);
  printf("Sorted array:\n");
  displayElements(array, 10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    11b8 <main+0x58>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x5a,%ecx
cltd
idiv   %ecx
add    $0xa,%edx
movslq -0x34(%rbp),%rax
mov    %edx,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1186 <main+0x26>
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1070 <displayElements@plt>
lea    0xe38(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1050 <mergeSort@plt>
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1070 <displayElements@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1080 <rand@plt>
movd   %r14d,%xmm0
movd   %ebp,%xmm1
punpckldq %xmm1,%xmm0
movd   %ebx,%xmm1
movd   %eax,%xmm2
punpckldq %xmm2,%xmm1
punpcklqdq %xmm1,%xmm0
pxor   %xmm1,%xmm1
pcmpgtd %xmm0,%xmm1
movdqa 0xe3a(%rip),%xmm4
pand   %xmm4,%xmm1
paddd  %xmm0,%xmm1
movdqa %xmm0,%xmm2
pmuludq %xmm4,%xmm2
pshufd $0xed,%xmm2,%xmm2
pshufd $0xf5,%xmm0,%xmm3
pmuludq %xmm4,%xmm3
pshufd $0xed,%xmm3,%xmm3
punpckldq %xmm3,%xmm2
psubd  %xmm1,%xmm2
paddd  %xmm0,%xmm2
movdqa %xmm2,%xmm1
psrld  $0x1f,%xmm1
psrad  $0x6,%xmm2
paddd  %xmm1,%xmm2
movdqa 0xe01(%rip),%xmm3
pshufd $0xf5,%xmm2,%xmm1
pmuludq %xmm3,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pmuludq %xmm3,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm2
psubd  %xmm2,%xmm0
paddd  0xdea(%rip),%xmm0
movdqa %xmm0,(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1080 <rand@plt>
movd   %r14d,%xmm0
movd   %ebp,%xmm1
punpckldq %xmm1,%xmm0
movd   %ebx,%xmm1
movd   %eax,%xmm2
punpckldq %xmm2,%xmm1
punpcklqdq %xmm1,%xmm0
pxor   %xmm1,%xmm1
pcmpgtd %xmm0,%xmm1
movdqa 0xd75(%rip),%xmm2
pand   %xmm2,%xmm1
paddd  %xmm0,%xmm1
movdqa %xmm1,%xmm3
movdqa %xmm0,%xmm1
pmuludq %xmm2,%xmm1
movdqa %xmm2,%xmm4
pshufd $0xed,%xmm1,%xmm1
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm4,%xmm2
pshufd $0xed,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
psubd  %xmm3,%xmm1
paddd  %xmm0,%xmm1
movdqa %xmm1,%xmm2
psrld  $0x1f,%xmm2
psrad  $0x6,%xmm1
paddd  %xmm2,%xmm1
pshufd $0xf5,%xmm1,%xmm2
movdqa 0xd2f(%rip),%xmm3
pmuludq %xmm3,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm3,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
psubd  %xmm1,%xmm0
paddd  0xd1d(%rip),%xmm0
movdqa %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0xffffffffb60b60b7,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x5a,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0xa,%eax
mov    %eax,0x20(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0xffffffffb60b60b7,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x5a,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0xa,%eax
mov    %eax,0x24(%rsp)
lea    0xcc4(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <displayElements@plt>
lea    0xcb8(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <mergeSort@plt>
lea    0xca1(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <displayElements@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@str = [16 x i8] c"Unsorted array:\00"
@str.3 = [2 x i8] c"\0A\00"
@str.4 = [14 x i8] c"Sorted array:\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 (...) @rand()
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%7 = tail call i32 (...) @rand()
%8 = tail call i32 (...) @rand()
%9 = tail call i32 (...) @rand()
%10 = insertelement <4 x i32> poison, i32 %5, i64 0
%11 = insertelement <4 x i32> %10, i32 %7, i64 1
%12 = insertelement <4 x i32> %11, i32 %8, i64 2
%13 = insertelement <4 x i32> %12, i32 %9, i64 3
%14 = srem <4 x i32> %13, <i32 90, i32 90, i32 90, i32 90>
%15 = add nsw <4 x i32> %14, <i32 10, i32 10, i32 10, i32 10>
%16 = bitcast [10 x i32]* %1 to <4 x i32>*
store <4 x i32> %15, <4 x i32>* %16
%17 = tail call i32 (...) @rand()
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%19 = tail call i32 (...) @rand()
%20 = tail call i32 (...) @rand()
%21 = tail call i32 (...) @rand()
%22 = insertelement <4 x i32> poison, i32 %17, i64 0
%23 = insertelement <4 x i32> %22, i32 %19, i64 1
%24 = insertelement <4 x i32> %23, i32 %20, i64 2
%25 = insertelement <4 x i32> %24, i32 %21, i64 3
%26 = srem <4 x i32> %25, <i32 90, i32 90, i32 90, i32 90>
%27 = add nsw <4 x i32> %26, <i32 10, i32 10, i32 10, i32 10>
%28 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> %27, <4 x i32>* %28
%29 = tail call i32 (...) @rand()
%30 = srem i32 %29, 90
%31 = add nsw i32 %30, 10
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
store i32 %31, i32* %32
%33 = tail call i32 (...) @rand()
%34 = srem i32 %33, 90
%35 = add nsw i32 %34, 10
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
store i32 %35, i32* %36
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%38 = call i32 @displayElements(i32* %6, i32 10)
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.3, i64 0, i64 0))
%40 = call i32 @mergeSort(i32* %6, i32 10)
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.4, i64 0, i64 0))
%42 = call i32 @displayElements(i32* %6, i32 10)
ret i32 0
}