#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 */
scalar_t__ price_len(int);
scalar_t__ price_offset(int, int);
int price_lz(int offset, int length, int used) {
  int res = 1;
  if (offset >= 5400) {
    length--;
  }
  if (offset >= 0x060000) {
    length--;
  }
  offset--;
  res += price_offset(offset, used);
  res += price_len(length - 2 + 2);
  return res;
}


x86 assembly (clang, -O0):
<price_lz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x1518,-0x4(%rbp)
jl     114e <price_lz+0x2e>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x60000,-0x4(%rbp)
jl     1164 <price_lz+0x44>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <price_offset@plt>
mov    %rax,%rcx
movslq -0x10(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x2,%edi
add    $0x2,%edi
call   1040 <price_len@plt>
mov    %rax,%rcx
movslq -0x10(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<price_lz>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
xor    %eax,%eax
cmp    $0x1518,%edi
setge  %al
sub    %eax,%ebx
xor    %eax,%eax
cmp    $0x60000,%edi
setge  %al
sub    %eax,%ebx
add    $0xffffffff,%edi
mov    %edx,%esi
call   1030 <price_offset@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1040 <price_len@plt>
add    %r14d,%eax
add    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @price_lz(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 1, i32* %7
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 5400
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i32, i32* %5
%12 = add nsw i32 %11, -1
store i32 %12, i32* %5
br label %13
13: ; preds = %10, %3
%14 = load i32, i32* %4
%15 = icmp sge i32 %14, 393216
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %5
%18 = add nsw i32 %17, -1
store i32 %18, i32* %5
br label %19
19: ; preds = %16, %13
%20 = load i32, i32* %4
%21 = add nsw i32 %20, -1
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = load i32, i32* %6
%24 = call i64 @price_offset(i32 %22, i32 %23)
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = add nsw i64 %26, %24
%28 = trunc i64 %27 to i32
store i32 %28, i32* %7
%29 = load i32, i32* %5
%30 = sub nsw i32 %29, 2
%31 = add nsw i32 %30, 2
%32 = call i64 @price_len(i32 %31)
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = add nsw i64 %34, %32
%36 = trunc i64 %35 to i32
store i32 %36, i32* %7
%37 = load i32, i32* %7
ret i32 %37
}

LLVM IR (-O2):
define i32 @price_lz(i32 %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %0, 5399
%5 = sext i1 %4 to i32
%6 = add nsw i32 %5, %1
%7 = icmp sgt i32 %0, 393215
%8 = sext i1 %7 to i32
%9 = add nsw i32 %6, %8
%10 = add nsw i32 %0, -1
%11 = tail call i64 @price_offset(i32 %10, i32 %2)
%12 = tail call i64 @price_len(i32 %9)
%13 = add i64 %11, 1
%14 = add i64 %13, %12
%15 = trunc i64 %14 to i32
ret i32 %15
}