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

/* Variables and functions */
scalar_t__ rtp_check_extension(int /*<<< orphan*/ *);
int /*<<< orphan*/ rtp_extension(int /*<<< orphan*/ *);
int rtp_get_cc(int /*<<< orphan*/ *);
int rtpx_get_length(int /*<<< orphan*/);
uint8_t *rtp_payload(uint8_t *p_rtp) {
  unsigned int i_size = 12;
  i_size += 4 * rtp_get_cc(p_rtp);
  if (rtp_check_extension(p_rtp))
    i_size += 4 * (1 + rtpx_get_length(rtp_extension(p_rtp)));
  return p_rtp + i_size;
}


x86 assembly (clang, -O0):
<rtp_payload>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xc,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <rtp_get_cc@plt>
shl    $0x2,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <rtp_check_extension@plt>
cmp    $0x0,%rax
je     1194 <rtp_payload+0x54>
mov    -0x8(%rbp),%rdi
call   1040 <rtp_extension@plt>
mov    %eax,%edi
call   1060 <rtpx_get_length@plt>
add    $0x1,%eax
shl    $0x2,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x2,%rcx
add    %rcx,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtp_payload>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <rtp_get_cc@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1050 <rtp_check_extension@plt>
test   %rax,%rax
je     1178 <rtp_payload+0x38>
shl    $0x2,%r14d
mov    %rbx,%rdi
call   1040 <rtp_extension@plt>
mov    %eax,%edi
call   1060 <rtpx_get_length@plt>
lea    (%r14,%rax,4),%eax
add    $0x10,%eax
jmp    1180 <rtp_payload+0x40>
lea    0xc(,%r14,4),%eax
mov    %eax,%eax
lea    (%rbx,%rax,4),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32* @rtp_payload(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
store i32 12, i32* %3
%4 = load i32*, i32** %2
%5 = call i32 @rtp_get_cc(i32* %4)
%6 = mul nsw i32 4, %5
%7 = load i32, i32* %3
%8 = add i32 %7, %6
store i32 %8, i32* %3
%9 = load i32*, i32** %2
%10 = call i64 @rtp_check_extension(i32* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %1
%13 = load i32*, i32** %2
%14 = call i32 @rtp_extension(i32* %13)
%15 = call i32 @rtpx_get_length(i32 %14)
%16 = add nsw i32 1, %15
%17 = mul nsw i32 4, %16
%18 = load i32, i32* %3
%19 = add i32 %18, %17
store i32 %19, i32* %3
br label %20
20: ; preds = %12, %1
%21 = load i32*, i32** %2
%22 = load i32, i32* %3
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
ret i32* %24
}

LLVM IR (-O2):
define i32* @rtp_payload(i32* %0) {
%2 = tail call i32 @rtp_get_cc(i32* %0)
%3 = shl nsw i32 %2, 2
%4 = add i32 %3, 12
%5 = tail call i64 @rtp_check_extension(i32* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %1
%8 = tail call i32 @rtp_extension(i32* %0)
%9 = tail call i32 @rtpx_get_length(i32 %8)
%10 = shl i32 %9, 2
%11 = add i32 %3, 16
%12 = add i32 %11, %10
br label %13
13: ; preds = %7, %1
%14 = phi i32 [ %12, %7 ], [ %4, %1 ]
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %0, i64 %15
ret i32* %16
}