#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;
typedef int uint32_t;

/* Variables and functions */
int mpeg2_is_sequence_header(const uint8_t *buf, int len) {
  int i;
  for (i = 0; i < len - 6; i++) {
    if ((*(const uint32_t *)(buf + i) == 0xb3010000U)) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<mpeg2_is_sequence_header>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x6,%ecx
cmp    %ecx,%eax
jge    1157 <mpeg2_is_sequence_header+0x57>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpl   $0xb3010000,(%rax,%rcx,4)
jne    1144 <mpeg2_is_sequence_header+0x44>
movl   $0x1,-0x4(%rbp)
jmp    115e <mpeg2_is_sequence_header+0x5e>
jmp    1149 <mpeg2_is_sequence_header+0x49>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1112 <mpeg2_is_sequence_header+0x12>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpeg2_is_sequence_header>:
xor    %eax,%eax
cmp    $0x7,%esi
jl     112a <mpeg2_is_sequence_header+0x2a>
add    $0xfffffffa,%esi
xor    %eax,%eax
nopl   0x0(%rax)
cmpl   $0xb3010000,(%rdi,%rax,4)
je     1125 <mpeg2_is_sequence_header+0x25>
add    $0x1,%rax
cmp    %rax,%rsi
jne    1110 <mpeg2_is_sequence_header+0x10>
xor    %eax,%eax
ret
mov    $0x1,%eax
ret

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

LLVM IR (-O2):
define i32 @mpeg2_is_sequence_header(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 6
br i1 %3, label %4, label %15
4: ; preds = %2
%5 = add nsw i32 %1, -6
%6 = zext i32 %5 to i64
br label %9
7: ; preds = %9
%8 = icmp eq i64 %14, %6
br i1 %8, label %15, label %9
9: ; preds = %4, %7
%10 = phi i64 [ 0, %4 ], [ %14, %7 ]
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, -1291780096
%14 = add nuw nsw i64 %10, 1
br i1 %13, label %15, label %7
15: ; preds = %9, %7, %2
%16 = phi i32 [ 0, %2 ], [ 0, %7 ], [ 1, %9 ]
ret i32 %16
}