#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 *, char *);
int /*<<< orphan*/ sprintf(char *, char *, short, int, ...);
int tilemap_verify_header(char *buffer, short version) {
  char filler[32];
  if (buffer[0] == 'M' && buffer[1] == 'S')
    return 1;
  else {
    if (buffer[0] != 'M' || buffer[1] != 'S') {
      sprintf(filler,
              "Header mismatch in level file. (got %c%c; expected %c%c)\n",
              buffer[0], buffer[1], 'M', 'S');
      printf("%s", filler);
    } else if (version != 05) {
      if (version >= 4)
        return 1;
      else {
        sprintf(filler,
                "Version mismatch in level file. (got %d; expected %d)\n",
                version, 05);
        printf("%s", filler);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<tilemap_verify_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %si,%ax
mov    %rdi,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4d,%eax
jne    1160 <tilemap_verify_header+0x40>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x53,%eax
jne    1160 <tilemap_verify_header+0x40>
movl   $0x1,-0x4(%rbp)
jmp    122d <tilemap_verify_header+0x10d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4d,%eax
jne    1181 <tilemap_verify_header+0x61>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x53,%eax
je     11c6 <tilemap_verify_header+0xa6>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
lea    0xe65(%rip),%rsi
mov    $0x4d,%r8d
mov    $0x53,%r9d
movswl %ax,%edx
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
jmp    1221 <tilemap_verify_header+0x101>
movswl -0x12(%rbp),%eax
cmp    $0x5,%eax
je     121c <tilemap_verify_header+0xfc>
movswl -0x12(%rbp),%eax
cmp    $0x4,%eax
jl     11ec <tilemap_verify_header+0xcc>
movl   $0x1,-0x4(%rbp)
jmp    122d <tilemap_verify_header+0x10d>
lea    -0x40(%rbp),%rdi
lea    0xe46(%rip),%rsi
mov    $0x5,%ecx
movswl -0x12(%rbp),%edx
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe28(%rip),%rdi
call   1030 <printf@plt>
jmp    121c <tilemap_verify_header+0xfc>
jmp    1221 <tilemap_verify_header+0x101>
jmp    1226 <tilemap_verify_header+0x106>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tilemap_verify_header>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movsbl (%rdi),%eax
mov    0x1(%rdi),%cl
cmp    $0x4d,%ax
jne    113d <tilemap_verify_header+0x1d>
mov    $0x1,%ebx
cmp    $0x53,%cl
je     1174 <tilemap_verify_header+0x54>
movsbl %cl,%ecx
movswl %ax,%edx
lea    0xeb6(%rip),%rsi
xor    %ebx,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x4d,%r8d
mov    $0x53,%r9d
xor    %eax,%eax
call   1040 <sprintf@plt>
lea    0xece(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [58 x i8] c"Header mismatch in level file. (got %c%c; expected %c%c)\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @tilemap_verify_header(i8* nocapture %0, i16 signext %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 77
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 83
%10 = select i1 %6, i1 %9, i1 false
br i1 %10, label %16, label %11
11: ; preds = %2
%12 = sext i8 %5 to i16
%13 = sext i8 %8 to i32
%14 = call i32 (i8*, i8*, i16, i32, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i16 signext %12, i32 %13, i32 77, i32 83)
%15 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %16
16: ; preds = %2, %11
%17 = phi i32 [ 0, %11 ], [ 1, %2 ]
ret i32 %17
}