#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 */
int ccnl_ccnb_mkHeader(unsigned char *, int, int);
scalar_t__ ccnl_ccnb_mkName(struct ccnl_prefix_s *, unsigned char *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int ccnl_ccnb_fillContent(struct ccnl_prefix_s *name, unsigned char *data,
                          int datalen, int *contentpos, unsigned char *out) {
  int len = 0;
  len = ccnl_ccnb_mkHeader(out, 64, 2);
  len += ccnl_ccnb_mkName(name, out + len);
  len += ccnl_ccnb_mkHeader(out + len, 19, 2);
  len += ccnl_ccnb_mkHeader(out + len, datalen, 5);
  if (contentpos)
    *contentpos = len;
  memcpy(out + len, data, datalen);
  if (contentpos)
    *contentpos = len;
  len += datalen;
  out[len++] = 0;
  out[len++] = 0;
  return len;
}


x86 assembly (clang, -O0):
<ccnl_ccnb_fillContent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x40,%esi
mov    $0x2,%edx
call   1040 <ccnl_ccnb_mkHeader@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x2c(%rbp),%rax
add    %rax,%rsi
call   1050 <ccnl_ccnb_mkName@plt>
mov    %rax,%rcx
movslq -0x2c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
movslq -0x2c(%rbp),%rax
add    %rax,%rdi
mov    $0x13,%esi
mov    $0x2,%edx
call   1040 <ccnl_ccnb_mkHeader@plt>
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
movslq -0x2c(%rbp),%rax
add    %rax,%rdi
mov    -0x14(%rbp),%esi
mov    $0x5,%edx
call   1040 <ccnl_ccnb_mkHeader@plt>
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11db <ccnl_ccnb_fillContent+0xab>
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rdi
movslq -0x2c(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <memcpy@plt>
cmpq   $0x0,-0x20(%rbp)
je     1206 <ccnl_ccnb_fillContent+0xd6>
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x2c(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ccnl_ccnb_fillContent>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%rbp
mov    %rcx,%r15
mov    %edx,%r14d
mov    %rsi,%r12
mov    %rdi,%r13
mov    %r8,%rdi
mov    $0x40,%esi
mov    $0x2,%edx
call   1040 <ccnl_ccnb_mkHeader@plt>
movslq %eax,%rbx
lea    (%rbx,%rbp,1),%rsi
mov    %r13,%rdi
call   1050 <ccnl_ccnb_mkName@plt>
add    %eax,%ebx
movslq %ebx,%rbx
lea    (%rbx,%rbp,1),%rdi
mov    $0x13,%esi
mov    $0x2,%edx
call   1040 <ccnl_ccnb_mkHeader@plt>
add    %eax,%ebx
movslq %ebx,%rbx
lea    (%rbx,%rbp,1),%rdi
mov    %r14d,%esi
mov    $0x5,%edx
call   1040 <ccnl_ccnb_mkHeader@plt>
add    %eax,%ebx
test   %r15,%r15
je     11bc <ccnl_ccnb_fillContent+0x8c>
mov    %ebx,(%r15)
movslq %ebx,%r13
mov    %rbp,%rdi
add    %r13,%rdi
mov    %r12,%rsi
mov    %r14d,%edx
call   1030 <memcpy@plt>
mov    %r13d,(%r15)
jmp    11cd <ccnl_ccnb_fillContent+0x9d>
movslq %ebx,%rdi
add    %rbp,%rdi
mov    %r12,%rsi
mov    %r14d,%edx
call   1030 <memcpy@plt>
lea    (%rbx,%r14,1),%eax
cltq
movw   $0x0,0x0(%rbp,%rax,1)
lea    (%rbx,%r14,1),%eax
add    $0x2,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ccnl_prefix_s = type { i32 }
define i32 @ccnl_ccnb_fillContent(%struct.ccnl_prefix_s* %0, i8* %1, i32 %2, i32* %3, i8* %4) {
%6 = alloca %struct.ccnl_prefix_s*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i32
store %struct.ccnl_prefix_s* %0, %struct.ccnl_prefix_s** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32* %3, i32** %9
store i8* %4, i8** %10
store i32 0, i32* %11
%12 = load i8*, i8** %10
%13 = call i32 @ccnl_ccnb_mkHeader(i8* %12, i32 64, i32 2)
store i32 %13, i32* %11
%14 = load %struct.ccnl_prefix_s*, %struct.ccnl_prefix_s** %6
%15 = load i8*, i8** %10
%16 = load i32, i32* %11
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = call i64 @ccnl_ccnb_mkName(%struct.ccnl_prefix_s* %14, i8* %18)
%20 = load i32, i32* %11
%21 = sext i32 %20 to i64
%22 = add nsw i64 %21, %19
%23 = trunc i64 %22 to i32
store i32 %23, i32* %11
%24 = load i8*, i8** %10
%25 = load i32, i32* %11
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = call i32 @ccnl_ccnb_mkHeader(i8* %27, i32 19, i32 2)
%29 = load i32, i32* %11
%30 = add nsw i32 %29, %28
store i32 %30, i32* %11
%31 = load i8*, i8** %10
%32 = load i32, i32* %11
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i32, i32* %8
%36 = call i32 @ccnl_ccnb_mkHeader(i8* %34, i32 %35, i32 5)
%37 = load i32, i32* %11
%38 = add nsw i32 %37, %36
store i32 %38, i32* %11
%39 = load i32*, i32** %9
%40 = icmp ne i32* %39, null
br i1 %40, label %41, label %44
41: ; preds = %5
%42 = load i32, i32* %11
%43 = load i32*, i32** %9
store i32 %42, i32* %43
br label %44
44: ; preds = %41, %5
%45 = load i8*, i8** %10
%46 = load i32, i32* %11
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8*, i8** %7
%50 = load i32, i32* %8
%51 = call i32 @memcpy(i8* %48, i8* %49, i32 %50)
%52 = load i32*, i32** %9
%53 = icmp ne i32* %52, null
br i1 %53, label %54, label %57
54: ; preds = %44
%55 = load i32, i32* %11
%56 = load i32*, i32** %9
store i32 %55, i32* %56
br label %57
57: ; preds = %54, %44
%58 = load i32, i32* %8
%59 = load i32, i32* %11
%60 = add nsw i32 %59, %58
store i32 %60, i32* %11
%61 = load i8*, i8** %10
%62 = load i32, i32* %11
%63 = add nsw i32 %62, 1
store i32 %63, i32* %11
%64 = sext i32 %62 to i64
%65 = getelementptr inbounds i8, i8* %61, i64 %64
store i8 0, i8* %65
%66 = load i8*, i8** %10
%67 = load i32, i32* %11
%68 = add nsw i32 %67, 1
store i32 %68, i32* %11
%69 = sext i32 %67 to i64
%70 = getelementptr inbounds i8, i8* %66, i64 %69
store i8 0, i8* %70
%71 = load i32, i32* %11
ret i32 %71
}

LLVM IR (-O2):
%struct.ccnl_prefix_s = type { i32 }
define i32 @ccnl_ccnb_fillContent(%struct.ccnl_prefix_s* %0, i8* %1, i32 %2, i32* writeonly %3, i8* %4) {
%6 = tail call i32 @ccnl_ccnb_mkHeader(i8* %4, i32 64, i32 2)
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %4, i64 %7
%9 = tail call i64 @ccnl_ccnb_mkName(%struct.ccnl_prefix_s* %0, i8* %8)
%10 = trunc i64 %9 to i32
%11 = add i32 %6, %10
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %4, i64 %12
%14 = tail call i32 @ccnl_ccnb_mkHeader(i8* %13, i32 19, i32 2)
%15 = add nsw i32 %11, %14
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %4, i64 %16
%18 = tail call i32 @ccnl_ccnb_mkHeader(i8* %17, i32 %2, i32 5)
%19 = add nsw i32 %15, %18
%20 = icmp eq i32* %3, null
br i1 %20, label %25, label %21
21: ; preds = %5
store i32 %19, i32* %3
%22 = sext i32 %19 to i64
%23 = getelementptr inbounds i8, i8* %4, i64 %22
%24 = tail call i32 @memcpy(i8* %23, i8* %1, i32 %2)
store i32 %19, i32* %3
br label %29
25: ; preds = %5
%26 = sext i32 %19 to i64
%27 = getelementptr inbounds i8, i8* %4, i64 %26
%28 = tail call i32 @memcpy(i8* %27, i8* %1, i32 %2)
br label %29
29: ; preds = %25, %21
%30 = add nsw i32 %19, %2
%31 = add nsw i32 %30, 1
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds i8, i8* %4, i64 %32
store i8 0, i8* %33
%34 = add nsw i32 %30, 2
%35 = sext i32 %31 to i64
%36 = getelementptr inbounds i8, i8* %4, i64 %35
store i8 0, i8* %36
ret i32 %34
}