#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 uint8_t;
typedef int uint32_t;
typedef int uint16_t;

/* Variables and functions */
int write_v2gtpHeader(uint8_t *outStream, uint32_t outStreamLength,
                      uint16_t payloadType) {
  outStream[0] = 0x01;
  outStream[1] = 0xFE;
  outStream[3] = (uint8_t)(payloadType & 0xFF);
  outStream[2] = (uint8_t)(payloadType >> 8 & 0xFF);
  outStream[7] = (uint8_t)(outStreamLength & 0xFF);
  outStream[6] = (uint8_t)(outStreamLength >> 8 & 0xFF);
  outStream[5] = (uint8_t)(outStreamLength >> 16 & 0xFF);
  outStream[4] = (uint8_t)(outStreamLength >> 24 & 0xFF);
  return 0;
}


x86 assembly (clang, -O0):
<write_v2gtpHeader>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%rax
movl   $0xfe,0x4(%rax)
mov    -0x10(%rbp),%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x10(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0xc(%rbp),%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x1c(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x18,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_v2gtpHeader>:
mov    %esi,%eax
movabs $0xfe00000001,%rcx
mov    %rcx,(%rdi)
movzbl %dl,%ecx
mov    %ecx,0xc(%rdi)
movzbl %dh,%ecx
mov    %ecx,0x8(%rdi)
movzbl %al,%ecx
mov    %ecx,0x1c(%rdi)
movzbl %ah,%ecx
mov    %ecx,0x18(%rdi)
mov    %esi,%ecx
shr    $0x10,%ecx
movzbl %cl,%ecx
mov    %ecx,0x14(%rdi)
shr    $0x18,%eax
mov    %eax,0x10(%rdi)
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @write_v2gtpHeader(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32*, i32** %4
%8 = getelementptr inbounds i32, i32* %7, i64 0
store i32 1, i32* %8
%9 = load i32*, i32** %4
%10 = getelementptr inbounds i32, i32* %9, i64 1
store i32 254, i32* %10
%11 = load i32, i32* %6
%12 = and i32 %11, 255
%13 = load i32*, i32** %4
%14 = getelementptr inbounds i32, i32* %13, i64 3
store i32 %12, i32* %14
%15 = load i32, i32* %6
%16 = ashr i32 %15, 8
%17 = and i32 %16, 255
%18 = load i32*, i32** %4
%19 = getelementptr inbounds i32, i32* %18, i64 2
store i32 %17, i32* %19
%20 = load i32, i32* %5
%21 = and i32 %20, 255
%22 = load i32*, i32** %4
%23 = getelementptr inbounds i32, i32* %22, i64 7
store i32 %21, i32* %23
%24 = load i32, i32* %5
%25 = ashr i32 %24, 8
%26 = and i32 %25, 255
%27 = load i32*, i32** %4
%28 = getelementptr inbounds i32, i32* %27, i64 6
store i32 %26, i32* %28
%29 = load i32, i32* %5
%30 = ashr i32 %29, 16
%31 = and i32 %30, 255
%32 = load i32*, i32** %4
%33 = getelementptr inbounds i32, i32* %32, i64 5
store i32 %31, i32* %33
%34 = load i32, i32* %5
%35 = ashr i32 %34, 24
%36 = and i32 %35, 255
%37 = load i32*, i32** %4
%38 = getelementptr inbounds i32, i32* %37, i64 4
store i32 %36, i32* %38
ret i32 0
}

LLVM IR (-O2):
define i32 @write_v2gtpHeader(i32* nocapture writeonly %0, i32 %1, i32 %2) {
store i32 1, i32* %0
%4 = getelementptr inbounds i32, i32* %0, i64 1
store i32 254, i32* %4
%5 = and i32 %2, 255
%6 = getelementptr inbounds i32, i32* %0, i64 3
store i32 %5, i32* %6
%7 = lshr i32 %2, 8
%8 = and i32 %7, 255
%9 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %8, i32* %9
%10 = and i32 %1, 255
%11 = getelementptr inbounds i32, i32* %0, i64 7
store i32 %10, i32* %11
%12 = lshr i32 %1, 8
%13 = and i32 %12, 255
%14 = getelementptr inbounds i32, i32* %0, i64 6
store i32 %13, i32* %14
%15 = lshr i32 %1, 16
%16 = and i32 %15, 255
%17 = getelementptr inbounds i32, i32* %0, i64 5
store i32 %16, i32* %17
%18 = lshr i32 %1, 24
%19 = getelementptr inbounds i32, i32* %0, i64 4
store i32 %18, i32* %19
ret i32 0
}