#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 /*<<< orphan*/ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ ts_encode_pts_dts(int *, int, int /*<<< orphan*/);
int ts_packet_get_payload_offset(int *);
void ts_packet_change_pts_dts(uint8_t *ts_packet, uint64_t pts, uint64_t dts) {
  uint8_t payload_offset = ts_packet_get_payload_offset(ts_packet);
  if (!payload_offset)
    return;
  uint8_t *data = ts_packet + payload_offset;
  ts_encode_pts_dts(&data[9], 3, pts);
  ts_encode_pts_dts(&data[14], 1, dts);
}


x86 assembly (clang, -O0):
<ts_packet_change_pts_dts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <ts_packet_get_payload_offset@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    114d <ts_packet_change_pts_dts+0x2d>
jmp    118a <ts_packet_change_pts_dts+0x6a>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x24,%rdi
mov    -0xc(%rbp),%edx
mov    $0x3,%esi
call   1040 <ts_encode_pts_dts@plt>
mov    -0x20(%rbp),%rdi
add    $0x38,%rdi
mov    -0x10(%rbp),%edx
mov    $0x1,%esi
call   1040 <ts_encode_pts_dts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ts_packet_change_pts_dts>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbx
call   1030 <ts_packet_get_payload_offset@plt>
test   %eax,%eax
je     1170 <ts_packet_change_pts_dts+0x50>
movslq %eax,%rbp
lea    (%rbx,%rbp,4),%rdi
add    $0x24,%rdi
mov    $0x3,%esi
mov    %r15d,%edx
call   1040 <ts_encode_pts_dts@plt>
lea    (%rbx,%rbp,4),%rdi
add    $0x38,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <ts_encode_pts_dts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ts_packet_change_pts_dts(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32*, i32** %4
%10 = call i32 @ts_packet_get_payload_offset(i32* %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %3
br label %27
14: ; preds = %3
%15 = load i32*, i32** %4
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
store i32* %18, i32** %8
%19 = load i32*, i32** %8
%20 = getelementptr inbounds i32, i32* %19, i64 9
%21 = load i32, i32* %5
%22 = call i32 @ts_encode_pts_dts(i32* %20, i32 3, i32 %21)
%23 = load i32*, i32** %8
%24 = getelementptr inbounds i32, i32* %23, i64 14
%25 = load i32, i32* %6
%26 = call i32 @ts_encode_pts_dts(i32* %24, i32 1, i32 %25)
br label %27
27: ; preds = %14, %13
ret void
}

LLVM IR (-O2):
define void @ts_packet_change_pts_dts(i32* %0, i32 %1, i32 %2) {
%4 = tail call i32 @ts_packet_get_payload_offset(i32* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = sext i32 %4 to i64
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = getelementptr inbounds i32, i32* %8, i64 9
%10 = tail call i32 @ts_encode_pts_dts(i32* %9, i32 3, i32 %1)
%11 = getelementptr inbounds i32, i32* %8, i64 14
%12 = tail call i32 @ts_encode_pts_dts(i32* %11, i32 1, i32 %2)
br label %13
13: ; preds = %3, %6
ret void
}