#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int get_format_ver(char *str) {
  if ((str[9] == 'F') && (str[20] == 'F') && (str[24] == 'S') &&
      (str[31] == 'P') && (str[45] == 'O'))
    return 1;
  else if ((str[9] == 'M') && (str[15] == 'C') && (str[23] == 'F') &&
           (str[34] == 'F') && (str[45] == 'P'))
    return 2;
  fprintf(stderr, "nsrl: Unknown header format: %s\n", str);
  exit(1);
}


x86 assembly (clang, -O0):
<get_format_ver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x9(%rax),%eax
cmp    $0x46,%eax
jne    118d <get_format_ver+0x6d>
mov    -0x10(%rbp),%rax
movsbl 0x14(%rax),%eax
cmp    $0x46,%eax
jne    118d <get_format_ver+0x6d>
mov    -0x10(%rbp),%rax
movsbl 0x18(%rax),%eax
cmp    $0x53,%eax
jne    118d <get_format_ver+0x6d>
mov    -0x10(%rbp),%rax
movsbl 0x1f(%rax),%eax
cmp    $0x50,%eax
jne    118d <get_format_ver+0x6d>
mov    -0x10(%rbp),%rax
movsbl 0x2d(%rax),%eax
cmp    $0x4f,%eax
jne    118d <get_format_ver+0x6d>
movl   $0x1,-0x4(%rbp)
jmp    1216 <get_format_ver+0xf6>
mov    -0x10(%rbp),%rax
movsbl 0x9(%rax),%eax
cmp    $0x4d,%eax
jne    11ee <get_format_ver+0xce>
mov    -0x10(%rbp),%rax
movsbl 0xf(%rax),%eax
cmp    $0x43,%eax
jne    11ee <get_format_ver+0xce>
mov    -0x10(%rbp),%rax
movsbl 0x17(%rax),%eax
cmp    $0x46,%eax
jne    11ee <get_format_ver+0xce>
mov    -0x10(%rbp),%rax
movsbl 0x22(%rax),%eax
cmp    $0x46,%eax
jne    11ee <get_format_ver+0xce>
mov    -0x10(%rbp),%rax
movsbl 0x2d(%rax),%eax
cmp    $0x50,%eax
jne    11ee <get_format_ver+0xce>
movl   $0x2,-0x4(%rbp)
jmp    1216 <get_format_ver+0xf6>
jmp    11f3 <get_format_ver+0xd3>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdf9(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_format_ver>:
push   %rax
mov    %rdi,%rdx
mov    0x9(%rdi),%al
cmp    $0x4d,%al
je     114e <get_format_ver+0x2e>
cmp    $0x46,%al
jne    116d <get_format_ver+0x4d>
cmpb   $0x46,0x14(%rdx)
jne    116d <get_format_ver+0x4d>
cmpb   $0x53,0x18(%rdx)
jne    116d <get_format_ver+0x4d>
cmpb   $0x50,0x1f(%rdx)
jne    116d <get_format_ver+0x4d>
mov    $0x1,%eax
cmpb   $0x4f,0x2d(%rdx)
je     116b <get_format_ver+0x4b>
jmp    116d <get_format_ver+0x4d>
cmpb   $0x43,0xf(%rdx)
jne    116d <get_format_ver+0x4d>
cmpb   $0x46,0x17(%rdx)
jne    116d <get_format_ver+0x4d>
cmpb   $0x46,0x22(%rdx)
jne    116d <get_format_ver+0x4d>
mov    $0x2,%eax
cmpb   $0x50,0x2d(%rdx)
jne    116d <get_format_ver+0x4d>
pop    %rcx
ret
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"nsrl: Unknown header format: %s\0A\00"
define i32 @get_format_ver(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i64 9
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 70
br i1 %8, label %9, label %34
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 20
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 70
br i1 %14, label %15, label %34
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 24
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 83
br i1 %20, label %21, label %34
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 31
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 80
br i1 %26, label %27, label %34
27: ; preds = %21
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 45
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 79
br i1 %32, label %33, label %34
33: ; preds = %27
store i32 1, i32* %2
br label %71
34: ; preds = %27, %21, %15, %9, %1
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i64 9
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 77
br i1 %39, label %40, label %65
40: ; preds = %34
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i64 15
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 67
br i1 %45, label %46, label %65
46: ; preds = %40
%47 = load i8*, i8** %3
%48 = getelementptr inbounds i8, i8* %47, i64 23
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 70
br i1 %51, label %52, label %65
52: ; preds = %46
%53 = load i8*, i8** %3
%54 = getelementptr inbounds i8, i8* %53, i64 34
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 70
br i1 %57, label %58, label %65
58: ; preds = %52
%59 = load i8*, i8** %3
%60 = getelementptr inbounds i8, i8* %59, i64 45
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 80
br i1 %63, label %64, label %65
64: ; preds = %58
store i32 2, i32* %2
br label %71
65: ; preds = %58, %52, %46, %40, %34
br label %66
66: ; preds = %65
%67 = load i32, i32* @stderr
%68 = load i8*, i8** %3
%69 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %68)
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %64, %33
%72 = load i32, i32* %2
ret i32 %72
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"nsrl: Unknown header format: %s\0A\00"
define i32 @get_format_ver(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 9
%3 = load i8, i8* %2
switch i8 %3, label %36 [
i8 70, label %4
i8 77, label %20
]
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 20
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 70
br i1 %7, label %8, label %36
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %0, i64 24
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 83
br i1 %11, label %12, label %36
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %0, i64 31
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 80
br i1 %15, label %16, label %36
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %0, i64 45
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 79
br i1 %19, label %40, label %36
20: ; preds = %1
%21 = getelementptr inbounds i8, i8* %0, i64 15
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 67
br i1 %23, label %24, label %36
24: ; preds = %20
%25 = getelementptr inbounds i8, i8* %0, i64 23
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 70
br i1 %27, label %28, label %36
28: ; preds = %24
%29 = getelementptr inbounds i8, i8* %0, i64 34
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 70
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = getelementptr inbounds i8, i8* %0, i64 45
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 80
br i1 %35, label %40, label %36
36: ; preds = %1, %4, %8, %12, %16, %20, %24, %28, %32
%37 = load i32, i32* @stderr
%38 = tail call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %0)
%39 = tail call i32 @exit(i32 1)
unreachable
40: ; preds = %32, %16
%41 = phi i32 [ 1, %16 ], [ 2, %32 ]
ret i32 %41
}