#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*/ ide_activate();
scalar_t__ ide_wait_ready();
int ide_init() {
  ide_activate();
  if (ide_wait_ready())
    return -1;
  ((*((volatile unsigned char *)(0xA05F7000 + 0x084))) = (0x03));
  ((*((volatile unsigned char *)(0xA05F7000 + 0x088))) = (0x0B));
  ((*((volatile unsigned char *)(0xA05F7000 + 0x09C))) = (0xEF));
  if (ide_wait_ready())
    return -1;
  ((*((volatile unsigned long *)(0xA05F7490))) = (0x222));
  ((*((volatile unsigned long *)(0xA05F7494))) = (0x222));
  ((*((volatile unsigned char *)(0xA05F7000 + 0x084))) = (0x03));
  ((*((volatile unsigned char *)(0xA05F7000 + 0x088))) = (0x22));
  ((*((volatile unsigned char *)(0xA05F7000 + 0x09C))) = (0xEF));
  if (ide_wait_ready())
    return -1;
  ((*((volatile unsigned short *)(0xA05F7480))) = (0x400));
  ((*((volatile unsigned long *)(0xA05F7488))) = (0x200));
  ((*((volatile unsigned long *)(0xA05F748C))) = (0x200));
  ((*((volatile unsigned long *)(0xA05F74A0))) = (0x2001));
  ((*((volatile unsigned long *)(0xA05F74A4))) = (0x2001));
  ((*((volatile unsigned long *)(0xA05F74B4))) = (0x0001));
}


x86 assembly (clang, -O0):
<ide_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <ide_activate@plt>
mov    $0x0,%al
call   1030 <ide_wait_ready@plt>
cmp    $0x0,%rax
je     114c <ide_init+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1214 <ide_init+0xf4>
mov    $0xa05f7084,%eax
movb   $0x3,(%rax)
mov    $0xa05f7088,%eax
movb   $0xb,(%rax)
mov    $0xa05f709c,%eax
movb   $0xef,(%rax)
mov    $0x0,%al
call   1030 <ide_wait_ready@plt>
cmp    $0x0,%rax
je     1181 <ide_init+0x61>
movl   $0xffffffff,-0x4(%rbp)
jmp    1214 <ide_init+0xf4>
mov    $0xa05f7490,%eax
movq   $0x222,(%rax)
mov    $0xa05f7494,%eax
movq   $0x222,(%rax)
mov    $0xa05f7084,%eax
movb   $0x3,(%rax)
mov    $0xa05f7088,%eax
movb   $0x22,(%rax)
mov    $0xa05f709c,%eax
movb   $0xef,(%rax)
mov    $0x0,%al
call   1030 <ide_wait_ready@plt>
cmp    $0x0,%rax
je     11ce <ide_init+0xae>
movl   $0xffffffff,-0x4(%rbp)
jmp    1214 <ide_init+0xf4>
mov    $0xa05f7480,%eax
movw   $0x400,(%rax)
mov    $0xa05f7488,%eax
movq   $0x200,(%rax)
mov    $0xa05f748c,%eax
movq   $0x200,(%rax)
mov    $0xa05f74a0,%eax
movq   $0x2001,(%rax)
mov    $0xa05f74a4,%eax
movq   $0x2001,(%rax)
mov    $0xa05f74b4,%eax
movq   $0x1,(%rax)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ide_init>:
push   %rbx
xor    %eax,%eax
call   1040 <ide_activate@plt>
xor    %eax,%eax
call   1030 <ide_wait_ready@plt>
test   %rax,%rax
jne    11c1 <ide_init+0xa1>
mov    $0xa05f7084,%ebx
movb   $0x3,(%rbx)
movb   $0xb,0x4(%rbx)
movb   $0xef,0x18(%rbx)
xor    %eax,%eax
call   1030 <ide_wait_ready@plt>
test   %rax,%rax
jne    11c1 <ide_init+0xa1>
movq   $0x222,0x40c(%rbx)
movq   $0x222,0x410(%rbx)
movb   $0x3,(%rbx)
movb   $0x22,0x4(%rbx)
movb   $0xef,0x18(%rbx)
xor    %eax,%eax
call   1030 <ide_wait_ready@plt>
test   %rax,%rax
jne    11c1 <ide_init+0xa1>
movw   $0x400,0x3fc(%rbx)
movq   $0x200,0x404(%rbx)
movq   $0x200,0x408(%rbx)
movq   $0x2001,0x41c(%rbx)
movq   $0x2001,0x420(%rbx)
movq   $0x1,0x430(%rbx)
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @ide_init() {
%1 = alloca i32
%2 = call i32 (...) @ide_activate()
%3 = call i64 (...) @ide_wait_ready()
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 -1, i32* %1
br label %15
6: ; preds = %0
store volatile i8 3, i8* inttoptr (i64 2690609284 to i8*)
store volatile i8 11, i8* inttoptr (i64 2690609288 to i8*)
store volatile i8 -17, i8* inttoptr (i64 2690609308 to i8*)
%7 = call i64 (...) @ide_wait_ready()
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %6
store i32 -1, i32* %1
br label %15
10: ; preds = %6
store volatile i64 546, i64* inttoptr (i64 2690610320 to i64*)
store volatile i64 546, i64* inttoptr (i64 2690610324 to i64*)
store volatile i8 3, i8* inttoptr (i64 2690609284 to i8*)
store volatile i8 34, i8* inttoptr (i64 2690609288 to i8*)
store volatile i8 -17, i8* inttoptr (i64 2690609308 to i8*)
%11 = call i64 (...) @ide_wait_ready()
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 -1, i32* %1
br label %15
14: ; preds = %10
store volatile i16 1024, i16* inttoptr (i64 2690610304 to i16*)
store volatile i64 512, i64* inttoptr (i64 2690610312 to i64*)
store volatile i64 512, i64* inttoptr (i64 2690610316 to i64*)
store volatile i64 8193, i64* inttoptr (i64 2690610336 to i64*)
store volatile i64 8193, i64* inttoptr (i64 2690610340 to i64*)
store volatile i64 1, i64* inttoptr (i64 2690610356 to i64*)
br label %15
15: ; preds = %14, %13, %9, %5
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
define i32 @ide_init() {
%1 = tail call i32 (...) @ide_activate()
%2 = tail call i64 (...) @ide_wait_ready()
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %11
4: ; preds = %0
store volatile i8 3, i8* inttoptr (i64 2690609284 to i8*)
store volatile i8 11, i8* inttoptr (i64 2690609288 to i8*)
store volatile i8 -17, i8* inttoptr (i64 2690609308 to i8*)
%5 = tail call i64 (...) @ide_wait_ready()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %4
store volatile i64 546, i64* inttoptr (i64 2690610320 to i64*)
store volatile i64 546, i64* inttoptr (i64 2690610324 to i64*)
store volatile i8 3, i8* inttoptr (i64 2690609284 to i8*)
store volatile i8 34, i8* inttoptr (i64 2690609288 to i8*)
store volatile i8 -17, i8* inttoptr (i64 2690609308 to i8*)
%8 = tail call i64 (...) @ide_wait_ready()
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %7
store volatile i16 1024, i16* inttoptr (i64 2690610304 to i16*)
store volatile i64 512, i64* inttoptr (i64 2690610312 to i64*)
store volatile i64 512, i64* inttoptr (i64 2690610316 to i64*)
store volatile i64 8193, i64* inttoptr (i64 2690610336 to i64*)
store volatile i64 8193, i64* inttoptr (i64 2690610340 to i64*)
store volatile i64 1, i64* inttoptr (i64 2690610356 to i64*)
br label %11
11: ; preds = %7, %4, %0, %10
ret i32 -1
}