#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ ckfread(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int headerOK(FILE *fp) {
  char ver[4];
  ckfread(ver, 2 * sizeof(char), fp);
  ver[2] = '\0';
  ckfread(&ver[3], 1, fp);
  if (strcmp(ver, "FC") != 0) {
    fprintf(stderr, "MIME type sconosciuto. Intestazione errata: %c%c\n",
            ver[0], ver[1]);
    return 0;
  }
  if (ver[3] != 1) {
    fprintf(
        stderr,
        "Formato FantasyCore sconosciuto(supportato: v1). Versione: v%u ?\n",
        ver[3]);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<headerOK>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2,%esi
call   1050 <ckfread@plt>
movb   $0x0,-0x12(%rbp)
lea    -0x14(%rbp),%rdi
add    $0x3,%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1,%esi
call   1050 <ckfread@plt>
lea    -0x14(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11af <headerOK+0x7f>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%al
movsbl -0x13(%rbp),%ecx
lea    0xe6a(%rip),%rsi
movsbl %al,%edx
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ea <headerOK+0xba>
movsbl -0x11(%rbp),%eax
cmp    $0x1,%eax
je     11e3 <headerOK+0xb3>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe69(%rip),%rsi
movsbl -0x11(%rbp),%edx
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ea <headerOK+0xba>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<headerOK>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xc(%rsp),%r14
mov    %r14,%rdi
mov    $0x2,%esi
mov    %rbx,%rdx
call   1050 <ckfread@plt>
movb   $0x0,0xe(%rsp)
lea    0xf(%rsp),%rdi
mov    $0x1,%ebp
mov    $0x1,%esi
mov    %rbx,%rdx
call   1050 <ckfread@plt>
lea    0xe8d(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11a5 <headerOK+0x75>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
movsbl 0xc(%rsp),%edx
movsbl 0xd(%rsp),%ecx
lea    0xe69(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11c9 <headerOK+0x99>
mov    0xf(%rsp),%al
cmp    $0x1,%al
je     11c9 <headerOK+0x99>
mov    0x2e2c(%rip),%rcx
mov    (%rcx),%edi
movsbl %al,%edx
lea    0xe75(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"FC\00"
@stderr = global i32 0
@.str.1 = [50 x i8] c"MIME type sconosciuto. Intestazione errata: %c%c\0A\00"
@.str.2 = [66 x i8] c"Formato FantasyCore sconosciuto(supportato: v1). Versione: v%u ?\0A\00"
define i32 @headerOK(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [4 x i8]
store i32* %0, i32** %3
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%6 = load i32*, i32** %3
%7 = call i32 @ckfread(i8* %5, i32 2, i32* %6)
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
store i8 0, i8* %8
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%10 = load i32*, i32** %3
%11 = call i32 @ckfread(i8* %9, i32 1, i32* %10)
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %1
%16 = load i32, i32* @stderr
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%18 = load i8, i8* %17
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = call i32 (i32, i8*, i8, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8 signext %18, i32 %21)
store i32 0, i32* %2
br label %34
23: ; preds = %1
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 1
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%31 = load i8, i8* %30
%32 = call i32 (i32, i8*, i8, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0), i8 signext %31)
store i32 0, i32* %2
br label %34
33: ; preds = %23
store i32 1, i32* %2
br label %34
34: ; preds = %33, %28, %15
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [3 x i8] c"FC\00"
@stderr = global i32 0
@.str.1 = [50 x i8] c"MIME type sconosciuto. Intestazione errata: %c%c\0A\00"
@.str.2 = [66 x i8] c"Formato FantasyCore sconosciuto(supportato: v1). Versione: v%u ?\0A\00"
define i32 @headerOK(i32* %0) {
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%4 = call i32 @ckfread(i8* %3, i32 2, i32* %0)
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 2
store i8 0, i8* %5
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 3
%7 = call i32 @ckfread(i8* %6, i32 1, i32* %0)
%8 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = load i8, i8* %3
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = call i32 (i32, i8*, i8, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8 signext %12, i32 %15)
br label %23
17: ; preds = %1
%18 = load i8, i8* %6
%19 = icmp eq i8 %18, 1
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, i8, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0), i8 signext %18)
br label %23
23: ; preds = %17, %20, %10
%24 = phi i32 [ 0, %10 ], [ 0, %20 ], [ 1, %17 ]
ret i32 %24
}