#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 *ScanHeader_Pre(uint8_t Data) {
  static uint8_t buf[2];
  static uint8_t index = 0;
  uint8_t *result = NULL;
  buf[index++] = Data;
  if (2 == index) {
    if ((0xAB == buf[0]) && (0x55 == buf[1])) {
      result = buf;
      index = 0;
      goto END;
    }
    if ((0xAB != buf[0]) && (0xAB == buf[1])) {
      buf[0] = buf[1];
      index = 1;
      goto END;
    }
    index = 0;
  }
END:
  return result;
}


x86 assembly (clang, -O0):
<ScanHeader_Pre>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%edx
mov    0x2f14(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2f09(%rip)
movslq %eax,%rcx
lea    0x2ef7(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    $0x2,%eax
cmp    0x2ef1(%rip),%eax
jne    11c4 <ScanHeader_Pre+0xc4>
mov    $0xab,%eax
cmp    0x2ed8(%rip),%eax
jne    117d <ScanHeader_Pre+0x7d>
mov    $0x55,%eax
cmp    0x2ecb(%rip),%eax
jne    117d <ScanHeader_Pre+0x7d>
lea    0x2eba(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,0x2eb4(%rip)
jmp    11c9 <ScanHeader_Pre+0xc9>
mov    $0xab,%eax
cmp    0x2e9c(%rip),%eax
je     11ba <ScanHeader_Pre+0xba>
mov    $0xab,%eax
cmp    0x2e8f(%rip),%eax
jne    11ba <ScanHeader_Pre+0xba>
mov    0x2e83(%rip),%eax
mov    %eax,0x2e79(%rip)
movl   $0x1,0x2e77(%rip)
jmp    11c9 <ScanHeader_Pre+0xc9>
movl   $0x0,0x2e68(%rip)
jmp    11c9 <ScanHeader_Pre+0xc9>
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ScanHeader_Pre>:
movslq 0x2f25(%rip),%rcx
lea    0x1(%rcx),%edx
mov    %edx,0x2f1c(%rip)
lea    0x2f0d(%rip),%rax
mov    %edi,(%rax,%rcx,4)
xor    %ecx,%ecx
cmp    $0x2,%edx
jne    1141 <ScanHeader_Pre+0x41>
mov    0x2efd(%rip),%esi
mov    0x2efb(%rip),%edx
cmp    $0xab,%esi
jne    1144 <ScanHeader_Pre+0x44>
cmp    $0x55,%edx
jne    1144 <ScanHeader_Pre+0x44>
mov    %ecx,0x2eec(%rip)
ret
xor    %eax,%eax
ret
xor    %ecx,%ecx
cmp    $0xab,%esi
je     116a <ScanHeader_Pre+0x6a>
mov    $0x0,%eax
cmp    $0xab,%edx
jne    113a <ScanHeader_Pre+0x3a>
movl   $0xab,0x2ebf(%rip)
mov    $0x1,%ecx
xor    %eax,%eax
mov    %ecx,0x2eba(%rip)
ret

LLVM IR (-O0):
@ScanHeader_Pre.buf = internal global [2 x i32] zeroinitializer
@ScanHeader_Pre.index = internal global i32 0
define i32* @ScanHeader_Pre(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
store i32 %0, i32* %2
store i32* null, i32** %3
%4 = load i32, i32* %2
%5 = load i32, i32* @ScanHeader_Pre.index
%6 = add nsw i32 %5, 1
store i32 %6, i32* @ScanHeader_Pre.index
%7 = sext i32 %5 to i64
%8 = getelementptr inbounds [2 x i32], [2 x i32]* @ScanHeader_Pre.buf, i64 0, i64 %7
store i32 %4, i32* %8
%9 = load i32, i32* @ScanHeader_Pre.index
%10 = icmp eq i32 2, %9
br i1 %10, label %11, label %27
11: ; preds = %1
%12 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @ScanHeader_Pre.buf, i64 0, i64 0)
%13 = icmp eq i32 171, %12
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @ScanHeader_Pre.buf, i64 0, i64 1)
%16 = icmp eq i32 85, %15
br i1 %16, label %17, label %18
17: ; preds = %14
store i32* getelementptr inbounds ([2 x i32], [2 x i32]* @ScanHeader_Pre.buf, i64 0, i64 0), i32** %3
store i32 0, i32* @ScanHeader_Pre.index
br label %28
18: ; preds = %14, %11
%19 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @ScanHeader_Pre.buf, i64 0, i64 0)
%20 = icmp ne i32 171, %19
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @ScanHeader_Pre.buf, i64 0, i64 1)
%23 = icmp eq i32 171, %22
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @ScanHeader_Pre.buf, i64 0, i64 1)
store i32 %25, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @ScanHeader_Pre.buf, i64 0, i64 0)
store i32 1, i32* @ScanHeader_Pre.index
br label %28
26: ; preds = %21, %18
store i32 0, i32* @ScanHeader_Pre.index
br label %27
27: ; preds = %26, %1
br label %28
28: ; preds = %27, %24, %17
%29 = load i32*, i32** %3
ret i32* %29
}

LLVM IR (-O2):
@ScanHeader_Pre.buf = internal global [2 x i32] zeroinitializer
@ScanHeader_Pre.index = internal unnamed_addr global i32 0
define i32* @ScanHeader_Pre(i32 %0) {
%2 = load i32, i32* @ScanHeader_Pre.index
%3 = add nsw i32 %2, 1
store i32 %3, i32* @ScanHeader_Pre.index
%4 = sext i32 %2 to i64
%5 = getelementptr inbounds [2 x i32], [2 x i32]* @ScanHeader_Pre.buf, i64 0, i64 %4
store i32 %0, i32* %5
%6 = icmp eq i32 %3, 2
br i1 %6, label %7, label %21
7: ; preds = %1
%8 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @ScanHeader_Pre.buf, i64 0, i64 0)
%9 = icmp eq i32 %8, 171
%10 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @ScanHeader_Pre.buf, i64 0, i64 1)
%11 = icmp eq i32 %10, 85
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %18, label %13
13: ; preds = %7
%14 = icmp ne i32 %8, 171
%15 = icmp eq i32 %10, 171
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 171, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @ScanHeader_Pre.buf, i64 0, i64 0)
br label %18
18: ; preds = %13, %7, %17
%19 = phi i32 [ 1, %17 ], [ 0, %7 ], [ 0, %13 ]
%20 = phi i32* [ null, %17 ], [ getelementptr inbounds ([2 x i32], [2 x i32]* @ScanHeader_Pre.buf, i64 0, i64 0), %7 ], [ null, %13 ]
store i32 %19, i32* @ScanHeader_Pre.index
br label %21
21: ; preds = %18, %1
%22 = phi i32* [ null, %1 ], [ %20, %18 ]
ret i32* %22
}