unsigned int mmc_write(unsigned int sector, const void *buf) {
  unsigned int i;
  const unsigned int *src = buf;
  volatile unsigned int *write_sector =
      ((void *)((char *)(0x0404b200 << 2) + (2 << 2)));
  volatile unsigned int *hard_buf =
      ((void *)((char *)(0x0404b200 << 2) + (0x10 << 2)));
  for (i = 0; i < 512 >> 2; i++) {
    *hard_buf++ = *src++;
  }
  *write_sector = sector;
  return *(volatile unsigned int *)((void *)((char *)(0x0404b200 << 2) +
                                             (0xf << 2)));
}


x86 assembly (clang, -O0):
<mmc_write>:
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    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    $0x1012c800,%eax
add    $0x40,%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x80,-0x14(%rbp)
jae    1171 <mmc_write+0x71>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x30(%rbp)
mov    %ecx,(%rax)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1134 <mmc_write+0x34>
mov    -0x4(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x1012c800,%eax
mov    0x3c(%rax),%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @mmc_write(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 8) to i32*), i32** %7
store i32* bitcast (i8* getelementptr inbounds (i8, i8* inttoptr (i64 269666304 to i8*), i64 64) to i32*), i32** %8
store i32 0, i32* %5
br label %11
11: ; preds = %20, %2
%12 = load i32, i32* %5
%13 = icmp ult i32 %12, 128
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load i32*, i32** %6
%16 = getelementptr inbounds i32, i32* %15, i32 1
store i32* %16, i32** %6
%17 = load i32, i32* %15
%18 = load i32*, i32** %8
%19 = getelementptr inbounds i32, i32* %18, i32 1
store i32* %19, i32** %8
store volatile i32 %17, i32* %18
br label %20
20: ; preds = %14
%21 = load i32, i32* %5
%22 = add i32 %21, 1
store i32 %22, i32* %5
br label %11
23: ; preds = %11
%24 = load i32, i32* %3
%25 = load i32*, i32** %7
store volatile i32 %24, i32* %25
%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_write(i32 %0, i8* nocapture %1) {
%3 = bitcast i8* %1 to i32*
br label %4
4: ; preds = %4, %2
%5 = phi i32* [ inttoptr (i64 269666368 to i32*), %2 ], [ %31, %4 ]
%6 = phi i32 [ 0, %2 ], [ %32, %4 ]
%7 = phi i32* [ %3, %2 ], [ %29, %4 ]
%8 = getelementptr inbounds i32, i32* %7, i64 1
%9 = load i32, i32* %7
%10 = getelementptr inbounds i32, i32* %5, i64 1
store volatile i32 %9, i32* %5
%11 = getelementptr inbounds i32, i32* %7, i64 2
%12 = load i32, i32* %8
%13 = getelementptr inbounds i32, i32* %5, i64 2
store volatile i32 %12, i32* %10
%14 = getelementptr inbounds i32, i32* %7, i64 3
%15 = load i32, i32* %11
%16 = getelementptr inbounds i32, i32* %5, i64 3
store volatile i32 %15, i32* %13
%17 = getelementptr inbounds i32, i32* %7, i64 4
%18 = load i32, i32* %14
%19 = getelementptr inbounds i32, i32* %5, i64 4
store volatile i32 %18, i32* %16
%20 = getelementptr inbounds i32, i32* %7, i64 5
%21 = load i32, i32* %17
%22 = getelementptr inbounds i32, i32* %5, i64 5
store volatile i32 %21, i32* %19
%23 = getelementptr inbounds i32, i32* %7, i64 6
%24 = load i32, i32* %20
%25 = getelementptr inbounds i32, i32* %5, i64 6
store volatile i32 %24, i32* %22
%26 = getelementptr inbounds i32, i32* %7, i64 7
%27 = load i32, i32* %23
%28 = getelementptr inbounds i32, i32* %5, i64 7
store volatile i32 %27, i32* %25
%29 = getelementptr inbounds i32, i32* %7, i64 8
%30 = load i32, i32* %26
%31 = getelementptr inbounds i32, i32* %5, i64 8
store volatile 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
store volatile i32 %0, i32* inttoptr (i64 269666312 to i32*)
%35 = load volatile i32, i32* inttoptr (i64 269666364 to i32*)
ret i32 %35
}