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

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int fread(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ memcmp(char *, char *, int);
int ist64(FILE *infile) {
  char signature1[] = {'C', '6', '4', ' ', 't', 'a', 'p', 'e', ' ', 'i',
                       'm', 'a', 'g', 'e', ' ', 'f', 'i', 'l', 'e'};
  char signature2[] = {'C', '6', '4', 'S', ' ', 't', 'a', 'p', 'e', ' ',
                       'i', 'm', 'a', 'g', 'e', ' ', 'f', 'i', 'l', 'e'};
  char signature3[] = {'C', '6', '4', 'S', ' ', 't', 'a',
                       'p', 'e', ' ', 'f', 'i', 'l', 'e'};
  char read_from_file[64];
  if (fseek(infile, 0, SEEK_SET) != 0)
    return 0;
  if ((fread(read_from_file, 64, 1, infile)) < 1 ||
      ((memcmp(read_from_file, signature1, sizeof(signature1))) &&
       (memcmp(read_from_file, signature2, sizeof(signature2))) &&
       (memcmp(read_from_file, signature3, sizeof(signature3)))))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<ist64>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeb4(%rip),%ax
mov    %ax,-0x20(%rbp)
mov    0xeac(%rip),%al
mov    %al,-0x1e(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xead(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xeab(%rip),%eax
mov    %eax,-0x40(%rbp)
mov    0xea5(%rip),%rax
mov    %rax,-0x5e(%rbp)
mov    0xea3(%rip),%eax
mov    %eax,-0x56(%rbp)
mov    0xe9d(%rip),%ax
mov    %ax,-0x52(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e2e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
cmp    $0x0,%rax
je     11d1 <ist64+0xa1>
movl   $0x0,-0x4(%rbp)
jmp    1264 <ist64+0x134>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x40,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
jl     1251 <ist64+0x121>
lea    -0xa0(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x13,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     125d <ist64+0x12d>
lea    -0xa0(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x14,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     125d <ist64+0x12d>
lea    -0xa0(%rbp),%rdi
lea    -0x5e(%rbp),%rsi
mov    $0xe,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     125d <ist64+0x12d>
movl   $0x0,-0x4(%rbp)
jmp    1264 <ist64+0x134>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ist64>:
push   %rbp
push   %rbx
sub    $0x98,%rsp
mov    %rdi,%rbx
movaps 0xebd(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x656c6966,0x1f(%rsp)
65
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movl   $0x656c6966,0x40(%rsp)
65
movabs $0x656c696620657061,%rax
69 6c 65
mov    %rax,0x6(%rsp)
movabs $0x7061742053343643,%rax
74 61 70
mov    %rax,(%rsp)
mov    0x2e58(%rip),%rax
mov    (%rax),%edx
xor    %ebp,%ebp
xor    %esi,%esi
call   1050 <fseek@plt>
test   %rax,%rax
jne    1201 <ist64+0xd1>
lea    0x50(%rsp),%rdi
mov    $0x40,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
test   %eax,%eax
jle    1201 <ist64+0xd1>
lea    0x50(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x13,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
je     11fc <ist64+0xcc>
lea    0x50(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    $0x14,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
je     11fc <ist64+0xcc>
lea    0x50(%rsp),%rdi
mov    %rsp,%rsi
mov    $0xe,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
jne    1201 <ist64+0xd1>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x98,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.ist64.signature1 = [19 x i8] c"C64 tape image file"
@__const.ist64.signature2 = [20 x i8] c"C64S tape image file"
@__const.ist64.signature3 = [14 x i8] c"C64S tape file"
@SEEK_SET = global i32 0
define i32 @ist64(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [19 x i8]
%5 = alloca [20 x i8]
%6 = alloca [14 x i8]
%7 = alloca [64 x i8]
store i32* %0, i32** %3
%8 = bitcast [19 x i8]* %4 to i8*
%9 = bitcast [20 x i8]* %5 to i8*
%10 = bitcast [14 x i8]* %6 to i8*
%11 = load i32*, i32** %3
%12 = load i32, i32* @SEEK_SET
%13 = call i64 @fseek(i32* %11, i32 0, i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %1
store i32 0, i32* %2
br label %38
16: ; preds = %1
%17 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%18 = load i32*, i32** %3
%19 = call i32 @fread(i8* %17, i32 64, i32 1, i32* %18)
%20 = icmp slt i32 %19, 1
br i1 %20, label %36, label %21
21: ; preds = %16
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%23 = getelementptr inbounds [19 x i8], [19 x i8]* %4, i64 0, i64 0
%24 = call i64 @memcmp(i8* %22, i8* %23, i32 19)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %21
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%29 = call i64 @memcmp(i8* %27, i8* %28, i32 20)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %26
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%33 = getelementptr inbounds [14 x i8], [14 x i8]* %6, i64 0, i64 0
%34 = call i64 @memcmp(i8* %32, i8* %33, i32 14)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %31, %16
store i32 0, i32* %2
br label %38
37: ; preds = %31, %26, %21
store i32 1, i32* %2
br label %38
38: ; preds = %37, %36, %15
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@__const.ist64.signature1 = [19 x i8] c"C64 tape image file"
@__const.ist64.signature2 = [20 x i8] c"C64S tape image file"
@__const.ist64.signature3 = [14 x i8] c"C64S tape file"
@SEEK_SET = global i32 0
define i32 @ist64(i32* nocapture %0) {
%2 = alloca [19 x i8]
%3 = alloca [20 x i8]
%4 = alloca [14 x i8]
%5 = alloca [64 x i8]
%6 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%10 = load i32, i32* @SEEK_SET
%11 = tail call i64 @fseek(i32* %0, i32 0, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %1
%14 = call i32 @fread(i8* %9, i32 64, i32 1, i32* %0)
%15 = icmp slt i32 %14, 1
br i1 %15, label %26, label %16
16: ; preds = %13
%17 = call i64 @memcmp(i8* %9, i8* %6, i32 19)
%18 = icmp eq i64 %17, 0
br i1 %18, label %25, label %19
19: ; preds = %16
%20 = call i64 @memcmp(i8* %9, i8* %7, i32 20)
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = call i64 @memcmp(i8* %9, i8* %8, i32 14)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %22, %19, %16
br label %26
26: ; preds = %13, %22, %1, %25
%27 = phi i32 [ 1, %25 ], [ 0, %1 ], [ 0, %22 ], [ 0, %13 ]
ret i32 %27
}