#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(int *, int *, int, int, int);
void merge_sort_ric(int v[], int temp[], int a, int b) {
  int m;
  if (a + 1 >= b)
    return;
  m = (a + b) / 2;
  merge_sort_ric(v, temp, a, m);
  merge_sort_ric(v, temp, m, b);
  merge(v, temp, a, m, b);
}


x86 assembly (clang, -O0):
<merge_sort_ric>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cmp    -0x18(%rbp),%eax
jl     114a <merge_sort_ric+0x2a>
jmp    1198 <merge_sort_ric+0x78>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1040 <merge_sort_ric@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <merge_sort_ric@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1030 <merge@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merge_sort_ric>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebx
lea    0x1(%rbx),%eax
cmp    %ecx,%eax
jge    117a <merge_sort_ric+0x5a>
mov    %ecx,%r14d
mov    %rsi,%r15
mov    %rdi,%r12
lea    (%r14,%rbx,1),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    %ebx,%edx
mov    %ebp,%ecx
call   1040 <merge_sort_ric@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1040 <merge_sort_ric@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %r14d,%r8d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <merge@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @merge_sort_ric(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = add nsw i32 %2, 1
%6 = icmp slt i32 %5, %3
br i1 %6, label %8, label %7
7: ; preds = %4, %8
ret void
8: ; preds = %4
%9 = add nsw i32 %3, %2
%10 = sdiv i32 %9, 2
tail call void @merge_sort_ric(i32* %0, i32* %1, i32 %2, i32 %10)
tail call void @merge_sort_ric(i32* %0, i32* %1, i32 %10, i32 %3)
%11 = tail call i32 @merge(i32* %0, i32* %1, i32 %2, i32 %10, i32 %3)
br label %7
}