#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int _ts_simple_analyze(const uint8_t *buf, int size) {
  int i;
  int isTs = 0;
  for (i = 0; i < size - 3; i++) {
    if (buf[i] == 0x47 && !(buf[i + 1] & 0x80) && (buf[i + 3] != 0x47)) {
      isTs = 1;
      break;
    }
  }
  fprintf(stderr, "ts_simple_analyze isTs is [%d]\n", isTs);
  return isTs;
}


x86 assembly (clang, -O0):
<_ts_simple_analyze>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    11a4 <_ts_simple_analyze+0x94>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x47,(%rax,%rcx,4)
jne    1191 <_ts_simple_analyze+0x81>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    1191 <_ts_simple_analyze+0x81>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
cmpl   $0x47,(%rax,%rcx,4)
je     1191 <_ts_simple_analyze+0x81>
movl   $0x1,-0x14(%rbp)
jmp    11a4 <_ts_simple_analyze+0x94>
jmp    1196 <_ts_simple_analyze+0x86>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112d <_ts_simple_analyze+0x1d>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe49(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ts_simple_analyze>:
push   %rbx
xor    %ebx,%ebx
cmp    $0x4,%esi
jl     1146 <_ts_simple_analyze+0x36>
add    $0xfffffffd,%esi
xor    %eax,%eax
jmp    1129 <_ts_simple_analyze+0x19>
nop
add    $0x1,%rax
cmp    %rax,%rsi
je     1144 <_ts_simple_analyze+0x34>
cmpl   $0x47,(%rdi,%rax,4)
jne    1120 <_ts_simple_analyze+0x10>
testb  $0x80,0x4(%rdi,%rax,4)
jne    1120 <_ts_simple_analyze+0x10>
cmpl   $0x47,0xc(%rdi,%rax,4)
je     1120 <_ts_simple_analyze+0x10>
mov    $0x1,%ebx
jmp    1146 <_ts_simple_analyze+0x36>
xor    %ebx,%ebx
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
mov    %ebx,%edx
call   1030 <fprintf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"ts_simple_analyze isTs is [%d]\0A\00"
define i32 @_ts_simple_analyze(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %6
store i32 0, i32* %5
br label %7
7: ; preds = %38, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = sub nsw i32 %9, 3
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %41
12: ; preds = %7
%13 = load i32*, i32** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 71
br i1 %18, label %19, label %37
19: ; preds = %12
%20 = load i32*, i32** %3
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %20, i64 %23
%25 = load i32, i32* %24
%26 = and i32 %25, 128
%27 = icmp ne i32 %26, 0
br i1 %27, label %37, label %28
28: ; preds = %19
%29 = load i32*, i32** %3
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %29, i64 %32
%34 = load i32, i32* %33
%35 = icmp ne i32 %34, 71
br i1 %35, label %36, label %37
36: ; preds = %28
store i32 1, i32* %6
br label %41
37: ; preds = %28, %19, %12
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %7
41: ; preds = %36, %7
%42 = load i32, i32* @stderr
%43 = load i32, i32* %6
%44 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %6
ret i32 %45
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"ts_simple_analyze isTs is [%d]\0A\00"
define i32 @_ts_simple_analyze(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 3
br i1 %3, label %4, label %25
4: ; preds = %2
%5 = add nsw i32 %1, -3
%6 = zext i32 %5 to i64
br label %7
7: ; preds = %4, %23
%8 = phi i64 [ 0, %4 ], [ %12, %23 ]
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 71
%12 = add nuw nsw i64 %8, 1
br i1 %11, label %13, label %23
13: ; preds = %7
%14 = getelementptr inbounds i32, i32* %0, i64 %12
%15 = load i32, i32* %14
%16 = and i32 %15, 128
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = add nuw nsw i64 %8, 3
%20 = getelementptr inbounds i32, i32* %0, i64 %19
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 71
br i1 %22, label %23, label %25
23: ; preds = %7, %13, %18
%24 = icmp eq i64 %12, %6
br i1 %24, label %25, label %7
25: ; preds = %23, %18, %2
%26 = phi i32 [ 0, %2 ], [ 1, %18 ], [ 0, %23 ]
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %26)
ret i32 %26
}