#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, int *);
void mergesort_r(int izq, int der, int *lista, int *iter) {
  if (der - izq <= 1) {
    return;
  }
  int izq_inicio = izq;
  int izq_fin = (izq + der) / 2;
  int der_inicio = izq_fin;
  int der_fin = der;
  mergesort_r(izq_inicio, izq_fin, lista, iter);
  mergesort_r(der_inicio, der_fin, lista, iter);
  merge(lista, izq_inicio, izq_fin, der_inicio, der_fin, iter);
}


x86 assembly (clang, -O0):
<mergesort_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
cmp    $0x1,%eax
jg     114a <mergesort_r+0x2a>
jmp    11ad <mergesort_r+0x8d>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1040 <mergesort_r@plt>
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1040 <mergesort_r@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x18(%rbp),%r9
call   1030 <merge@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mergesort_r>:
mov    %esi,%eax
sub    %edi,%eax
cmp    $0x1,%eax
jg     112a <mergesort_r+0xa>
ret
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%r12d
mov    %edi,%ebx
lea    (%r12,%rbx,1),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    %ebp,%esi
call   1040 <mergesort_r@plt>
mov    %ebp,%edi
mov    %r12d,%esi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <mergesort_r@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %ebp,%ecx
mov    %r12d,%r8d
mov    %r14,%r9
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <merge@plt>

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

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