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

/* Variables and functions */
uint8_t *rtp_payload(uint8_t *p_rtp) {
  unsigned int i_size = 12;
  i_size += 4 * (p_rtp[0] & 0xf);
  if (p_rtp[0] & 0x10)
    i_size += 4 * (1 + (p_rtp[i_size + 2] << 8) + p_rtp[i_size + 3]);
  return p_rtp + i_size;
}


x86 assembly (clang, -O0):
<rtp_payload>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0xc,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    $0xf,%eax
shl    $0x2,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     1160 <rtp_payload+0x60>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,4),%eax
shl    $0x8,%eax
add    $0x1,%eax
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%edx
add    $0x3,%edx
mov    %edx,%edx
add    (%rcx,%rdx,4),%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
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtp_payload>:
mov    (%rdi),%edx
lea    0x0(,%rdx,4),%ecx
and    $0x3c,%ecx
lea    0xc(%rcx),%eax
test   $0x10,%dl
je     1127 <rtp_payload+0x27>
mov    0x38(%rdi,%rcx,4),%edx
shl    $0x8,%edx
mov    %ecx,%ecx
add    0x3c(%rdi,%rcx,4),%edx
lea    (%rax,%rdx,4),%eax
add    $0x4,%eax
mov    %eax,%eax
lea    (%rdi,%rax,4),%rax
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 = getelementptr inbounds i32, i32* %4, i64 0
%6 = load i32, i32* %5
%7 = and i32 %6, 15
%8 = mul nsw i32 4, %7
%9 = load i32, i32* %3
%10 = add i32 %9, %8
store i32 %10, i32* %3
%11 = load i32*, i32** %2
%12 = getelementptr inbounds i32, i32* %11, i64 0
%13 = load i32, i32* %12
%14 = and i32 %13, 16
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %35
16: ; preds = %1
%17 = load i32*, i32** %2
%18 = load i32, i32* %3
%19 = add i32 %18, 2
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %17, i64 %20
%22 = load i32, i32* %21
%23 = shl i32 %22, 8
%24 = add nsw i32 1, %23
%25 = load i32*, i32** %2
%26 = load i32, i32* %3
%27 = add i32 %26, 3
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %25, i64 %28
%30 = load i32, i32* %29
%31 = add nsw i32 %24, %30
%32 = mul nsw i32 4, %31
%33 = load i32, i32* %3
%34 = add i32 %33, %32
store i32 %34, i32* %3
br label %35
35: ; preds = %16, %1
%36 = load i32*, i32** %2
%37 = load i32, i32* %3
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
ret i32* %39
}

LLVM IR (-O2):
define i32* @rtp_payload(i32* %0) {
%2 = load i32, i32* %0
%3 = shl i32 %2, 2
%4 = and i32 %3, 60
%5 = add nuw nsw i32 %4, 12
%6 = and i32 %2, 16
%7 = icmp eq i32 %6, 0
br i1 %7, label %22, label %8
8: ; preds = %1
%9 = add nuw nsw i32 %4, 14
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = shl i32 %12, 8
%14 = or i32 %13, 1
%15 = add nuw nsw i32 %4, 15
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %0, i64 %16
%18 = load i32, i32* %17
%19 = add nsw i32 %14, %18
%20 = shl nsw i32 %19, 2
%21 = add i32 %20, %5
br label %22
22: ; preds = %8, %1
%23 = phi i32 [ %21, %8 ], [ %5, %1 ]
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %0, i64 %24
ret i32* %25
}