unsigned int mmc_read(unsigned int sector, void *buf) {
  unsigned int i;
  unsigned int *dest = buf;
  volatile unsigned int *read_sector =
      ((void *)((char *)(0x0404b200 << 2) + (1 << 2)));
  volatile unsigned int *hard_buf =
      ((void *)((char *)(0x0404b200 << 2) + (0x10 << 2)));
  *read_sector = sector;
  for (i = 0; i < 512 >> 2; i++) {
    *dest++ = *hard_buf++;
  }
  return *(volatile unsigned int *)((void *)((char *)(0x0404b200 << 2) +
                                             (0xf << 2)));
}


x86 assembly (clang, -O0):
<mmc_read>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x1012c800,%eax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    $0x1012c800,%eax
add    $0x40,%rax
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x14(%rbp)
cmpl   $0x80,-0x14(%rbp)
jae    117a <mmc_read+0x7a>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x20(%rbp)
mov    %ecx,(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <mmc_read+0x3d>
mov    $0x1012c800,%eax
mov    0x3c(%rax),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mmc_read>:
mov    %edi,0x1012c804
xor    %eax,%eax
nopl   0x0(%rax)
mov    0x1012c840(,%rax,4),%ecx
mov    %ecx,(%rsi,%rax,4)
mov    0x1012c844(,%rax,4),%ecx
mov    %ecx,0x4(%rsi,%rax,4)
mov    0x1012c848(,%rax,4),%ecx
mov    %ecx,0x8(%rsi,%rax,4)
mov    0x1012c84c(,%rax,4),%ecx
mov    %ecx,0xc(%rsi,%rax,4)
mov    0x1012c850(,%rax,4),%ecx
mov    %ecx,0x10(%rsi,%rax,4)
mov    0x1012c854(,%rax,4),%ecx
mov    %ecx,0x14(%rsi,%rax,4)
mov    0x1012c858(,%rax,4),%ecx
mov    %ecx,0x18(%rsi,%rax,4)
mov    0x1012c85c(,%rax,4),%ecx
mov    %ecx,0x1c(%rsi,%rax,4)
add    $0x8,%rax
cmp    $0x80,%eax
jne    1110 <mmc_read+0x10>
mov    0x1012c83c,%eax
ret

LLVM IR (-O0):
define i32 @mmc_read(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
store i32 %0, i32* %3
store i8* %1, i8** %4
%9 = load i8*, i8** %4
%10 = bitcast i8* %9 to i32*
store i32* %10, i32** %6
store i32* bitcast (i8* getelementptr inbounds (i8, i8* inttoptr (i64 269666304 to i8*), i64 4) to i32*), i32** %7
store i32* bitcast (i8* getelementptr inbounds (i8, i8* inttoptr (i64 269666304 to i8*), i64 64) to i32*), i32** %8
%11 = load i32, i32* %3
%12 = load i32*, i32** %7
store volatile i32 %11, i32* %12
store i32 0, i32* %5
br label %13
13: ; preds = %22, %2
%14 = load i32, i32* %5
%15 = icmp ult i32 %14, 128
br i1 %15, label %16, label %25
16: ; preds = %13
%17 = load i32*, i32** %8
%18 = getelementptr inbounds i32, i32* %17, i32 1
store i32* %18, i32** %8
%19 = load volatile i32, i32* %17
%20 = load i32*, i32** %6
%21 = getelementptr inbounds i32, i32* %20, i32 1
store i32* %21, i32** %6
store i32 %19, i32* %20
br label %22
22: ; preds = %16
%23 = load i32, i32* %5
%24 = add i32 %23, 1
store i32 %24, i32* %5
br label %13
25: ; preds = %13
%26 = load volatile i32, i32* bitcast (i8* getelementptr inbounds (i8, i8* inttoptr (i64 269666304 to i8*), i64 60) to i32*)
ret i32 %26
}

LLVM IR (-O2):
define i32 @mmc_read(i32 %0, i8* nocapture writeonly %1) {
%3 = bitcast i8* %1 to i32*
store volatile i32 %0, i32* inttoptr (i64 269666308 to i32*)
br label %4
4: ; preds = %4, %2
%5 = phi i32* [ inttoptr (i64 269666368 to i32*), %2 ], [ %29, %4 ]
%6 = phi i32 [ 0, %2 ], [ %32, %4 ]
%7 = phi i32* [ %3, %2 ], [ %31, %4 ]
%8 = getelementptr inbounds i32, i32* %5, i64 1
%9 = load volatile i32, i32* %5
%10 = getelementptr inbounds i32, i32* %7, i64 1
store i32 %9, i32* %7
%11 = getelementptr inbounds i32, i32* %5, i64 2
%12 = load volatile i32, i32* %8
%13 = getelementptr inbounds i32, i32* %7, i64 2
store i32 %12, i32* %10
%14 = getelementptr inbounds i32, i32* %5, i64 3
%15 = load volatile i32, i32* %11
%16 = getelementptr inbounds i32, i32* %7, i64 3
store i32 %15, i32* %13
%17 = getelementptr inbounds i32, i32* %5, i64 4
%18 = load volatile i32, i32* %14
%19 = getelementptr inbounds i32, i32* %7, i64 4
store i32 %18, i32* %16
%20 = getelementptr inbounds i32, i32* %5, i64 5
%21 = load volatile i32, i32* %17
%22 = getelementptr inbounds i32, i32* %7, i64 5
store i32 %21, i32* %19
%23 = getelementptr inbounds i32, i32* %5, i64 6
%24 = load volatile i32, i32* %20
%25 = getelementptr inbounds i32, i32* %7, i64 6
store i32 %24, i32* %22
%26 = getelementptr inbounds i32, i32* %5, i64 7
%27 = load volatile i32, i32* %23
%28 = getelementptr inbounds i32, i32* %7, i64 7
store i32 %27, i32* %25
%29 = getelementptr inbounds i32, i32* %5, i64 8
%30 = load volatile i32, i32* %26
%31 = getelementptr inbounds i32, i32* %7, i64 8
store i32 %30, i32* %28
%32 = add nuw nsw i32 %6, 8
%33 = icmp eq i32 %32, 128
br i1 %33, label %34, label %4
34: ; preds = %4
%35 = load volatile i32, i32* inttoptr (i64 269666364 to i32*)
ret i32 %35
}