#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 */
char D_Read();
int /*<<< orphan*/ D_Write(int);
void D_ReadRom(char *address) {
  char count;
  D_Write(0x33);
  for (count = 0; count < 8; count++) {
    address[count] = D_Read();
    address++;
  }
}


x86 assembly (clang, -O0):
<D_ReadRom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x33,%edi
call   1030 <D_Write@plt>
movb   $0x0,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x8,%eax
jge    1175 <D_ReadRom+0x55>
mov    $0x0,%al
call   1040 <D_Read@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movsbq -0x9(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x9(%rbp),%al
add    $0x1,%al
mov    %al,-0x9(%rbp)
jmp    113a <D_ReadRom+0x1a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<D_ReadRom>:
push   %rbx
mov    %rdi,%rbx
mov    $0x33,%edi
call   1030 <D_Write@plt>
xor    %eax,%eax
call   1040 <D_Read@plt>
mov    %al,(%rbx)
xor    %eax,%eax
call   1040 <D_Read@plt>
mov    %al,0x2(%rbx)
xor    %eax,%eax
call   1040 <D_Read@plt>
mov    %al,0x4(%rbx)
xor    %eax,%eax
call   1040 <D_Read@plt>
mov    %al,0x6(%rbx)
xor    %eax,%eax
call   1040 <D_Read@plt>
mov    %al,0x8(%rbx)
xor    %eax,%eax
call   1040 <D_Read@plt>
mov    %al,0xa(%rbx)
xor    %eax,%eax
call   1040 <D_Read@plt>
mov    %al,0xc(%rbx)
xor    %eax,%eax
call   1040 <D_Read@plt>
mov    %al,0xe(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @D_ReadRom(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
store i8* %0, i8** %2
%4 = call i32 @D_Write(i32 51)
store i8 0, i8* %3
br label %5
5: ; preds = %17, %1
%6 = load i8, i8* %3
%7 = sext i8 %6 to i32
%8 = icmp slt i32 %7, 8
br i1 %8, label %9, label %20
9: ; preds = %5
%10 = call signext i8 (...) @D_Read()
%11 = load i8*, i8** %2
%12 = load i8, i8* %3
%13 = sext i8 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
store i8 %10, i8* %14
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %2
br label %17
17: ; preds = %9
%18 = load i8, i8* %3
%19 = add i8 %18, 1
store i8 %19, i8* %3
br label %5
20: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @D_ReadRom(i8* nocapture writeonly %0) {
%2 = tail call i32 @D_Write(i32 51)
%3 = tail call signext i8 (...) @D_Read()
store i8 %3, i8* %0
%4 = tail call signext i8 (...) @D_Read()
%5 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %4, i8* %5
%6 = tail call signext i8 (...) @D_Read()
%7 = getelementptr inbounds i8, i8* %0, i64 4
store i8 %6, i8* %7
%8 = tail call signext i8 (...) @D_Read()
%9 = getelementptr inbounds i8, i8* %0, i64 6
store i8 %8, i8* %9
%10 = tail call signext i8 (...) @D_Read()
%11 = getelementptr inbounds i8, i8* %0, i64 8
store i8 %10, i8* %11
%12 = tail call signext i8 (...) @D_Read()
%13 = getelementptr inbounds i8, i8* %0, i64 10
store i8 %12, i8* %13
%14 = tail call signext i8 (...) @D_Read()
%15 = getelementptr inbounds i8, i8* %0, i64 12
store i8 %14, i8* %15
%16 = tail call signext i8 (...) @D_Read()
%17 = getelementptr inbounds i8, i8* %0, i64 14
store i8 %16, i8* %17
ret void
}