#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 unsigned int uint8_t;
typedef int int64_t;

/* Variables and functions */
int get16be(unsigned int const *);
bool decode_time_stamp(int64_t *ts, const uint8_t *s, unsigned int marker) {
  if (0 != ((marker ^ s[0]) & 0xF1))
    return 0;
  if (NULL != ts) {
    unsigned int a, b, c;
    a = (s[0] >> 1) & 0x7;
    b = get16be(s + 1) >> 1;
    c = get16be(s + 3) >> 1;
    *ts = ((int64_t)a << 30) + (b << 15) + (c << 0);
  }
  return 1;
}


x86 assembly (clang, -O0):
<decode_time_stamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
xor    (%rax),%ecx
and    $0xf1,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     1148 <decode_time_stamp+0x38>
movl   $0x0,-0x4(%rbp)
jmp    11ac <decode_time_stamp+0x9c>
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     11a5 <decode_time_stamp+0x95>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
shr    $0x1,%eax
and    $0x7,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
call   1030 <get16be@plt>
sar    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
add    $0xc,%rdi
call   1030 <get16be@plt>
sar    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%ecx
shl    $0x1e,%ecx
mov    -0x24(%rbp),%eax
shl    $0xf,%eax
add    %eax,%ecx
mov    -0x28(%rbp),%eax
shl    $0x0,%eax
add    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_time_stamp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rsi),%ebp
xor    %ebp,%edx
xor    %r15d,%r15d
test   $0xf1,%dl
jne    1166 <decode_time_stamp+0x56>
mov    %rdi,%r14
mov    $0x1,%r15d
test   %rdi,%rdi
je     1166 <decode_time_stamp+0x56>
mov    %rsi,%rbx
lea    0x4(%rsi),%rdi
call   1030 <get16be@plt>
mov    %eax,%r12d
add    $0xc,%rbx
mov    %rbx,%rdi
call   1030 <get16be@plt>
sar    %eax
and    $0xfffffffe,%ebp
shl    $0x1d,%ebp
and    $0xfffffffe,%r12d
shl    $0xe,%r12d
add    %ebp,%r12d
add    %eax,%r12d
mov    %r12d,(%r14)
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @decode_time_stamp(i32* writeonly %0, i32* %1, i32 %2) {
%4 = load i32, i32* %1
%5 = xor i32 %4, %2
%6 = and i32 %5, 241
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %3
%9 = icmp eq i32* %0, null
br i1 %9, label %22, label %10
10: ; preds = %8
%11 = getelementptr inbounds i32, i32* %1, i64 1
%12 = tail call i32 @get16be(i32* %11)
%13 = getelementptr inbounds i32, i32* %1, i64 3
%14 = tail call i32 @get16be(i32* %13)
%15 = ashr i32 %14, 1
%16 = shl i32 %4, 29
%17 = and i32 %16, -1073741824
%18 = shl i32 %12, 14
%19 = and i32 %18, -32768
%20 = add i32 %19, %17
%21 = add i32 %20, %15
store i32 %21, i32* %0
br label %22
22: ; preds = %8, %10, %3
%23 = phi i32 [ 0, %3 ], [ 1, %10 ], [ 1, %8 ]
ret i32 %23
}