#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_key_get(struct rlite *, unsigned char const *, long, unsigned char *,
               long *, long *, int /*<<< orphan*/ *, long *);
int rl_key_set(struct rlite *, unsigned char const *, long, unsigned char, long,
               unsigned long long, long);
int rl_key_expires(struct rlite *db, const unsigned char *key, long keylen,
                   unsigned long long expires) {
  int retval;
  unsigned char type;
  long string_page, value_page, version;
  retval = rl_key_get(db, key, keylen, &type, &string_page, &value_page, NULL,
                      &version);
  if (2 != retval)
    goto cleanup;
  ;
  retval = rl_key_set(db, key, keylen, type, value_page, expires, version + 1);
  if (0 != retval)
    goto cleanup;
  ;
cleanup:
  return retval;
}


x86 assembly (clang, -O0):
<rl_key_expires>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x25(%rbp),%rcx
lea    -0x30(%rbp),%r8
lea    -0x38(%rbp),%r9
xor    %eax,%eax
lea    -0x40(%rbp),%rax
movq   $0x0,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <rl_key_get@plt>
mov    %eax,-0x24(%rbp)
mov    $0x2,%eax
cmp    -0x24(%rbp),%eax
je     117e <rl_key_expires+0x5e>
jmp    11c1 <rl_key_expires+0xa1>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x25(%rbp),%cl
mov    -0x38(%rbp),%r8
mov    -0x20(%rbp),%r9
mov    -0x40(%rbp),%rax
add    $0x1,%rax
movzbl %cl,%ecx
mov    %rax,(%rsp)
call   1040 <rl_key_set@plt>
mov    %eax,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x24(%rbp),%eax
je     11bc <rl_key_expires+0x9c>
jmp    11c1 <rl_key_expires+0xa1>
jmp    11c1 <rl_key_expires+0xa1>
mov    -0x24(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rl_key_expires>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0x10(%rsp),%rax
lea    0xf(%rsp),%rcx
lea    0x20(%rsp),%r8
lea    0x18(%rsp),%r9
push   %rax
push   $0x0
call   1030 <rl_key_get@plt>
add    $0x10,%rsp
cmp    $0x2,%eax
jne    1189 <rl_key_expires+0x69>
movzbl 0xf(%rsp),%ecx
mov    0x18(%rsp),%r8
mov    0x10(%rsp),%rax
add    $0x1,%rax
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%r9
push   %rax
call   1040 <rl_key_set@plt>
add    $0x10,%rsp
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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