#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 */
int h264_is_nal_starting_tag(const uint8_t *buf) {
  if (buf[0] != 0 || buf[1] != 0) {
    return 0;
  }
  if (buf[2] == 0x01) {
    return 1;
  }
  if (buf[2] == 0 && buf[3] == 0x01) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<h264_is_nal_starting_tag>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1123 <h264_is_nal_starting_tag+0x23>
mov    -0x10(%rbp),%rax
cmpl   $0x0,0x4(%rax)
je     112f <h264_is_nal_starting_tag+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    1178 <h264_is_nal_starting_tag+0x78>
mov    -0x10(%rbp),%rax
cmpl   $0x1,0x8(%rax)
jne    1149 <h264_is_nal_starting_tag+0x49>
movl   $0x1,-0x4(%rbp)
jmp    1178 <h264_is_nal_starting_tag+0x78>
mov    -0x10(%rbp),%rax
cmpl   $0x0,0x8(%rax)
jne    1171 <h264_is_nal_starting_tag+0x71>
mov    -0x10(%rbp),%rax
cmpl   $0x1,0xc(%rax)
jne    1171 <h264_is_nal_starting_tag+0x71>
movl   $0x1,-0x4(%rbp)
jmp    1178 <h264_is_nal_starting_tag+0x78>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<h264_is_nal_starting_tag>:
xor    %eax,%eax
cmpl   $0x0,(%rdi)
je     1108 <h264_is_nal_starting_tag+0x8>
ret
cmpl   $0x0,0x4(%rdi)
jne    1107 <h264_is_nal_starting_tag+0x7>
mov    0x8(%rdi),%eax
cmp    $0x1,%eax
je     1107 <h264_is_nal_starting_tag+0x7>
test   %eax,%eax
jne    1125 <h264_is_nal_starting_tag+0x25>
mov    $0x1,%eax
cmpl   $0x1,0xc(%rdi)
je     1107 <h264_is_nal_starting_tag+0x7>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @h264_is_nal_starting_tag(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
store i32* %0, i32** %3
%4 = load i32*, i32** %3
%5 = getelementptr inbounds i32, i32* %4, i64 0
%6 = load i32, i32* %5
%7 = icmp ne i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %1
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i64 1
%11 = load i32, i32* %10
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %8, %1
store i32 0, i32* %2
br label %32
14: ; preds = %8
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i64 2
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 1, i32* %2
br label %32
20: ; preds = %14
%21 = load i32*, i32** %3
%22 = getelementptr inbounds i32, i32* %21, i64 2
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %20
%26 = load i32*, i32** %3
%27 = getelementptr inbounds i32, i32* %26, i64 3
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 1, i32* %2
br label %32
31: ; preds = %25, %20
store i32 0, i32* %2
br label %32
32: ; preds = %31, %30, %19, %13
%33 = load i32, i32* %2
ret i32 %33
}

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