#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*/ printf(char *);
int /*<<< orphan*/ report_fatal_error(char *);
int /*<<< orphan*/ sprintf(char *, char *, char, char, char, char);
scalar_t__ strcmp(char *, char *);
int item_db_verify_header(char *buffer, short version, char *delim) {
  char filler[32];
  if (buffer[0] == 'M' && buffer[1] == 'S') {
    printf("header matches\n");
    if (version == 01) {
      if (strcmp(delim, "ITEMS") == 0) {
        return 1;
      } else {
        report_fatal_error("Delim mismatch.");
      }
    } else
      report_fatal_error("Version mismatch.");
  } else {
    sprintf(filler, "Header mismatch in level file. (got %c%c, expected %c%c)",
            buffer[0], buffer[1], 'M', 'S');
    report_fatal_error(filler);
  }
  return 0;
}


x86 assembly (clang, -O0):
<item_db_verify_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %si,%ax
mov    %rdi,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4d,%eax
jne    11d9 <item_db_verify_header+0x99>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x53,%eax
jne    11d9 <item_db_verify_header+0x99>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
movswl -0x12(%rbp),%eax
cmp    $0x1,%eax
jne    11c8 <item_db_verify_header+0x88>
mov    -0x20(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b7 <item_db_verify_header+0x77>
movl   $0x1,-0x4(%rbp)
jmp    1216 <item_db_verify_header+0xd6>
lea    0xe58(%rip),%rdi
call   1050 <report_fatal_error@plt>
jmp    11d4 <item_db_verify_header+0x94>
lea    0xe57(%rip),%rdi
call   1050 <report_fatal_error@plt>
jmp    120f <item_db_verify_header+0xcf>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
lea    0xe4a(%rip),%rsi
mov    $0x4d,%r8d
mov    $0x53,%r9d
movsbl %cl,%edx
movsbl 0x1(%rax),%ecx
call   1060 <sprintf@plt>
lea    -0x40(%rbp),%rdi
call   1050 <report_fatal_error@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<item_db_verify_header>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    (%rdi),%al
mov    0x1(%rdi),%cl
cmp    $0x4d,%al
jne    1188 <item_db_verify_header+0x48>
cmp    $0x53,%cl
jne    1188 <item_db_verify_header+0x48>
mov    %rdx,%rbx
mov    %esi,%ebp
lea    0xf01(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x1,%bp
jne    11b1 <item_db_verify_header+0x71>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11c6 <item_db_verify_header+0x86>
lea    0xe80(%rip),%rdi
jmp    11b8 <item_db_verify_header+0x78>
movsbl %al,%edx
movsbl %cl,%ecx
lea    0xe93(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x4d,%r8d
mov    $0x53,%r9d
call   1060 <sprintf@plt>
mov    %rbx,%rdi
jmp    11b8 <item_db_verify_header+0x78>
lea    0xe5e(%rip),%rdi
call   1050 <report_fatal_error@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0x1,%eax
jmp    11bf <item_db_verify_header+0x7f>

LLVM IR (-O0):
@.str = [16 x i8] c"header matches\0A\00"
@.str.1 = [6 x i8] c"ITEMS\00"
@.str.2 = [16 x i8] c"Delim mismatch.\00"
@.str.3 = [18 x i8] c"Version mismatch.\00"
@.str.4 = [57 x i8] c"Header mismatch in level file. (got %c%c, expected %c%c)\00"
define i32 @item_db_verify_header(i8* %0, i16 signext %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i16
%7 = alloca i8*
%8 = alloca [32 x i8]
store i8* %0, i8** %5
store i16 %1, i16* %6
store i8* %2, i8** %7
%9 = load i8*, i8** %5
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 77
br i1 %13, label %14, label %36
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 83
br i1 %19, label %20, label %36
20: ; preds = %14
%21 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%22 = load i16, i16* %6
%23 = sext i16 %22 to i32
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %33
25: ; preds = %20
%26 = load i8*, i8** %7
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 1, i32* %4
br label %48
30: ; preds = %25
%31 = call i32 @report_fatal_error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30
br label %35
33: ; preds = %20
%34 = call i32 @report_fatal_error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %35
35: ; preds = %33, %32
br label %47
36: ; preds = %14, %3
%37 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i64 0
%40 = load i8, i8* %39
%41 = load i8*, i8** %5
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = load i8, i8* %42
%44 = call i32 @sprintf(i8* %37, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i8 signext %40, i8 signext %43, i8 signext 77, i8 signext 83)
%45 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%46 = call i32 @report_fatal_error(i8* %45)
br label %47
47: ; preds = %36, %35
store i32 0, i32* %4
br label %48
48: ; preds = %47, %29
%49 = load i32, i32* %4
ret i32 %49
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"ITEMS\00"
@.str.2 = [16 x i8] c"Delim mismatch.\00"
@.str.3 = [18 x i8] c"Version mismatch.\00"
@.str.4 = [57 x i8] c"Header mismatch in level file. (got %c%c, expected %c%c)\00"
@str = [15 x i8] c"header matches\00"
define i32 @item_db_verify_header(i8* nocapture %0, i16 signext %1, i8* %2) {
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 77
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 83
%11 = select i1 %7, i1 %10, i1 false
br i1 %11, label %12, label %22
12: ; preds = %3
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%14 = icmp eq i16 %1, 1
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %25, label %18
18: ; preds = %15
%19 = tail call i32 @report_fatal_error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %25
20: ; preds = %12
%21 = tail call i32 @report_fatal_error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %25
22: ; preds = %3
%23 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i8 signext %6, i8 signext %9, i8 signext 77, i8 signext 83)
%24 = call i32 @report_fatal_error(i8* %5)
br label %25
25: ; preds = %22, %20, %18, %15
%26 = phi i32 [ 1, %15 ], [ 0, %18 ], [ 0, %20 ], [ 0, %22 ]
ret i32 %26
}