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


x86 assembly (clang, -O0):
<mergesort_seq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
cmp    $0x1,%eax
jg     1146 <mergesort_seq+0x26>
jmp    1191 <mergesort_seq+0x71>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <mergesort_seq@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <mergesort_seq@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <merge@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mergesort_seq>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
sub    %esi,%ebx
cmp    $0x1,%ebx
jg     113b <mergesort_seq+0x1b>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edx,%r15d
mov    %esi,%ebp
mov    %rdi,%r14
shr    %ebx
add    %esi,%ebx
mov    %ebx,%edx
call   1040 <mergesort_seq@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
call   1040 <mergesort_seq@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <merge@plt>

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

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