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

/* Variables and functions */
void ts_packet_set_pcr_ex(uint8_t *ts_packet, uint64_t pcr_base,
                          uint16_t pcr_ext) {
  ts_packet[6 + 0] = (pcr_base >> 25) & 0xFF;
  ts_packet[6 + 1] = (pcr_base >> 17) & 0xFF;
  ts_packet[6 + 2] = (pcr_base >> 9) & 0xFF;
  ts_packet[6 + 3] = (pcr_base >> 1) & 0xFF;
  ts_packet[6 + 4] = 0x7e | ((pcr_ext >> 8) & 0x01) | ((pcr_base & 0x01) << 7);
  ts_packet[6 + 5] = pcr_ext & 0xFF;
}


x86 assembly (clang, -O0):
<ts_packet_set_pcr_ex>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%ecx
sar    $0x19,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x11,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x1c(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x9,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x1,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x24(%rax)
mov    -0x10(%rbp),%ecx
sar    $0x8,%ecx
and    $0x1,%ecx
or     $0x7e,%ecx
mov    -0xc(%rbp),%eax
and    $0x1,%eax
shl    $0x7,%eax
or     %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x28(%rax)
mov    -0x10(%rbp),%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x2c(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<ts_packet_set_pcr_ex>:
mov    %esi,%eax
sar    $0x19,%eax
movzbl %al,%eax
mov    %eax,0x18(%rdi)
mov    %esi,%eax
shr    $0x11,%eax
movzbl %al,%eax
mov    %eax,0x1c(%rdi)
mov    %esi,%eax
shr    $0x9,%eax
movzbl %al,%eax
mov    %eax,0x20(%rdi)
mov    %esi,%eax
shr    %eax
movzbl %al,%eax
mov    %eax,0x24(%rdi)
movzbl %dl,%eax
mov    %edx,%ecx
shr    $0x8,%ecx
and    $0x1,%ecx
shl    $0x7,%esi
movzbl %sil,%edx
add    %edx,%ecx
add    $0x7e,%ecx
mov    %ecx,0x28(%rdi)
mov    %eax,0x2c(%rdi)
ret

LLVM IR (-O0):
define void @ts_packet_set_pcr_ex(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* %5
%8 = ashr i32 %7, 25
%9 = and i32 %8, 255
%10 = load i32*, i32** %4
%11 = getelementptr inbounds i32, i32* %10, i64 6
store i32 %9, i32* %11
%12 = load i32, i32* %5
%13 = ashr i32 %12, 17
%14 = and i32 %13, 255
%15 = load i32*, i32** %4
%16 = getelementptr inbounds i32, i32* %15, i64 7
store i32 %14, i32* %16
%17 = load i32, i32* %5
%18 = ashr i32 %17, 9
%19 = and i32 %18, 255
%20 = load i32*, i32** %4
%21 = getelementptr inbounds i32, i32* %20, i64 8
store i32 %19, i32* %21
%22 = load i32, i32* %5
%23 = ashr i32 %22, 1
%24 = and i32 %23, 255
%25 = load i32*, i32** %4
%26 = getelementptr inbounds i32, i32* %25, i64 9
store i32 %24, i32* %26
%27 = load i32, i32* %6
%28 = ashr i32 %27, 8
%29 = and i32 %28, 1
%30 = or i32 126, %29
%31 = load i32, i32* %5
%32 = and i32 %31, 1
%33 = shl i32 %32, 7
%34 = or i32 %30, %33
%35 = load i32*, i32** %4
%36 = getelementptr inbounds i32, i32* %35, i64 10
store i32 %34, i32* %36
%37 = load i32, i32* %6
%38 = and i32 %37, 255
%39 = load i32*, i32** %4
%40 = getelementptr inbounds i32, i32* %39, i64 11
store i32 %38, i32* %40
ret void
}

LLVM IR (-O2):
define void @ts_packet_set_pcr_ex(i32* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = ashr i32 %1, 25
%5 = and i32 %4, 255
%6 = getelementptr inbounds i32, i32* %0, i64 6
store i32 %5, i32* %6
%7 = lshr i32 %1, 17
%8 = and i32 %7, 255
%9 = getelementptr inbounds i32, i32* %0, i64 7
store i32 %8, i32* %9
%10 = lshr i32 %1, 9
%11 = and i32 %10, 255
%12 = getelementptr inbounds i32, i32* %0, i64 8
store i32 %11, i32* %12
%13 = lshr i32 %1, 1
%14 = and i32 %13, 255
%15 = getelementptr inbounds i32, i32* %0, i64 9
store i32 %14, i32* %15
%16 = lshr i32 %2, 8
%17 = and i32 %16, 1
%18 = shl i32 %1, 7
%19 = and i32 %18, 128
%20 = or i32 %19, %17
%21 = or i32 %20, 126
%22 = getelementptr inbounds i32, i32* %0, i64 10
store i32 %21, i32* %22
%23 = and i32 %2, 255
%24 = getelementptr inbounds i32, i32* %0, i64 11
store i32 %23, i32* %24
ret void
}