#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 */
struct bitwriter {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ bwrite_interpolative_encode_value(struct bitwriter *,
                                                     int const, int const);
void bwrite_interpolative_sublist(struct bitwriter *bw, int *L, int u, int v) {
  if (v - u <= 1) {
    return;
  }
  const int m = (u + v) >> 1, hi = L[v] - (v - m), lo = L[u] + (m - u),
            a = L[m] - lo, r = hi - lo + 1;
  bwrite_interpolative_encode_value(bw, a, r);
  bwrite_interpolative_sublist(bw, L, u, m);
  bwrite_interpolative_sublist(bw, L, m, v);
}


x86 assembly (clang, -O0):
<bwrite_interpolative_sublist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
cmp    $0x1,%eax
jg     114a <bwrite_interpolative_sublist+0x2a>
jmp    11d4 <bwrite_interpolative_sublist+0xb4>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x18(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x1c(%rbp),%ecx
sub    -0x14(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
sub    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
sub    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1040 <bwrite_interpolative_encode_value@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1030 <bwrite_interpolative_sublist@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <bwrite_interpolative_sublist@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bwrite_interpolative_sublist>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%eax
sub    %edx,%eax
cmp    $0x2,%eax
jl     11b2 <bwrite_interpolative_sublist+0x92>
mov    %ecx,%r14d
mov    %rsi,%r12
mov    %rdi,%r15
movslq %ecx,%rax
mov    %rax,0x10(%rsp)
mov    $0x1,%eax
sub    %ecx,%eax
mov    %rax,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%rdx,%r14,1),%ebp
sar    %ebp
movslq %edx,%r13
mov    %ebp,%eax
sub    %r13d,%eax
add    (%r12,%r13,4),%eax
movslq %ebp,%rbx
mov    (%r12,%rbx,4),%esi
sub    %eax,%esi
mov    0x8(%rsp),%rcx
lea    (%rcx,%rbx,1),%edx
mov    0x10(%rsp),%rcx
add    (%r12,%rcx,4),%edx
sub    %eax,%edx
mov    %r15,%rdi
call   1040 <bwrite_interpolative_encode_value@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
mov    %ebx,%ecx
call   1030 <bwrite_interpolative_sublist@plt>
mov    %r14d,%eax
sub    %ebx,%eax
mov    %ebp,%edx
cmp    $0x1,%eax
jg     1160 <bwrite_interpolative_sublist+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.bitwriter = type { i32 }
define void @bwrite_interpolative_sublist(%struct.bitwriter* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca %struct.bitwriter*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store %struct.bitwriter* %0, %struct.bitwriter** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%14 = load i32, i32* %8
%15 = load i32, i32* %7
%16 = sub nsw i32 %14, %15
%17 = icmp sle i32 %16, 1
br i1 %17, label %18, label %19
18: ; preds = %4
br label %65
19: ; preds = %4
%20 = load i32, i32* %7
%21 = load i32, i32* %8
%22 = add nsw i32 %20, %21
%23 = ashr i32 %22, 1
store i32 %23, i32* %9
%24 = load i32*, i32** %6
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = sub nsw i32 %29, %30
%32 = sub nsw i32 %28, %31
store i32 %32, i32* %10
%33 = load i32*, i32** %6
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
%37 = load i32, i32* %36
%38 = load i32, i32* %9
%39 = load i32, i32* %7
%40 = sub nsw i32 %38, %39
%41 = add nsw i32 %37, %40
store i32 %41, i32* %11
%42 = load i32*, i32** %6
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = load i32, i32* %11
%48 = sub nsw i32 %46, %47
store i32 %48, i32* %12
%49 = load i32, i32* %10
%50 = load i32, i32* %11
%51 = sub nsw i32 %49, %50
%52 = add nsw i32 %51, 1
store i32 %52, i32* %13
%53 = load %struct.bitwriter*, %struct.bitwriter** %5
%54 = load i32, i32* %12
%55 = load i32, i32* %13
%56 = call i32 @bwrite_interpolative_encode_value(%struct.bitwriter* %53, i32 %54, i32 %55)
%57 = load %struct.bitwriter*, %struct.bitwriter** %5
%58 = load i32*, i32** %6
%59 = load i32, i32* %7
%60 = load i32, i32* %9
%61 = load %struct.bitwriter*, %struct.bitwriter** %5
%62 = load i32*, i32** %6
%63 = load i32, i32* %9
%64 = load i32, i32* %8
br label %65
65: ; preds = %19, %18
ret void
}

LLVM IR (-O2):
%struct.bitwriter = type { i32 }
define void @bwrite_interpolative_sublist(%struct.bitwriter* %0, i32* %1, i32 %2, i32 %3) {
%5 = sub nsw i32 %3, %2
%6 = icmp slt i32 %5, 2
br i1 %6, label %31, label %7
7: ; preds = %4
%8 = sext i32 %3 to i64
%9 = getelementptr inbounds i32, i32* %1, i64 %8
%10 = sub i32 1, %3
br label %11
11: ; preds = %7, %11
%12 = phi i32 [ %2, %7 ], [ %14, %11 ]
%13 = add nsw i32 %12, %3
%14 = ashr i32 %13, 1
%15 = load i32, i32* %9
%16 = sext i32 %12 to i64
%17 = getelementptr inbounds i32, i32* %1, i64 %16
%18 = load i32, i32* %17
%19 = sub nsw i32 %14, %12
%20 = add nsw i32 %18, %19
%21 = sext i32 %14 to i64
%22 = getelementptr inbounds i32, i32* %1, i64 %21
%23 = load i32, i32* %22
%24 = sub nsw i32 %23, %20
%25 = add i32 %10, %14
%26 = add i32 %25, %15
%27 = sub i32 %26, %20
%28 = tail call i32 @bwrite_interpolative_encode_value(%struct.bitwriter* %0, i32 %24, i32 %27)
tail call void @bwrite_interpolative_sublist(%struct.bitwriter* %0, i32* %1, i32 %12, i32 %14)
%29 = sub nsw i32 %3, %14
%30 = icmp slt i32 %29, 2
br i1 %30, label %31, label %11
31: ; preds = %11, %4
ret void
}