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

/* Variables and functions */
scalar_t__ ccnl_cistlv_prependName(struct ccnl_prefix_s *, int *,
                                   unsigned char *);
scalar_t__ ccnl_cistlv_prependTL(int, int, int *, unsigned char *);
int ccnl_cistlv_prependInterest(struct ccnl_prefix_s *name, int *offset,
                                unsigned char *buf) {
  int oldoffset = *offset;
  if (ccnl_cistlv_prependName(name, offset, buf))
    return -1;
  if (ccnl_cistlv_prependTL(1, oldoffset - *offset, offset, buf) < 0)
    return -1;
  return oldoffset - *offset;
}


x86 assembly (clang, -O0):
<ccnl_cistlv_prependInterest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <ccnl_cistlv_prependName@plt>
cmp    $0x0,%rax
je     1164 <ccnl_cistlv_prependInterest+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a1 <ccnl_cistlv_prependInterest+0x81>
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%rax
sub    (%rax),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%edi
call   1030 <ccnl_cistlv_prependTL@plt>
cmp    $0x0,%rax
jge    1195 <ccnl_cistlv_prependInterest+0x75>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a1 <ccnl_cistlv_prependInterest+0x81>
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ccnl_cistlv_prependInterest>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    (%rsi),%r15d
call   1040 <ccnl_cistlv_prependName@plt>
mov    $0xffffffff,%r14d
test   %rax,%rax
jne    1160 <ccnl_cistlv_prependInterest+0x40>
mov    %r15d,%esi
sub    (%rbx),%esi
mov    $0x1,%edi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   1030 <ccnl_cistlv_prependTL@plt>
test   %rax,%rax
js     1160 <ccnl_cistlv_prependInterest+0x40>
sub    (%rbx),%r15d
mov    %r15d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.ccnl_prefix_s = type { i32 }
define i32 @ccnl_cistlv_prependInterest(%struct.ccnl_prefix_s* %0, i32* %1, i8* %2) {
%4 = load i32, i32* %1
%5 = tail call i64 @ccnl_cistlv_prependName(%struct.ccnl_prefix_s* %0, i32* %1, i8* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %3
%8 = load i32, i32* %1
%9 = sub nsw i32 %4, %8
%10 = tail call i64 @ccnl_cistlv_prependTL(i32 1, i32 %9, i32* %1, i8* %2)
%11 = icmp slt i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = load i32, i32* %1
%14 = sub nsw i32 %4, %13
br label %15
15: ; preds = %7, %3, %12
%16 = phi i32 [ %14, %12 ], [ -1, %3 ], [ -1, %7 ]
ret i32 %16
}