#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 */
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int member_0;
  int member_1;
  int member_2;
  int member_3;
};
typedef TYPE_1__ uint8_t;
typedef int uint32_t;

/* Variables and functions */
scalar_t__ searchForBytes(TYPE_1__ const *, int, TYPE_1__ *, int, int);
int isProbably0840(const uint8_t *image, uint32_t size) {
  uint8_t signature1[3][3] = {
      {0xAD, 0x00, 0x08}, {0xAD, 0x40, 0x08}, {0x2C, 0x00, 0x08}};
  uint32_t i;
  for (i = 0; i < 3; ++i)
    if (searchForBytes(image, size, signature1[i], 3, 2))
      return 1;
  uint8_t signature2[2][4] = {{0x0C, 0x00, 0x08, 0x4C},
                              {0x0C, 0xFF, 0x0F, 0x4C}};
  for (i = 0; i < 2; ++i)
    if (searchForBytes(image, size, signature2[i], 4, 2))
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<isProbably0840>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xec0(%rip),%rsi
mov    $0x90,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0xb4(%rbp)
cmpl   $0x3,-0xb4(%rbp)
jge    11bc <isProbably0840+0x9c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
movslq -0xb4(%rbp),%rax
lea    -0xb0(%rbp),%rdx
imul   $0x30,%rax,%rax
add    %rax,%rdx
mov    $0x3,%ecx
mov    $0x2,%r8d
call   1030 <searchForBytes@plt>
cmp    $0x0,%rax
je     11a3 <isProbably0840+0x83>
movl   $0x1,-0x4(%rbp)
jmp    124d <isProbably0840+0x12d>
jmp    11a8 <isProbably0840+0x88>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1154 <isProbably0840+0x34>
lea    -0x140(%rbp),%rdi
lea    0xec6(%rip),%rsi
mov    $0x80,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0xb4(%rbp)
cmpl   $0x2,-0xb4(%rbp)
jge    1246 <isProbably0840+0x126>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
movslq -0xb4(%rbp),%rax
lea    -0x140(%rbp),%rdx
shl    $0x6,%rax
add    %rax,%rdx
mov    $0x4,%ecx
mov    $0x2,%r8d
call   1030 <searchForBytes@plt>
cmp    $0x0,%rax
je     122d <isProbably0840+0x10d>
movl   $0x1,-0x4(%rbp)
jmp    124d <isProbably0840+0x12d>
jmp    1232 <isProbably0840+0x112>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    11de <isProbably0840+0xbe>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isProbably0840>:
push   %rbp
push   %r14
push   %rbx
sub    $0x110,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xec8(%rip),%rsi
lea    0x80(%rsp),%rbp
mov    $0x90,%edx
mov    %rbp,%rdi
call   1040 <memcpy@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %rbp,%rdx
mov    $0x3,%ecx
mov    $0x2,%r8d
call   1030 <searchForBytes@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    1268 <isProbably0840+0x148>
lea    0xb0(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    $0x3,%ecx
mov    $0x2,%r8d
call   1030 <searchForBytes@plt>
test   %rax,%rax
jne    1268 <isProbably0840+0x148>
lea    0xe0(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    $0x3,%ecx
mov    $0x2,%r8d
call   1030 <searchForBytes@plt>
test   %rax,%rax
jne    1268 <isProbably0840+0x148>
movaps 0xf37(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xf1b(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xeff(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xee3(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xec7(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeab(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe8f(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe73(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    $0x4,%ecx
mov    $0x2,%r8d
call   1030 <searchForBytes@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    1268 <isProbably0840+0x148>
lea    0x40(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    $0x4,%ecx
mov    $0x2,%r8d
call   1030 <searchForBytes@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, i32, i32, i32 }
@__const.isProbably0840.signature1 = [3 x [3 x %struct.TYPE_5__]] [[3 x %struct.TYPE_5__] [%struct.TYPE_5__ { i32 173, i32 0, i32 8, i32 0 }, %struct.TYPE_5__ zeroinitializer, %struct.TYPE_5__ zeroinitializer], [3 x %struct.TYPE_5__] [%struct.TYPE_5__ { i32 173, i32 64, i32 8, i32 0 }, %struct.TYPE_5__ zeroinitializer, %struct.TYPE_5__ zeroinitializer], [3 x %struct.TYPE_5__] [%struct.TYPE_5__ { i32 44, i32 0, i32 8, i32 0 }, %struct.TYPE_5__ zeroinitializer, %struct.TYPE_5__ zeroinitializer]]
@__const.isProbably0840.signature2 = [2 x [4 x %struct.TYPE_5__]] [[4 x %struct.TYPE_5__] [%struct.TYPE_5__ { i32 12, i32 0, i32 8, i32 76 }, %struct.TYPE_5__ zeroinitializer, %struct.TYPE_5__ zeroinitializer, %struct.TYPE_5__ zeroinitializer], [4 x %struct.TYPE_5__] [%struct.TYPE_5__ { i32 12, i32 255, i32 15, i32 76 }, %struct.TYPE_5__ zeroinitializer, %struct.TYPE_5__ zeroinitializer, %struct.TYPE_5__ zeroinitializer]]
define i32 @isProbably0840(%struct.TYPE_5__* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_5__*
%5 = alloca i32
%6 = alloca [3 x [3 x %struct.TYPE_5__]]
%7 = alloca i32
%8 = alloca [2 x [4 x %struct.TYPE_5__]]
store %struct.TYPE_5__* %0, %struct.TYPE_5__** %4
store i32 %1, i32* %5
%9 = bitcast [3 x [3 x %struct.TYPE_5__]]* %6 to i8*
store i32 0, i32* %7
br label %10
10: ; preds = %24, %2
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %27
13: ; preds = %10
%14 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%15 = load i32, i32* %5
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [3 x [3 x %struct.TYPE_5__]], [3 x [3 x %struct.TYPE_5__]]* %6, i64 0, i64 %17
%19 = getelementptr inbounds [3 x %struct.TYPE_5__], [3 x %struct.TYPE_5__]* %18, i64 0, i64 0
%20 = call i64 @searchForBytes(%struct.TYPE_5__* %14, i32 %15, %struct.TYPE_5__* %19, i32 3, i32 2)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %13
store i32 1, i32* %3
br label %47
23: ; preds = %13
br label %24
24: ; preds = %23
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %10
27: ; preds = %10
%28 = bitcast [2 x [4 x %struct.TYPE_5__]]* %8 to i8*
store i32 0, i32* %7
br label %29
29: ; preds = %43, %27
%30 = load i32, i32* %7
%31 = icmp slt i32 %30, 2
br i1 %31, label %32, label %46
32: ; preds = %29
%33 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%34 = load i32, i32* %5
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [2 x [4 x %struct.TYPE_5__]], [2 x [4 x %struct.TYPE_5__]]* %8, i64 0, i64 %36
%38 = getelementptr inbounds [4 x %struct.TYPE_5__], [4 x %struct.TYPE_5__]* %37, i64 0, i64 0
%39 = call i64 @searchForBytes(%struct.TYPE_5__* %33, i32 %34, %struct.TYPE_5__* %38, i32 4, i32 2)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %32
store i32 1, i32* %3
br label %47
42: ; preds = %32
br label %43
43: ; preds = %42
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %29
46: ; preds = %29
store i32 0, i32* %3
br label %47
47: ; preds = %46, %41, %22
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, i32, i32, i32 }
@__const.isProbably0840.signature1 = [3 x [3 x %struct.TYPE_5__]] [[3 x %struct.TYPE_5__] [%struct.TYPE_5__ { i32 173, i32 0, i32 8, i32 0 }, %struct.TYPE_5__ zeroinitializer, %struct.TYPE_5__ zeroinitializer], [3 x %struct.TYPE_5__] [%struct.TYPE_5__ { i32 173, i32 64, i32 8, i32 0 }, %struct.TYPE_5__ zeroinitializer, %struct.TYPE_5__ zeroinitializer], [3 x %struct.TYPE_5__] [%struct.TYPE_5__ { i32 44, i32 0, i32 8, i32 0 }, %struct.TYPE_5__ zeroinitializer, %struct.TYPE_5__ zeroinitializer]]
@__const.isProbably0840.signature2 = [2 x [4 x %struct.TYPE_5__]] [[4 x %struct.TYPE_5__] [%struct.TYPE_5__ { i32 12, i32 0, i32 8, i32 76 }, %struct.TYPE_5__ zeroinitializer, %struct.TYPE_5__ zeroinitializer, %struct.TYPE_5__ zeroinitializer], [4 x %struct.TYPE_5__] [%struct.TYPE_5__ { i32 12, i32 255, i32 15, i32 76 }, %struct.TYPE_5__ zeroinitializer, %struct.TYPE_5__ zeroinitializer, %struct.TYPE_5__ zeroinitializer]]
define i32 @isProbably0840(%struct.TYPE_5__* %0, i32 %1) {
%3 = alloca [3 x [3 x %struct.TYPE_5__]]
%4 = alloca [2 x [4 x %struct.TYPE_5__]]
%5 = bitcast [3 x [3 x %struct.TYPE_5__]]* %3 to i8*
%6 = getelementptr inbounds [3 x [3 x %struct.TYPE_5__]], [3 x [3 x %struct.TYPE_5__]]* %3, i64 0, i64 0, i64 0
%7 = call i64 @searchForBytes(%struct.TYPE_5__* %0, i32 %1, %struct.TYPE_5__* %6, i32 3, i32 2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %29
9: ; preds = %2
%10 = getelementptr inbounds [3 x [3 x %struct.TYPE_5__]], [3 x [3 x %struct.TYPE_5__]]* %3, i64 0, i64 1, i64 0
%11 = call i64 @searchForBytes(%struct.TYPE_5__* %0, i32 %1, %struct.TYPE_5__* %10, i32 3, i32 2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = getelementptr inbounds [3 x [3 x %struct.TYPE_5__]], [3 x [3 x %struct.TYPE_5__]]* %3, i64 0, i64 2, i64 0
%15 = call i64 @searchForBytes(%struct.TYPE_5__* %0, i32 %1, %struct.TYPE_5__* %14, i32 3, i32 2)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %29
17: ; preds = %13
%18 = bitcast [2 x [4 x %struct.TYPE_5__]]* %4 to i8*
%19 = getelementptr inbounds [2 x [4 x %struct.TYPE_5__]], [2 x [4 x %struct.TYPE_5__]]* %4, i64 0, i64 0, i64 0
%20 = call i64 @searchForBytes(%struct.TYPE_5__* %0, i32 %1, %struct.TYPE_5__* %19, i32 4, i32 2)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = getelementptr inbounds [2 x [4 x %struct.TYPE_5__]], [2 x [4 x %struct.TYPE_5__]]* %4, i64 0, i64 1, i64 0
%24 = call i64 @searchForBytes(%struct.TYPE_5__* %0, i32 %1, %struct.TYPE_5__* %23, i32 4, i32 2)
%25 = icmp ne i64 %24, 0
%26 = zext i1 %25 to i32
br label %27
27: ; preds = %22, %17
%28 = phi i32 [ 1, %17 ], [ %26, %22 ]
br label %29
29: ; preds = %2, %9, %13, %27
%30 = phi i32 [ %28, %27 ], [ 1, %13 ], [ 1, %9 ], [ 1, %2 ]
ret i32 %30
}