#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*/ ata_begin(int, int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ ata_pio_read(int, void *, int);
int /*<<< orphan*/ ata_wait(int, int, int);
int ata_identify(int id, int command, void *buffer) {
  if (!ata_begin(id, command, 0, 0))
    return 0;
  if (!ata_wait(id, 0x08, 0x08))
    return 0;
  ata_pio_read(id, buffer, 512);
  return 1;
}


x86 assembly (clang, -O0):
<ata_identify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1050 <ata_begin@plt>
cmp    $0x0,%eax
jne    1166 <ata_identify+0x36>
movl   $0x0,-0x4(%rbp)
jmp    11a2 <ata_identify+0x72>
mov    -0x8(%rbp),%edi
mov    $0x8,%edx
mov    %edx,%esi
call   1040 <ata_wait@plt>
cmp    $0x0,%eax
jne    118a <ata_identify+0x5a>
movl   $0x0,-0x4(%rbp)
jmp    11a2 <ata_identify+0x72>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0x200,%edx
call   1030 <ata_pio_read@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ata_identify>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %edi,%ebx
xor    %ebp,%ebp
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <ata_begin@plt>
test   %eax,%eax
je     1171 <ata_identify+0x41>
mov    %ebx,%edi
mov    $0x8,%esi
mov    $0x8,%edx
call   1040 <ata_wait@plt>
test   %eax,%eax
je     1171 <ata_identify+0x41>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x200,%edx
call   1030 <ata_pio_read@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ata_identify(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%8 = load i32, i32* %5
%9 = load i32, i32* %6
%10 = call i32 @ata_begin(i32 %8, i32 %9, i32 0, i32 0)
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %3
store i32 0, i32* %4
br label %22
13: ; preds = %3
%14 = load i32, i32* %5
%15 = call i32 @ata_wait(i32 %14, i32 8, i32 8)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13
store i32 0, i32* %4
br label %22
18: ; preds = %13
%19 = load i32, i32* %5
%20 = load i8*, i8** %7
%21 = call i32 @ata_pio_read(i32 %19, i8* %20, i32 512)
store i32 1, i32* %4
br label %22
22: ; preds = %18, %17, %12
%23 = load i32, i32* %4
ret i32 %23
}

LLVM IR (-O2):
define i32 @ata_identify(i32 %0, i32 %1, i8* %2) {
%4 = tail call i32 @ata_begin(i32 %0, i32 %1, i32 0, i32 0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i32 @ata_wait(i32 %0, i32 8, i32 8)
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @ata_pio_read(i32 %0, i8* %2, i32 512)
br label %11
11: ; preds = %6, %3, %9
%12 = phi i32 [ 1, %9 ], [ 0, %3 ], [ 0, %6 ]
ret i32 %12
}