#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;

/* Variables and functions */
void pes_set_pts(uint8_t *p_pes, uint64_t i_pts) {
  p_pes[7] |= 0x80;
  if (p_pes[8] < 5)
    p_pes[8] = 5;
  p_pes[9] = 0x21 | ((i_pts >> 29) & 0xe);
  p_pes[10] = (i_pts >> 22) & 0xff;
  p_pes[11] = 0x1 | ((i_pts >> 14) & 0xfe);
  p_pes[12] = (i_pts >> 7) & 0xff;
  p_pes[13] = 0x1 | ((i_pts << 1) & 0xfe);
}


x86 assembly (clang, -O0):
<pes_set_pts>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0x1c(%rax),%ecx
or     $0x80,%ecx
mov    %ecx,0x1c(%rax)
mov    -0x8(%rbp),%rax
cmpl   $0x5,0x20(%rax)
jge    1134 <pes_set_pts+0x34>
mov    -0x8(%rbp),%rax
movl   $0x5,0x20(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x1d,%ecx
and    $0xe,%ecx
or     $0x21,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x24(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x16,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x28(%rax)
mov    -0xc(%rbp),%ecx
sar    $0xe,%ecx
and    $0xfe,%ecx
or     $0x1,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x2c(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x7,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x30(%rax)
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
and    $0xfe,%ecx
or     $0x1,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x34(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<pes_set_pts>:
orb    $0x80,0x1c(%rdi)
cmpl   $0x4,0x20(%rdi)
jg     1111 <pes_set_pts+0x11>
movl   $0x5,0x20(%rdi)
mov    %esi,%eax
sar    $0x1d,%eax
and    $0xe,%eax
or     $0x21,%eax
mov    %eax,0x24(%rdi)
mov    %esi,%eax
shr    $0x16,%eax
movzbl %al,%eax
mov    %eax,0x28(%rdi)
mov    %esi,%eax
shr    $0xe,%eax
or     $0x1,%eax
movzbl %al,%eax
mov    %eax,0x2c(%rdi)
mov    %esi,%eax
shr    $0x7,%eax
movzbl %al,%eax
mov    %eax,0x30(%rdi)
lea    (%rsi,%rsi,1),%eax
add    $0x1,%eax
movzbl %al,%eax
mov    %eax,0x34(%rdi)
ret

LLVM IR (-O0):
define void @pes_set_pts(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32*, i32** %3
%6 = getelementptr inbounds i32, i32* %5, i64 7
%7 = load i32, i32* %6
%8 = or i32 %7, 128
store i32 %8, i32* %6
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i64 8
%11 = load i32, i32* %10
%12 = icmp slt i32 %11, 5
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32*, i32** %3
%15 = getelementptr inbounds i32, i32* %14, i64 8
store i32 5, i32* %15
br label %16
16: ; preds = %13, %2
%17 = load i32, i32* %4
%18 = ashr i32 %17, 29
%19 = and i32 %18, 14
%20 = or i32 33, %19
%21 = load i32*, i32** %3
%22 = getelementptr inbounds i32, i32* %21, i64 9
store i32 %20, i32* %22
%23 = load i32, i32* %4
%24 = ashr i32 %23, 22
%25 = and i32 %24, 255
%26 = load i32*, i32** %3
%27 = getelementptr inbounds i32, i32* %26, i64 10
store i32 %25, i32* %27
%28 = load i32, i32* %4
%29 = ashr i32 %28, 14
%30 = and i32 %29, 254
%31 = or i32 1, %30
%32 = load i32*, i32** %3
%33 = getelementptr inbounds i32, i32* %32, i64 11
store i32 %31, i32* %33
%34 = load i32, i32* %4
%35 = ashr i32 %34, 7
%36 = and i32 %35, 255
%37 = load i32*, i32** %3
%38 = getelementptr inbounds i32, i32* %37, i64 12
store i32 %36, i32* %38
%39 = load i32, i32* %4
%40 = shl i32 %39, 1
%41 = and i32 %40, 254
%42 = or i32 1, %41
%43 = load i32*, i32** %3
%44 = getelementptr inbounds i32, i32* %43, i64 13
store i32 %42, i32* %44
ret void
}

LLVM IR (-O2):
define void @pes_set_pts(i32* nocapture %0, i32 %1) {
%3 = getelementptr inbounds i32, i32* %0, i64 7
%4 = load i32, i32* %3
%5 = or i32 %4, 128
store i32 %5, i32* %3
%6 = getelementptr inbounds i32, i32* %0, i64 8
%7 = load i32, i32* %6
%8 = icmp slt i32 %7, 5
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 5, i32* %6
br label %10
10: ; preds = %9, %2
%11 = ashr i32 %1, 29
%12 = and i32 %11, 14
%13 = or i32 %12, 33
%14 = getelementptr inbounds i32, i32* %0, i64 9
store i32 %13, i32* %14
%15 = lshr i32 %1, 22
%16 = and i32 %15, 255
%17 = getelementptr inbounds i32, i32* %0, i64 10
store i32 %16, i32* %17
%18 = lshr i32 %1, 14
%19 = and i32 %18, 254
%20 = or i32 %19, 1
%21 = getelementptr inbounds i32, i32* %0, i64 11
store i32 %20, i32* %21
%22 = lshr i32 %1, 7
%23 = and i32 %22, 255
%24 = getelementptr inbounds i32, i32* %0, i64 12
store i32 %23, i32* %24
%25 = shl i32 %1, 1
%26 = and i32 %25, 254
%27 = or i32 %26, 1
%28 = getelementptr inbounds i32, i32* %0, i64 13
store i32 %27, i32* %28
ret void
}