#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_get(struct rlite *, long, unsigned char **, long *);
int rl_string_get_objects(struct rlite *, unsigned char const *, long, long *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int rl_get(struct rlite *db, const unsigned char *key, long keylen,
           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;
  ;
  if (valuelen) {
    retval = rl_multi_string_get(db, page_number, value, valuelen);
    if (0 != retval)
      goto cleanup;
    ;
  }
  retval = 0;
cleanup:
  return retval;
}


x86 assembly (clang, -O0):
<rl_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x30(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%r8
call   1040 <rl_string_get_objects@plt>
mov    %eax,-0x34(%rbp)
xor    %eax,%eax
cmp    -0x34(%rbp),%eax
je     116c <rl_get+0x4c>
jmp    11ab <rl_get+0x8b>
cmpq   $0x0,-0x28(%rbp)
je     11a4 <rl_get+0x84>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <rl_multi_string_get@plt>
mov    %eax,-0x34(%rbp)
xor    %eax,%eax
cmp    -0x34(%rbp),%eax
je     119f <rl_get+0x7f>
jmp    11ab <rl_get+0x8b>
jmp    11a4 <rl_get+0x84>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rl_get>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r15
mov    %rcx,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%rcx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1040 <rl_string_get_objects@plt>
test   %eax,%eax
jne    1164 <rl_get+0x44>
test   %r15,%r15
je     1162 <rl_get+0x42>
mov    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <rl_multi_string_get@plt>
test   %eax,%eax
jne    1164 <rl_get+0x44>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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