#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 */
char *malloc(size_t);
char *marshall(int argc, int fnid, int arg1, int arg2, size_t *lenptr) {
  char *buf;
  size_t len;
  len = sizeof(char) * (argc + 1);
  buf = malloc(len);
  buf[0] = len;
  buf[1] = fnid;
  buf[2] = arg1;
  buf[3] = arg2;
  *lenptr = len;
  return buf;
}


x86 assembly (clang, -O0):
<marshall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0xc(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x10(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<marshall>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%r14
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%ebp
add    $0x1,%edi
movslq %edi,%rbx
mov    %rbx,%rdi
call   1030 <malloc@plt>
mov    %bl,(%rax)
mov    %bpl,0x1(%rax)
mov    %r12b,0x2(%rax)
mov    %r15b,0x3(%rax)
mov    %rbx,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @marshall(i32 %0, i32 %1, i32 %2, i32 %3, i64* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64*
%11 = alloca i8*
%12 = alloca i64
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i64* %4, i64** %10
%13 = load i32, i32* %6
%14 = add nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = mul i64 1, %15
store i64 %16, i64* %12
%17 = load i64, i64* %12
%18 = call i8* @malloc(i64 %17)
store i8* %18, i8** %11
%19 = load i64, i64* %12
%20 = trunc i64 %19 to i8
%21 = load i8*, i8** %11
%22 = getelementptr inbounds i8, i8* %21, i64 0
store i8 %20, i8* %22
%23 = load i32, i32* %7
%24 = trunc i32 %23 to i8
%25 = load i8*, i8** %11
%26 = getelementptr inbounds i8, i8* %25, i64 1
store i8 %24, i8* %26
%27 = load i32, i32* %8
%28 = trunc i32 %27 to i8
%29 = load i8*, i8** %11
%30 = getelementptr inbounds i8, i8* %29, i64 2
store i8 %28, i8* %30
%31 = load i32, i32* %9
%32 = trunc i32 %31 to i8
%33 = load i8*, i8** %11
%34 = getelementptr inbounds i8, i8* %33, i64 3
store i8 %32, i8* %34
%35 = load i64, i64* %12
%36 = load i64*, i64** %10
store i64 %35, i64* %36
%37 = load i8*, i8** %11
ret i8* %37
}

LLVM IR (-O2):
define noalias i8* @marshall(i32 %0, i32 %1, i32 %2, i32 %3, i64* nocapture writeonly %4) {
%6 = add nsw i32 %0, 1
%7 = sext i32 %6 to i64
%8 = tail call i8* @malloc(i64 %7)
%9 = trunc i32 %6 to i8
store i8 %9, i8* %8
%10 = trunc i32 %1 to i8
%11 = getelementptr inbounds i8, i8* %8, i64 1
store i8 %10, i8* %11
%12 = trunc i32 %2 to i8
%13 = getelementptr inbounds i8, i8* %8, i64 2
store i8 %12, i8* %13
%14 = trunc i32 %3 to i8
%15 = getelementptr inbounds i8, i8* %8, i64 3
store i8 %14, i8* %15
store i64 %7, i64* %4
ret i8* %8
}