#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ merge_sort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, const char *argv[]) {
  int *my_list = (int *)malloc(sizeof(int) * 45);
  int i = 0;
  srand(time(NULL));
  while (i < 45)
    my_list[i++] = rand() % 99;
  i = 0;
  while (i < 45)
    printf("%2d ", my_list[i++]);
  printf("\n");
  merge_sort(my_list, 0, 45);
  i = 0;
  while (i < 45)
    printf("%2d ", my_list[i++]);
  printf("\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)
mov    $0xb4,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
cmpl   $0x2d,-0x1c(%rbp)
jge    11ce <main+0x6e>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x63,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    119b <main+0x3b>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2d,-0x1c(%rbp)
jge    1207 <main+0xa7>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d5 <main+0x75>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x2d,%edx
call   1070 <merge_sort@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2d,-0x1c(%rbp)
jge    125e <main+0xfe>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122c <main+0xcc>
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0xb4,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0xffffffffa57eb503,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x6,%ecx
add    %edx,%ecx
imul   $0x63,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    $0x2d,%rbx
jne    11a0 <main+0x30>
lea    0xe26(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r15,%rbx,4),%esi
add    $0x1,%rbx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2d,%rbx
jne    11e0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x2d,%edx
call   1080 <merge_sort@plt>
lea    0xde8(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
add    $0x1,%rbx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2d,%rbx
jne    1220 <main+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%2d \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 180)
%4 = inttoptr i64 %3 to i32*
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
br label %7
7: ; preds = %2, %7
%8 = phi i64 [ 0, %2 ], [ %11, %7 ]
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 99
%11 = add nuw nsw i64 %8, 1
%12 = getelementptr inbounds i32, i32* %4, i64 %8
store i32 %10, i32* %12
%13 = icmp eq i64 %11, 45
br i1 %13, label %14, label %7
14: ; preds = %7, %14
%15 = phi i64 [ %16, %14 ], [ 0, %7 ]
%16 = add nuw nsw i64 %15, 1
%17 = getelementptr inbounds i32, i32* %4, i64 %15
%18 = load i32, i32* %17
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = icmp eq i64 %16, 45
br i1 %20, label %21, label %14
21: ; preds = %14
%22 = tail call i32 @putchar(i32 10)
%23 = tail call i32 @merge_sort(i32* %4, i32 0, i32 45)
br label %24
24: ; preds = %21, %24
%25 = phi i64 [ 0, %21 ], [ %26, %24 ]
%26 = add nuw nsw i64 %25, 1
%27 = getelementptr inbounds i32, i32* %4, i64 %25
%28 = load i32, i32* %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = icmp eq i64 %26, 45
br i1 %30, label %31, label %24
31: ; preds = %24
%32 = tail call i32 @putchar(i32 10)
ret i32 0
}