#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 /*<<< orphan*/ HadTu_end(void *);
scalar_t__ HadTu_paddedSize(void *);
int /*<<< orphan*/ HadTu_setSize(void *, scalar_t__);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/, void const *, size_t);
void *realloc(void *, scalar_t__);
void *SubEvt_appendData(void *my, const void *data, size_t size) {
  my = realloc(my, HadTu_paddedSize(my) + size);
  memcpy(HadTu_end(my), data, size);
  HadTu_setSize(my, HadTu_paddedSize(my) + size);
  return my;
}


x86 assembly (clang, -O0):
<SubEvt_appendData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <HadTu_paddedSize@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rsi
add    -0x18(%rbp),%rsi
call   1070 <realloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <HadTu_end@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <HadTu_paddedSize@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rsi
add    -0x18(%rbp),%rsi
call   1040 <HadTu_setSize@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SubEvt_appendData>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
call   1060 <HadTu_paddedSize@plt>
lea    (%rax,%r12,1),%rsi
mov    %r15,%rdi
call   1070 <realloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <HadTu_end@plt>
mov    %eax,%edi
mov    %r14,%rsi
mov    %r12,%rdx
call   1050 <memcpy@plt>
mov    %rbx,%rdi
call   1060 <HadTu_paddedSize@plt>
add    %rax,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <HadTu_setSize@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @SubEvt_appendData(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load i8*, i8** %4
%8 = load i8*, i8** %4
%9 = call i64 @HadTu_paddedSize(i8* %8)
%10 = load i64, i64* %6
%11 = add i64 %9, %10
%12 = call i8* @realloc(i8* %7, i64 %11)
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = call i32 @HadTu_end(i8* %13)
%15 = load i8*, i8** %5
%16 = load i64, i64* %6
%17 = call i32 @memcpy(i32 %14, i8* %15, i64 %16)
%18 = load i8*, i8** %4
%19 = load i8*, i8** %4
%20 = call i64 @HadTu_paddedSize(i8* %19)
%21 = load i64, i64* %6
%22 = add i64 %20, %21
%23 = call i32 @HadTu_setSize(i8* %18, i64 %22)
%24 = load i8*, i8** %4
ret i8* %24
}

LLVM IR (-O2):
define i8* @SubEvt_appendData(i8* %0, i8* %1, i64 %2) {
%4 = tail call i64 @HadTu_paddedSize(i8* %0)
%5 = add i64 %4, %2
%6 = tail call i8* @realloc(i8* %0, i64 %5)
%7 = tail call i32 @HadTu_end(i8* %6)
%8 = tail call i32 @memcpy(i32 %7, i8* %1, i64 %2)
%9 = tail call i64 @HadTu_paddedSize(i8* %6)
%10 = add i64 %9, %2
%11 = tail call i32 @HadTu_setSize(i8* %6, i64 %10)
ret i8* %6
}