#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*/ fdd_image_read(int, char *, int /*<<< orphan*/, int);
int dsk_identify(int drive) {
  char header[2];
  fdd_image_read(drive, header, 0, 2);
  if (header[0] == 'T' && header[1] == 'D')
    return (1);
  else if (header[0] == 't' && header[1] == 'd')
    return (1);
  return (0);
}


x86 assembly (clang, -O0):
<dsk_identify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xa(%rbp),%rsi
xor    %edx,%edx
mov    $0x2,%ecx
call   1030 <fdd_image_read@plt>
movsbl -0xa(%rbp),%eax
cmp    $0x54,%eax
jne    1154 <dsk_identify+0x44>
movsbl -0x9(%rbp),%eax
cmp    $0x44,%eax
jne    1154 <dsk_identify+0x44>
movl   $0x1,-0x4(%rbp)
jmp    1186 <dsk_identify+0x76>
movsbl -0xa(%rbp),%eax
cmp    $0x74,%eax
jne    117a <dsk_identify+0x6a>
movsbl -0x9(%rbp),%eax
cmp    $0x64,%eax
jne    117a <dsk_identify+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    1186 <dsk_identify+0x76>
jmp    117f <dsk_identify+0x6f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dsk_identify>:
push   %rax
lea    0x6(%rsp),%rsi
xor    %edx,%edx
mov    $0x2,%ecx
call   1030 <fdd_image_read@plt>
mov    0x6(%rsp),%sil
mov    0x7(%rsp),%al
mov    %esi,%edx
xor    $0x54,%dl
mov    %eax,%ecx
xor    $0x44,%cl
or     %dl,%cl
sete   %cl
xor    $0x74,%sil
xor    $0x64,%al
or     %sil,%al
sete   %al
or     %cl,%al
movzbl %al,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @dsk_identify(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x i8]
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%7 = call i32 @fdd_image_read(i32 %5, i8* %6, i32 0, i32 2)
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 84
br i1 %11, label %12, label %18
12: ; preds = %1
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 68
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 1, i32* %2
br label %31
18: ; preds = %12, %1
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 116
br i1 %22, label %23, label %29
23: ; preds = %18
%24 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 100
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 1, i32* %2
br label %31
29: ; preds = %23, %18
br label %30
30: ; preds = %29
store i32 0, i32* %2
br label %31
31: ; preds = %30, %28, %17
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
define i32 @dsk_identify(i32 %0) {
%2 = alloca [2 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%4 = call i32 @fdd_image_read(i32 %0, i8* %3, i32 0, i32 2)
%5 = load i8, i8* %3
%6 = icmp eq i8 %5, 84
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 68
%10 = select i1 %6, i1 %9, i1 false
%11 = icmp eq i8 %5, 116
%12 = icmp eq i8 %8, 100
%13 = select i1 %11, i1 %12, i1 false
%14 = select i1 %10, i1 true, i1 %13
%15 = zext i1 %14 to i32
ret i32 %15
}