#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 */
typedef int /*<<< orphan*/ uint8_t;
struct lcpa_metapack {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ lcpa_append_copy(struct lcpa_metapack *, char *,
                                    int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/);
void lcpf_add_ie(struct lcpa_metapack *pack, uint8_t num, uint8_t len,
                 uint8_t *data) {
  uint8_t chunk[257];
  chunk[0] = num;
  chunk[1] = len;
  memcpy(&(chunk[2]), data, len);
  lcpa_append_copy(pack, "IETAG", len + 2, chunk);
}


x86 assembly (clang, -O0):
<lcpf_add_ie>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x420(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x41c(%rbp)
lea    -0x420(%rbp),%rdi
add    $0x8,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
add    $0x2,%edx
lea    -0x420(%rbp),%rcx
lea    0xe86(%rip),%rsi
call   1030 <lcpa_append_copy@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcpf_add_ie>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %edx,%ebx
mov    %rdi,%r14
mov    %esi,(%rsp)
mov    %edx,0x4(%rsp)
lea    0x8(%rsp),%rdi
mov    %rcx,%rsi
call   1040 <memcpy@plt>
add    $0x2,%ebx
lea    0xeb3(%rip),%rsi
mov    %rsp,%rcx
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <lcpa_append_copy@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.lcpa_metapack = type { i32 }
@.str = [6 x i8] c"IETAG\00"
define void @lcpf_add_ie(%struct.lcpa_metapack* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca %struct.lcpa_metapack*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca [257 x i32]
store %struct.lcpa_metapack* %0, %struct.lcpa_metapack** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%10 = load i32, i32* %6
%11 = getelementptr inbounds [257 x i32], [257 x i32]* %9, i64 0, i64 0
store i32 %10, i32* %11
%12 = load i32, i32* %7
%13 = getelementptr inbounds [257 x i32], [257 x i32]* %9, i64 0, i64 1
store i32 %12, i32* %13
%14 = getelementptr inbounds [257 x i32], [257 x i32]* %9, i64 0, i64 2
%15 = load i32*, i32** %8
%16 = load i32, i32* %7
%17 = call i32 @memcpy(i32* %14, i32* %15, i32 %16)
%18 = load %struct.lcpa_metapack*, %struct.lcpa_metapack** %5
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 2
%21 = getelementptr inbounds [257 x i32], [257 x i32]* %9, i64 0, i64 0
%22 = call i32 @lcpa_append_copy(%struct.lcpa_metapack* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %20, i32* %21)
ret void
}

LLVM IR (-O2):
%struct.lcpa_metapack = type { i32 }
@.str = [6 x i8] c"IETAG\00"
define void @lcpf_add_ie(%struct.lcpa_metapack* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca [257 x i32]
%6 = bitcast [257 x i32]* %5 to i8*
%7 = getelementptr inbounds [257 x i32], [257 x i32]* %5, i64 0, i64 0
store i32 %1, i32* %7
%8 = getelementptr inbounds [257 x i32], [257 x i32]* %5, i64 0, i64 1
store i32 %2, i32* %8
%9 = getelementptr inbounds [257 x i32], [257 x i32]* %5, i64 0, i64 2
%10 = call i32 @memcpy(i32* %9, i32* %3, i32 %2)
%11 = add nsw i32 %2, 2
%12 = call i32 @lcpa_append_copy(%struct.lcpa_metapack* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %11, i32* %7)
ret void
}