#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 ide_read_dma(char *, int);
int /*<<< orphan*/ ide_write_command_packet(char *, int);
int ide_do_packet_command_dma(char *cmd, char *buf, int length) {
  ((*((volatile unsigned long *)(0xFF000038))) = (0x10));
  ((*((volatile unsigned long *)(0xFF00003C))) = (0x10));
  ((*((volatile unsigned long *)(0xA05F7000 + 0x4B8))) = (0x8843407F));
  ((*((volatile unsigned long *)(0xA05F7000 + 0x404))) = ((unsigned int)buf));
  ((*((volatile unsigned long *)(0xA05F7000 + 0x408))) = (length));
  ((*((volatile unsigned long *)(0xA05F7000 + 0x40C))) = (1));
  ide_write_command_packet(cmd, 1);
  length = ide_read_dma(buf, length);
  return length;
}


x86 assembly (clang, -O0):
<ide_do_packet_command_dma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0xff000038,%eax
movq   $0x10,(%rax)
mov    $0xff00003c,%eax
movq   $0x10,(%rax)
mov    $0xa05f74b8,%eax
mov    $0x8843407f,%ecx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0xa05f7404,%eax
mov    %rcx,(%rax)
movslq -0x14(%rbp),%rcx
mov    $0xa05f7408,%eax
mov    %rcx,(%rax)
mov    $0xa05f740c,%eax
movq   $0x1,(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1030 <ide_write_command_packet@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <ide_read_dma@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ide_do_packet_command_dma>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    $0x8843407f,%eax
movq   $0x10,0x76bcbfb9(%rax)
movq   $0x10,0x76bcbfbd(%rax)
mov    %rax,0x181c3439(%rax)
mov    %r14d,%ecx
mov    %rcx,0x181c3385(%rax)
movslq %edx,%rbx
mov    %rbx,0x181c3389(%rax)
movq   $0x1,0x181c338d(%rax)
mov    $0x1,%esi
call   1030 <ide_write_command_packet@plt>
mov    %r14,%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <ide_read_dma@plt>

LLVM IR (-O0):
define i32 @ide_do_packet_command_dma(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store volatile i64 16, i64* inttoptr (i64 4278190136 to i64*)
store volatile i64 16, i64* inttoptr (i64 4278190140 to i64*)
store volatile i64 2286108799, i64* inttoptr (i64 2690610360 to i64*)
%7 = load i8*, i8** %5
%8 = ptrtoint i8* %7 to i32
%9 = zext i32 %8 to i64
store volatile i64 %9, i64* inttoptr (i64 2690610180 to i64*)
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
store volatile i64 %11, i64* inttoptr (i64 2690610184 to i64*)
store volatile i64 1, i64* inttoptr (i64 2690610188 to i64*)
%12 = load i8*, i8** %4
%13 = call i32 @ide_write_command_packet(i8* %12, i32 1)
%14 = load i8*, i8** %5
%15 = load i32, i32* %6
%16 = call i32 @ide_read_dma(i8* %14, i32 %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
ret i32 %17
}

LLVM IR (-O2):
define i32 @ide_do_packet_command_dma(i8* %0, i8* %1, i32 %2) {
store volatile i64 16, i64* inttoptr (i64 4278190136 to i64*)
store volatile i64 16, i64* inttoptr (i64 4278190140 to i64*)
store volatile i64 2286108799, i64* inttoptr (i64 2690610360 to i64*)
%4 = ptrtoint i8* %1 to i64
%5 = and i64 %4, 4294967295
store volatile i64 %5, i64* inttoptr (i64 2690610180 to i64*)
%6 = sext i32 %2 to i64
store volatile i64 %6, i64* inttoptr (i64 2690610184 to i64*)
store volatile i64 1, i64* inttoptr (i64 2690610188 to i64*)
%7 = tail call i32 @ide_write_command_packet(i8* %0, i32 1)
%8 = tail call i32 @ide_read_dma(i8* %1, i32 %2)
ret i32 %8
}