#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 */

/* Variables and functions */
int /*<<< orphan*/ get16le();
int get32le();
char get8();
int bmp_test(void) {
  int sz;
  if (get8() != 'B')
    return 0;
  if (get8() != 'M')
    return 0;
  get32le();
  get16le();
  get16le();
  get32le();
  sz = get32le();
  if (sz == 12 || sz == 40 || sz == 56 || sz == 108)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<bmp_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <get8@plt>
movsbl %al,%eax
cmp    $0x42,%eax
je     1157 <bmp_test+0x27>
movl   $0x0,-0x4(%rbp)
jmp    11d7 <bmp_test+0xa7>
mov    $0x0,%al
call   1030 <get8@plt>
movsbl %al,%eax
cmp    $0x4d,%eax
je     1176 <bmp_test+0x46>
movl   $0x0,-0x4(%rbp)
jmp    11d7 <bmp_test+0xa7>
mov    $0x0,%al
call   1040 <get32le@plt>
mov    $0x0,%al
call   1050 <get16le@plt>
mov    $0x0,%al
call   1050 <get16le@plt>
mov    $0x0,%al
call   1040 <get32le@plt>
mov    $0x0,%al
call   1040 <get32le@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xc,-0x8(%rbp)
je     11c4 <bmp_test+0x94>
cmpl   $0x28,-0x8(%rbp)
je     11c4 <bmp_test+0x94>
cmpl   $0x38,-0x8(%rbp)
je     11c4 <bmp_test+0x94>
cmpl   $0x6c,-0x8(%rbp)
jne    11d0 <bmp_test+0xa0>
movl   $0x1,-0x4(%rbp)
jmp    11d7 <bmp_test+0xa7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bmp_test>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get8@plt>
cmp    $0x42,%al
jne    1191 <bmp_test+0x61>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get8@plt>
cmp    $0x4d,%al
jne    1191 <bmp_test+0x61>
xor    %eax,%eax
call   1040 <get32le@plt>
xor    %eax,%eax
call   1050 <get16le@plt>
xor    %eax,%eax
call   1050 <get16le@plt>
xor    %eax,%eax
call   1040 <get32le@plt>
xor    %eax,%eax
call   1040 <get32le@plt>
mov    $0x1,%ebx
cmp    $0x38,%eax
ja     118a <bmp_test+0x5a>
mov    %eax,%ecx
movabs $0x100010000001000,%rdx
bt     %rcx,%rdx
jb     1191 <bmp_test+0x61>
cmp    $0x6c,%eax
je     1191 <bmp_test+0x61>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @bmp_test() {
%1 = alloca i32
%2 = alloca i32
%3 = call signext i8 (...) @get8()
%4 = sext i8 %3 to i32
%5 = icmp ne i32 %4, 66
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 0, i32* %1
br label %31
7: ; preds = %0
%8 = call signext i8 (...) @get8()
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 77
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 0, i32* %1
br label %31
12: ; preds = %7
%13 = call i32 (...) @get32le()
%14 = call i32 (...) @get16le()
%15 = call i32 (...) @get16le()
%16 = call i32 (...) @get32le()
%17 = call i32 (...) @get32le()
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 12
br i1 %19, label %29, label %20
20: ; preds = %12
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 40
br i1 %22, label %29, label %23
23: ; preds = %20
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 56
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 108
br i1 %28, label %29, label %30
29: ; preds = %26, %23, %20, %12
store i32 1, i32* %1
br label %31
30: ; preds = %26
store i32 0, i32* %1
br label %31
31: ; preds = %30, %29, %11, %6
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
define i32 @bmp_test() {
%1 = tail call signext i8 (...) @get8()
%2 = icmp eq i8 %1, 66
br i1 %2, label %3, label %13
3: ; preds = %0
%4 = tail call signext i8 (...) @get8()
%5 = icmp eq i8 %4, 77
br i1 %5, label %6, label %13
6: ; preds = %3
%7 = tail call i32 (...) @get32le()
%8 = tail call i32 (...) @get16le()
%9 = tail call i32 (...) @get16le()
%10 = tail call i32 (...) @get32le()
%11 = tail call i32 (...) @get32le()
switch i32 %11, label %12 [
i32 108, label %13
i32 56, label %13
i32 40, label %13
i32 12, label %13
]
12: ; preds = %6
br label %13
13: ; preds = %6, %6, %6, %6, %3, %0, %12
%14 = phi i32 [ 0, %12 ], [ 0, %0 ], [ 0, %3 ], [ 1, %6 ], [ 1, %6 ], [ 1, %6 ], [ 1, %6 ]
ret i32 %14
}