#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 */
int bee_tlv_appender(int, int /*<<< orphan*/, char *, char **, int);
int /*<<< orphan*/ noly_hexdump(char *, int);
int /*<<< orphan*/ strlen(char *);
int simple() {
  char a[] = "a";
  char b[] = "bb";
  char c[] = "cc";
  char *data = NULL;
  int total = 0;
  total = bee_tlv_appender(1, strlen(a), a, &data, total);
  total = bee_tlv_appender(2, strlen(b), b, &data, total);
  total = bee_tlv_appender(3, strlen(c), c, &data, total);
  noly_hexdump(data, total);
  return 0;
}


x86 assembly (clang, -O0):
<simple>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xec1(%rip),%ax
mov    %ax,-0x2(%rbp)
mov    0xeb8(%rip),%ax
mov    %ax,-0x5(%rbp)
mov    0xeb0(%rip),%al
mov    %al,-0x3(%rbp)
mov    0xea7(%rip),%ax
mov    %ax,-0x8(%rbp)
mov    0xe9f(%rip),%al
mov    %al,-0x6(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x2(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
lea    -0x2(%rbp),%rdx
mov    -0x14(%rbp),%r8d
mov    $0x1,%edi
lea    -0x10(%rbp),%rcx
call   1040 <bee_tlv_appender@plt>
mov    %eax,-0x14(%rbp)
lea    -0x5(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
lea    -0x5(%rbp),%rdx
mov    -0x14(%rbp),%r8d
mov    $0x2,%edi
lea    -0x10(%rbp),%rcx
call   1040 <bee_tlv_appender@plt>
mov    %eax,-0x14(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
lea    -0x8(%rbp),%rdx
mov    -0x14(%rbp),%r8d
mov    $0x3,%edi
lea    -0x10(%rbp),%rcx
call   1040 <bee_tlv_appender@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <noly_hexdump@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movw   $0x61,0x16(%rsp)
movb   $0x0,0x14(%rsp)
movw   $0x6262,0x12(%rsp)
movb   $0x0,0x10(%rsp)
movw   $0x6363,0xe(%rsp)
movq   $0x0,0x18(%rsp)
lea    0x16(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0x18(%rsp),%r14
mov    $0x1,%edi
mov    %eax,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1040 <bee_tlv_appender@plt>
mov    %eax,%ebx
lea    0x12(%rsp),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    $0x2,%edi
mov    %eax,%esi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %ebx,%r8d
call   1040 <bee_tlv_appender@plt>
mov    %eax,%ebx
lea    0xe(%rsp),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    $0x3,%edi
mov    %eax,%esi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %ebx,%r8d
call   1040 <bee_tlv_appender@plt>
mov    0x18(%rsp),%rdi
mov    %eax,%esi
call   1050 <noly_hexdump@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.simple.a = [2 x i8] c"a\00"
@__const.simple.b = [3 x i8] c"bb\00"
@__const.simple.c = [3 x i8] c"cc\00"
define i32 @simple() {
%1 = alloca [2 x i8]
%2 = alloca [3 x i8]
%3 = alloca [3 x i8]
%4 = alloca i8*
%5 = alloca i32
%6 = bitcast [2 x i8]* %1 to i8*
%7 = bitcast [3 x i8]* %2 to i8*
%8 = bitcast [3 x i8]* %3 to i8*
store i8* null, i8** %4
store i32 0, i32* %5
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = getelementptr inbounds [2 x i8], [2 x i8]* %1, i64 0, i64 0
%12 = load i32, i32* %5
%13 = call i32 @bee_tlv_appender(i32 1, i32 %10, i8* %11, i8** %4, i32 %12)
store i32 %13, i32* %5
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%17 = load i32, i32* %5
%18 = call i32 @bee_tlv_appender(i32 2, i32 %15, i8* %16, i8** %4, i32 %17)
store i32 %18, i32* %5
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
%21 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%22 = load i32, i32* %5
%23 = call i32 @bee_tlv_appender(i32 3, i32 %20, i8* %21, i8** %4, i32 %22)
store i32 %23, i32* %5
%24 = load i8*, i8** %4
%25 = load i32, i32* %5
%26 = call i32 @noly_hexdump(i8* %24, i32 %25)
ret i32 0
}

LLVM IR (-O2):
@__const.simple.b = [3 x i8] c"bb\00"
@__const.simple.c = [3 x i8] c"cc\00"
define i32 @simple() {
%1 = alloca i16
%2 = alloca [3 x i8]
%3 = alloca [3 x i8]
%4 = alloca i8*
%5 = bitcast i16* %1 to i8*
store i16 97, i16* %1
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%8 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%9 = call i32 @strlen(i8* %5)
%10 = call i32 @bee_tlv_appender(i32 1, i32 %9, i8* %5, i8** %4, i32 0)
%11 = call i32 @strlen(i8* %6)
%12 = call i32 @bee_tlv_appender(i32 2, i32 %11, i8* %6, i8** %4, i32 %10)
%13 = call i32 @strlen(i8* %7)
%14 = call i32 @bee_tlv_appender(i32 3, i32 %13, i8* %7, i8** %4, i32 %12)
%15 = load i8*, i8** %4
%16 = call i32 @noly_hexdump(i8* %15, i32 %14)
ret i32 0
}