#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 insertion_sort_rec_helper_helper(int *, int, int, int);
void insertion_sort_rec_helper(int *arr, int n, int i) {
  if (i == n) {
    return;
  } else {
    int tmp = arr[i];
    int j = insertion_sort_rec_helper_helper(arr, n, i, tmp);
    arr[j] = tmp;
    insertion_sort_rec_helper(arr, n, i + 1);
  }
}


x86 assembly (clang, -O0):
<insertion_sort_rec_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1143 <insertion_sort_rec_helper+0x23>
jmp    1186 <insertion_sort_rec_helper+0x66>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1040 <insertion_sort_rec_helper_helper@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
call   1030 <insertion_sort_rec_helper@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insertion_sort_rec_helper>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    %esi,%edx
je     1156 <insertion_sort_rec_helper+0x46>
mov    %edx,%ebx
mov    %esi,%r14d
mov    %rdi,%r15
movslq %edx,%rax
lea    (%rdi,%rax,4),%rbp
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%r12d
mov    %r15,%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %r12d,%ecx
call   1030 <insertion_sort_rec_helper_helper@plt>
cltq
mov    %r12d,(%r15,%rax,4)
add    $0x4,%rbp
add    $0x1,%ebx
cmp    %ebx,%r14d
jne    1130 <insertion_sort_rec_helper+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @insertion_sort_rec_helper(i32* %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, %1
br i1 %4, label %18, label %5
5: ; preds = %3
%6 = sext i32 %2 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ %6, %5 ], [ %15, %7 ]
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = load i32, i32* %9
%11 = trunc i64 %8 to i32
%12 = tail call i32 @insertion_sort_rec_helper_helper(i32* %0, i32 %1, i32 %11, i32 %10)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %0, i64 %13
store i32 %10, i32* %14
%15 = add nsw i64 %8, 1
%16 = trunc i64 %15 to i32
%17 = icmp eq i32 %16, %1
br i1 %17, label %18, label %7
18: ; preds = %7, %3
ret void
}