#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*/ uint_fast8_t;
typedef int /*<<< orphan*/ uint_fast32_t;
typedef int /*<<< orphan*/ uint_fast16_t;
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ _a16be(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ _a32be(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ *wbuf_get(int /*<<< orphan*/);
uint8_t *inserthdr(uint_fast32_t pts, uint_fast32_t dts, uint_fast8_t segtype,
                   uint_fast16_t seglen) {
  uint8_t *buf = wbuf_get(13 + seglen);
  _a32be(buf + 2, pts);
  _a32be(buf + 6, dts);
  buf[10] = segtype;
  _a16be(buf + 11, seglen);
  return buf;
}


x86 assembly (clang, -O0):
<inserthdr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x10(%rbp),%edi
add    $0xd,%edi
call   1040 <wbuf_get@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x8,%rdi
mov    -0x4(%rbp),%esi
call   1030 <_a32be@plt>
mov    -0x18(%rbp),%rdi
add    $0x18,%rdi
mov    -0x8(%rbp),%esi
call   1030 <_a32be@plt>
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x28(%rax)
mov    -0x18(%rbp),%rdi
add    $0x2c,%rdi
mov    -0x10(%rbp),%esi
call   1050 <_a16be@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inserthdr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%r12d
lea    0xd(%rbx),%edi
call   1040 <wbuf_get@plt>
mov    %rax,%rbp
lea    0x8(%rax),%rdi
mov    %r12d,%esi
call   1030 <_a32be@plt>
lea    0x18(%rbp),%rdi
mov    %r15d,%esi
call   1030 <_a32be@plt>
mov    %r14d,0x28(%rbp)
lea    0x2c(%rbp),%rdi
mov    %ebx,%esi
call   1050 <_a16be@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @inserthdr(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %8
%11 = add nsw i32 13, %10
%12 = call i32* @wbuf_get(i32 %11)
store i32* %12, i32** %9
%13 = load i32*, i32** %9
%14 = getelementptr inbounds i32, i32* %13, i64 2
%15 = load i32, i32* %5
%16 = call i32 @_a32be(i32* %14, i32 %15)
%17 = load i32*, i32** %9
%18 = getelementptr inbounds i32, i32* %17, i64 6
%19 = load i32, i32* %6
%20 = call i32 @_a32be(i32* %18, i32 %19)
%21 = load i32, i32* %7
%22 = load i32*, i32** %9
%23 = getelementptr inbounds i32, i32* %22, i64 10
store i32 %21, i32* %23
%24 = load i32*, i32** %9
%25 = getelementptr inbounds i32, i32* %24, i64 11
%26 = load i32, i32* %8
%27 = call i32 @_a16be(i32* %25, i32 %26)
%28 = load i32*, i32** %9
ret i32* %28
}

LLVM IR (-O2):
define i32* @inserthdr(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = add nsw i32 %3, 13
%6 = tail call i32* @wbuf_get(i32 %5)
%7 = getelementptr inbounds i32, i32* %6, i64 2
%8 = tail call i32 @_a32be(i32* %7, i32 %0)
%9 = getelementptr inbounds i32, i32* %6, i64 6
%10 = tail call i32 @_a32be(i32* %9, i32 %1)
%11 = getelementptr inbounds i32, i32* %6, i64 10
store i32 %2, i32* %11
%12 = getelementptr inbounds i32, i32* %6, i64 11
%13 = tail call i32 @_a16be(i32* %12, i32 %3)
ret i32* %6
}