#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*/ SEEK_SET;
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
scalar_t__ isalnum(char);
int check_format(FILE *fp) {
  char buffer[3];
  fseek(fp, 0, SEEK_SET);
  fread(buffer, 1, 3, fp);
  if (buffer[0] == 0x76 && buffer[1] == 0x07 && isalnum(buffer[2]))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<check_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
lea    -0x13(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x3,%edx
call   1030 <fread@plt>
movsbl -0x13(%rbp),%eax
cmp    $0x76,%eax
jne    11a0 <check_format+0x70>
movsbl -0x12(%rbp),%eax
cmp    $0x7,%eax
jne    11a0 <check_format+0x70>
movsbl -0x11(%rbp),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%rax
je     11a0 <check_format+0x70>
movl   $0x1,-0x4(%rbp)
jmp    11a7 <check_format+0x77>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_format>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    0x2ea1(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
lea    0xd(%rsp),%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmpb   $0x76,0xd(%rsp)
jne    1184 <check_format+0x54>
cmpb   $0x7,0xe(%rsp)
jne    1184 <check_format+0x54>
movsbl 0xf(%rsp),%edi
call   1040 <isalnum@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1186 <check_format+0x56>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @check_format(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [3 x i8]
store i32* %0, i32** %3
%5 = load i32*, i32** %3
%6 = load i32, i32* @SEEK_SET
%7 = call i32 @fseek(i32* %5, i32 0, i32 %6)
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%9 = load i32*, i32** %3
%10 = call i32 @fread(i8* %8, i32 1, i32 3, i32* %9)
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 118
br i1 %14, label %15, label %26
15: ; preds = %1
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 7
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
%22 = load i8, i8* %21
%23 = call i64 @isalnum(i8 signext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 1, i32* %2
br label %27
26: ; preds = %20, %15, %1
store i32 0, i32* %2
br label %27
27: ; preds = %26, %25
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @check_format(i32* nocapture %0) {
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @SEEK_SET
%5 = tail call i32 @fseek(i32* %0, i32 0, i32 %4)
%6 = call i32 @fread(i8* %3, i32 1, i32 3, i32* %0)
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 118
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 7
%12 = select i1 %8, i1 %11, i1 false
br i1 %12, label %13, label %18
13: ; preds = %1
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 2
%15 = load i8, i8* %14
%16 = tail call i64 @isalnum(i8 signext %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13, %1
br label %19
19: ; preds = %13, %18
%20 = phi i32 [ 0, %18 ], [ 1, %13 ]
ret i32 %20
}