#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*/ memcpy(char *, ...);
char *addHeader(char *dest, int *seq, char *buff, int sizeH, int sizeB) {
  *dest = 'P';
  *(dest + 1) = 'K';
  *(dest + 2) = 'T';
  memcpy(dest + 3, seq, sizeof(int));
  memcpy((dest + sizeH), buff, sizeB);
  return dest;
}


x86 assembly (clang, -O0):
<addHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x50,(%rax)
mov    -0x8(%rbp),%rax
movb   $0x4b,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x54,0x2(%rax)
mov    -0x8(%rbp),%rdi
add    $0x3,%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
xor    %eax,%eax
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addHeader>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%ebp
mov    %rdx,%r15
mov    %rdi,%rbx
movw   $0x4b50,(%rdi)
movb   $0x54,0x2(%rdi)
add    $0x3,%rdi
mov    $0x4,%edx
xor    %eax,%eax
call   1030 <memcpy@plt>
movslq %ebp,%rdi
add    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <memcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @addHeader(i8* %0, i32* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i32* %1, i32** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i8*, i8** %6
store i8 80, i8* %11
%12 = load i8*, i8** %6
%13 = getelementptr inbounds i8, i8* %12, i64 1
store i8 75, i8* %13
%14 = load i8*, i8** %6
%15 = getelementptr inbounds i8, i8* %14, i64 2
store i8 84, i8* %15
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i64 3
%18 = load i32*, i32** %7
%19 = call i32 (i8*, ...) @memcpy(i8* %17, i32* %18, i64 4)
%20 = load i8*, i8** %6
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8*, i8** %8
%25 = load i32, i32* %10
%26 = call i32 (i8*, ...) @memcpy(i8* %23, i8* %24, i32 %25)
%27 = load i8*, i8** %6
ret i8* %27
}

LLVM IR (-O2):
define i8* @addHeader(i8* returned %0, i32* %1, i8* %2, i32 %3, i32 %4) {
store i8 80, i8* %0
%6 = getelementptr inbounds i8, i8* %0, i64 1
store i8 75, i8* %6
%7 = getelementptr inbounds i8, i8* %0, i64 2
store i8 84, i8* %7
%8 = getelementptr inbounds i8, i8* %0, i64 3
%9 = tail call i32 (i8*, ...) @memcpy(i8* %8, i32* %1, i64 4)
%10 = sext i32 %3 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = tail call i32 (i8*, ...) @memcpy(i8* %11, i8* %2, i32 %4)
ret i8* %0
}