#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*/ insertion_sort(int *, int, int);
int /*<<< orphan*/ merge(int *, int, int, int);
void mixed_sort_insertion(int A[], int p, int r) {
  if (p >= r)
    return;
  if (r - p < 20) {
    insertion_sort(A, p, r);
  } else {
    int q = (p + r) / 2;
    mixed_sort_insertion(A, p, q);
    mixed_sort_insertion(A, q + 1, r);
    merge(A, p, q, r);
  }
}


x86 assembly (clang, -O0):
<mixed_sort_insertion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     1153 <mixed_sort_insertion+0x23>
jmp    11ba <mixed_sort_insertion+0x8a>
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
cmp    $0x14,%eax
jge    1176 <mixed_sort_insertion+0x46>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <insertion_sort@plt>
jmp    11ba <mixed_sort_insertion+0x8a>
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   1040 <mixed_sort_insertion@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1040 <mixed_sort_insertion@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <merge@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mixed_sort_insertion>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edx,%eax
sub    %esi,%eax
jle    1165 <mixed_sort_insertion+0x35>
mov    %edx,%r14d
mov    %esi,%r12d
mov    %rdi,%r15
cmp    $0x13,%eax
jg     1171 <mixed_sort_insertion+0x41>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <insertion_sort@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    (%r14,%r12,1),%eax
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
call   1040 <mixed_sort_insertion@plt>
lea    0x1(%rbx),%esi
mov    %r15,%rdi
mov    %r14d,%edx
call   1040 <mixed_sort_insertion@plt>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <merge@plt>

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

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