#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*/ merge_sort(int *, int /*<<< orphan*/, int const);
int /*<<< orphan*/ printArray(int *, int const);
int /*<<< orphan*/ printf(char *);
int rand();
int main() {
  const int N = 25;
  int arr[N];
  int i = 0;
  for (i = 0; i < N; ++i)
    arr[i] = rand() % (2 * N) + 1;
  printArray(arr, N);
  merge_sort(arr, 0, N - 1);
  printf("Sorted array: \n");
  printArray(arr, N);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x19,-0x8(%rbp)
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x19,-0x14(%rbp)
jge    11a0 <main+0x60>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x32,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
movslq -0x14(%rbp),%rax
mov    %edx,-0x80(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116e <main+0x2e>
lea    -0x80(%rbp),%rdi
mov    $0x19,%esi
call   1050 <printArray@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <merge_sort@plt>
lea    0xe3b(%rip),%rdi
call   1030 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    $0x19,%esi
call   1050 <printArray@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x32,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x19,%rbx
jne    1150 <main+0x10>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x19,%esi
call   1050 <printArray@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <merge_sort@plt>
lea    0xe56(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x19,%esi
call   1050 <printArray@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@str = [15 x i8] c"Sorted array: \00"
define i32 @main() {
%1 = alloca [25 x i32]
br label %2
2: ; preds = %0, %2
%3 = phi i64 [ 0, %0 ], [ %8, %2 ]
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 50
%6 = add nsw i32 %5, 1
%7 = getelementptr inbounds [25 x i32], [25 x i32]* %1, i64 0, i64 %3
store i32 %6, i32* %7
%8 = add nuw nsw i64 %3, 1
%9 = icmp eq i64 %8, 25
br i1 %9, label %10, label %2
10: ; preds = %2
%11 = getelementptr inbounds [25 x i32], [25 x i32]* %1, i64 0, i64 0
%12 = call i32 @printArray(i32* %11, i32 25)
%13 = call i32 @merge_sort(i32* %11, i32 0, i32 24)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%15 = call i32 @printArray(i32* %11, i32 25)
ret i32 0
}