#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 rlite {
  int dummy;
};

/* Variables and functions */
int rl_multi_string_getrange(struct rlite *, long, unsigned char **, long *,
                             long, long);
int rl_string_get_objects(struct rlite *, unsigned char const *, long, long *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int rl_getrange(struct rlite *db, const unsigned char *key, long keylen,
                long start, long stop, unsigned char **value, long *valuelen) {
  long page_number;
  int retval;
  retval = rl_string_get_objects(db, key, keylen, &page_number, NULL, NULL);
  if (0 != retval)
    goto cleanup;
  ;
  retval =
      rl_multi_string_getrange(db, page_number, value, valuelen, start, stop);
  if (0 != retval)
    goto cleanup;
  ;
  retval = 0;
cleanup:
  return retval;
}


x86 assembly (clang, -O0):
<rl_getrange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x38(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%r8
call   1040 <rl_string_get_objects@plt>
mov    %eax,-0x3c(%rbp)
xor    %eax,%eax
cmp    -0x3c(%rbp),%eax
je     1174 <rl_getrange+0x54>
jmp    11ab <rl_getrange+0x8b>
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    0x10(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
call   1030 <rl_multi_string_getrange@plt>
mov    %eax,-0x3c(%rbp)
xor    %eax,%eax
cmp    -0x3c(%rbp),%eax
je     11a4 <rl_getrange+0x84>
jmp    11ab <rl_getrange+0x8b>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rl_getrange>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %r9,%r15
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdi,%rbx
mov    %rsp,%rcx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1040 <rl_string_get_objects@plt>
test   %eax,%eax
jne    1160 <rl_getrange+0x40>
mov    0x30(%rsp),%rcx
mov    (%rsp),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%r8
mov    %r14,%r9
call   1030 <rl_multi_string_getrange@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.rlite = type { i32 }
define i32 @rl_getrange(%struct.rlite* %0, i8* %1, i64 %2, i64 %3, i64 %4, i8** %5, i64* %6) {
%8 = alloca %struct.rlite*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i8**
%14 = alloca i64*
%15 = alloca i64
%16 = alloca i32
store %struct.rlite* %0, %struct.rlite** %8
store i8* %1, i8** %9
store i64 %2, i64* %10
store i64 %3, i64* %11
store i64 %4, i64* %12
store i8** %5, i8*** %13
store i64* %6, i64** %14
%17 = load %struct.rlite*, %struct.rlite** %8
%18 = load i8*, i8** %9
%19 = load i64, i64* %10
%20 = call i32 @rl_string_get_objects(%struct.rlite* %17, i8* %18, i64 %19, i64* %15, i32* null, i32* null)
store i32 %20, i32* %16
%21 = load i32, i32* %16
%22 = icmp ne i32 0, %21
br i1 %22, label %23, label %24
23: ; preds = %7
br label %36
24: ; preds = %7
%25 = load %struct.rlite*, %struct.rlite** %8
%26 = load i64, i64* %15
%27 = load i8**, i8*** %13
%28 = load i64*, i64** %14
%29 = load i64, i64* %11
%30 = load i64, i64* %12
%31 = call i32 @rl_multi_string_getrange(%struct.rlite* %25, i64 %26, i8** %27, i64* %28, i64 %29, i64 %30)
store i32 %31, i32* %16
%32 = load i32, i32* %16
%33 = icmp ne i32 0, %32
br i1 %33, label %34, label %35
34: ; preds = %24
br label %36
35: ; preds = %24
store i32 0, i32* %16
br label %36
36: ; preds = %35, %34, %23
%37 = load i32, i32* %16
ret i32 %37
}

LLVM IR (-O2):
%struct.rlite = type { i32 }
define i32 @rl_getrange(%struct.rlite* %0, i8* %1, i64 %2, i64 %3, i64 %4, i8** %5, i64* %6) {
%8 = alloca i64
%9 = bitcast i64* %8 to i8*
%10 = call i32 @rl_string_get_objects(%struct.rlite* %0, i8* %1, i64 %2, i64* %8, i32* null, i32* null)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i64, i64* %8
%14 = call i32 @rl_multi_string_getrange(%struct.rlite* %0, i64 %13, i8** %5, i64* %6, i64 %3, i64 %4)
br label %15
15: ; preds = %12, %7
%16 = phi i32 [ %10, %7 ], [ %14, %12 ]
ret i32 %16
}