#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 */
struct student_rec {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ combine(struct student_rec *, int, int, int);
int /*<<< orphan*/ mod_bubble_sort(struct student_rec *);
void MergeSort(struct student_rec *temp_students, int low, int high) {
  int mid = 0;
  if (mid < 4) {
    mod_bubble_sort(temp_students);
  } else if (low < high) {
    mid = (low + high) / 2;
    MergeSort(temp_students, low, mid);
    MergeSort(temp_students, mid + 1, high);
    combine(temp_students, low, mid, high);
  }
}


x86 assembly (clang, -O0):
<MergeSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1161 <MergeSort+0x31>
mov    -0x8(%rbp),%rdi
call   1040 <mod_bubble_sort@plt>
jmp    11b6 <MergeSort+0x86>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11b1 <MergeSort+0x81>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <MergeSort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1050 <MergeSort@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <combine@plt>
jmp    11b6 <MergeSort+0x86>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MergeSort>:
jmp    1030 <mod_bubble_sort@plt>

LLVM IR (-O0):
%struct.student_rec = type { i32 }
define void @MergeSort(%struct.student_rec* %0, i32 %1, i32 %2) {
%4 = alloca %struct.student_rec*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store %struct.student_rec* %0, %struct.student_rec** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
%8 = load i32, i32* %7
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load %struct.student_rec*, %struct.student_rec** %4
%12 = call i32 @mod_bubble_sort(%struct.student_rec* %11)
br label %35
13: ; preds = %3
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %34
17: ; preds = %13
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = add nsw i32 %18, %19
%21 = sdiv i32 %20, 2
store i32 %21, i32* %7
%22 = load %struct.student_rec*, %struct.student_rec** %4
%23 = load i32, i32* %5
%24 = load i32, i32* %7
%25 = load %struct.student_rec*, %struct.student_rec** %4
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
%28 = load i32, i32* %6
%29 = load %struct.student_rec*, %struct.student_rec** %4
%30 = load i32, i32* %5
%31 = load i32, i32* %7
%32 = load i32, i32* %6
%33 = call i32 @combine(%struct.student_rec* %29, i32 %30, i32 %31, i32 %32)
br label %34
34: ; preds = %17, %13
br label %35
35: ; preds = %34, %10
ret void
}

LLVM IR (-O2):
%struct.student_rec = type { i32 }
define void @MergeSort(%struct.student_rec* %0, i32 %1, i32 %2) {
%4 = tail call i32 @mod_bubble_sort(%struct.student_rec* %0)
ret void
}