#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__ ccnl_ndntlv_prependTLval(int, int *, unsigned char *);
int ccnl_ndntlv_prependTL(int type, unsigned int len, int *offset,
                          unsigned char *buf) {
  int oldoffset = *offset;
  if (ccnl_ndntlv_prependTLval(len, offset, buf) < 0)
    return -1;
  if (ccnl_ndntlv_prependTLval(type, offset, buf) < 0)
    return -1;
  return oldoffset - *offset;
}


x86 assembly (clang, -O0):
<ccnl_ndntlv_prependTL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <ccnl_ndntlv_prependTLval@plt>
cmp    $0x0,%rax
jge    1155 <ccnl_ndntlv_prependTL+0x45>
movl   $0xffffffff,-0x4(%rbp)
jmp    1187 <ccnl_ndntlv_prependTL+0x77>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <ccnl_ndntlv_prependTLval@plt>
cmp    $0x0,%rax
jge    117b <ccnl_ndntlv_prependTL+0x6b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1187 <ccnl_ndntlv_prependTL+0x77>
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_ndntlv_prependTL>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%rbp
mov    %rdx,%rbx
mov    %edi,%r15d
mov    (%rdx),%r12d
mov    %esi,%edi
mov    %rdx,%rsi
mov    %rcx,%rdx
call   1030 <ccnl_ndntlv_prependTLval@plt>
mov    $0xffffffff,%r14d
test   %rax,%rax
js     1155 <ccnl_ndntlv_prependTL+0x45>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1030 <ccnl_ndntlv_prependTLval@plt>
test   %rax,%rax
js     1155 <ccnl_ndntlv_prependTL+0x45>
sub    (%rbx),%r12d
mov    %r12d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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