int rom_readsect(int lba, char *buf) {
  int i;
  for (i = 0; i < 512; i++)
    buf[i] = ((char *)0xBF000000)[lba * 512 + i];
  return 0;
}


x86 assembly (clang, -O0):
<rom_readsect>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x200,-0x14(%rbp)
jge    114c <rom_readsect+0x4c>
mov    -0x4(%rbp),%eax
shl    $0x9,%eax
add    -0x14(%rbp),%eax
movslq %eax,%rcx
mov    $0xbf000000,%eax
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1112 <rom_readsect+0x12>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rom_readsect>:
mov    $0xbf000000,%eax
movslq %edi,%rcx
shl    $0x9,%rcx
lea    (%rcx,%rax,1),%rdx
add    $0x200,%rdx
cmp    %rsi,%rdx
jbe    1172 <rom_readsect+0x72>
lea    0x200(%rsi),%rdx
lea    (%rcx,%rax,1),%rdi
cmp    %rdx,%rdi
jae    1172 <rom_readsect+0x72>
add    %rcx,%rax
add    $0x3,%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl -0x3(%rax,%rcx,1),%edx
mov    %dl,(%rsi,%rcx,1)
movzbl -0x2(%rax,%rcx,1),%edx
mov    %dl,0x1(%rsi,%rcx,1)
movzbl -0x1(%rax,%rcx,1),%edx
mov    %dl,0x2(%rsi,%rcx,1)
movzbl (%rax,%rcx,1),%edx
mov    %dl,0x3(%rsi,%rcx,1)
add    $0x4,%rcx
cmp    $0x200,%rcx
jne    1140 <rom_readsect+0x40>
xor    %eax,%eax
ret
movaps (%rax,%rcx,1),%xmm0
movaps 0x10(%rax,%rcx,1),%xmm1
movups %xmm0,(%rsi)
movups %xmm1,0x10(%rsi)
mov    %rcx,%rdx
or     $0x20,%rdx
movaps (%rax,%rdx,1),%xmm0
movaps 0x10(%rax,%rdx,1),%xmm1
movups %xmm0,0x20(%rsi)
movups %xmm1,0x30(%rsi)
mov    %rcx,%rdx
or     $0x40,%rdx
movaps (%rax,%rdx,1),%xmm0
movaps 0x10(%rax,%rdx,1),%xmm1
movups %xmm0,0x40(%rsi)
movups %xmm1,0x50(%rsi)
mov    %rcx,%rdx
or     $0x60,%rdx
movaps (%rax,%rdx,1),%xmm0
movaps 0x10(%rax,%rdx,1),%xmm1
movups %xmm0,0x60(%rsi)
movups %xmm1,0x70(%rsi)
mov    %rcx,%rdx
or     $0x80,%rdx
movaps (%rax,%rdx,1),%xmm0
movaps 0x10(%rax,%rdx,1),%xmm1
movups %xmm0,0x80(%rsi)
movups %xmm1,0x90(%rsi)
mov    %rcx,%rdx
or     $0xa0,%rdx
movaps (%rax,%rdx,1),%xmm0
movaps 0x10(%rax,%rdx,1),%xmm1
movups %xmm0,0xa0(%rsi)
movups %xmm1,0xb0(%rsi)
mov    %rcx,%rdx
or     $0xc0,%rdx
movaps (%rax,%rdx,1),%xmm0
movaps 0x10(%rax,%rdx,1),%xmm1
movups %xmm0,0xc0(%rsi)
movups %xmm1,0xd0(%rsi)
mov    %rcx,%rdx
or     $0xe0,%rdx
movaps (%rax,%rdx,1),%xmm0
movaps 0x10(%rax,%rdx,1),%xmm1
movups %xmm0,0xe0(%rsi)
movups %xmm1,0xf0(%rsi)
mov    %rcx,%rdx
or     $0x100,%rdx
movaps (%rax,%rdx,1),%xmm0
movaps 0x10(%rax,%rdx,1),%xmm1
movups %xmm0,0x100(%rsi)
movups %xmm1,0x110(%rsi)
mov    %rcx,%rdx
or     $0x120,%rdx
movaps (%rax,%rdx,1),%xmm0
movaps 0x10(%rax,%rdx,1),%xmm1
movups %xmm0,0x120(%rsi)
movups %xmm1,0x130(%rsi)
mov    %rcx,%rdx
or     $0x140,%rdx
movaps (%rax,%rdx,1),%xmm0
movaps 0x10(%rax,%rdx,1),%xmm1
movups %xmm0,0x140(%rsi)
movups %xmm1,0x150(%rsi)
mov    %rcx,%rdx
or     $0x160,%rdx
movaps (%rax,%rdx,1),%xmm0
movaps 0x10(%rax,%rdx,1),%xmm1
movups %xmm0,0x160(%rsi)
movups %xmm1,0x170(%rsi)
mov    %rcx,%rdx
or     $0x180,%rdx
movaps (%rax,%rdx,1),%xmm0
movaps 0x10(%rax,%rdx,1),%xmm1
movups %xmm0,0x180(%rsi)
movups %xmm1,0x190(%rsi)
mov    %rcx,%rdx
or     $0x1a0,%rdx
movaps (%rax,%rdx,1),%xmm0
movaps 0x10(%rax,%rdx,1),%xmm1
movups %xmm0,0x1a0(%rsi)
movups %xmm1,0x1b0(%rsi)
mov    %rcx,%rdx
or     $0x1c0,%rdx
movaps (%rax,%rdx,1),%xmm0
movaps 0x10(%rax,%rdx,1),%xmm1
movups %xmm0,0x1c0(%rsi)
movups %xmm1,0x1d0(%rsi)
or     $0x1e0,%rcx
movaps (%rax,%rcx,1),%xmm0
movaps 0x10(%rax,%rcx,1),%xmm1
movups %xmm0,0x1e0(%rsi)
movups %xmm1,0x1f0(%rsi)
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @rom_readsect(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %21, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 512
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = load i32, i32* %3
%11 = mul nsw i32 %10, 512
%12 = load i32, i32* %5
%13 = add nsw i32 %11, %12
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %14
%16 = load i8, i8* %15
%17 = load i8*, i8** %4
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 %16, i8* %20
br label %21
21: ; preds = %9
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %6
24: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
define i32 @rom_readsect(i32 %0, i8* nocapture writeonly %1) {
%3 = shl nsw i32 %0, 9
%4 = sext i32 %3 to i64
%5 = getelementptr i8, i8* %1, i64 512
%6 = getelementptr i8, i8* inttoptr (i64 3204448256 to i8*), i64 %4
%7 = add nsw i64 %4, 512
%8 = getelementptr i8, i8* inttoptr (i64 3204448256 to i8*), i64 %7
%9 = icmp ugt i8* %8, %1
%10 = icmp ult i8* %6, %5
%11 = and i1 %9, %10
br i1 %11, label %187, label %12
12: ; preds = %2
%13 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %4
%14 = bitcast i8* %13 to <16 x i8>*
%15 = load <16 x i8>, <16 x i8>* %14
%16 = getelementptr inbounds i8, i8* %13, i64 16
%17 = bitcast i8* %16 to <16 x i8>*
%18 = load <16 x i8>, <16 x i8>* %17
%19 = bitcast i8* %1 to <16 x i8>*
store <16 x i8> %15, <16 x i8>* %19
%20 = getelementptr inbounds i8, i8* %1, i64 16
%21 = bitcast i8* %20 to <16 x i8>*
store <16 x i8> %18, <16 x i8>* %21
%22 = or i64 %4, 32
%23 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %22
%24 = bitcast i8* %23 to <16 x i8>*
%25 = load <16 x i8>, <16 x i8>* %24
%26 = getelementptr inbounds i8, i8* %23, i64 16
%27 = bitcast i8* %26 to <16 x i8>*
%28 = load <16 x i8>, <16 x i8>* %27
%29 = getelementptr inbounds i8, i8* %1, i64 32
%30 = bitcast i8* %29 to <16 x i8>*
store <16 x i8> %25, <16 x i8>* %30
%31 = getelementptr inbounds i8, i8* %1, i64 48
%32 = bitcast i8* %31 to <16 x i8>*
store <16 x i8> %28, <16 x i8>* %32
%33 = or i64 %4, 64
%34 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %33
%35 = bitcast i8* %34 to <16 x i8>*
%36 = load <16 x i8>, <16 x i8>* %35
%37 = getelementptr inbounds i8, i8* %34, i64 16
%38 = bitcast i8* %37 to <16 x i8>*
%39 = load <16 x i8>, <16 x i8>* %38
%40 = getelementptr inbounds i8, i8* %1, i64 64
%41 = bitcast i8* %40 to <16 x i8>*
store <16 x i8> %36, <16 x i8>* %41
%42 = getelementptr inbounds i8, i8* %1, i64 80
%43 = bitcast i8* %42 to <16 x i8>*
store <16 x i8> %39, <16 x i8>* %43
%44 = or i64 %4, 96
%45 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %44
%46 = bitcast i8* %45 to <16 x i8>*
%47 = load <16 x i8>, <16 x i8>* %46
%48 = getelementptr inbounds i8, i8* %45, i64 16
%49 = bitcast i8* %48 to <16 x i8>*
%50 = load <16 x i8>, <16 x i8>* %49
%51 = getelementptr inbounds i8, i8* %1, i64 96
%52 = bitcast i8* %51 to <16 x i8>*
store <16 x i8> %47, <16 x i8>* %52
%53 = getelementptr inbounds i8, i8* %1, i64 112
%54 = bitcast i8* %53 to <16 x i8>*
store <16 x i8> %50, <16 x i8>* %54
%55 = or i64 %4, 128
%56 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %55
%57 = bitcast i8* %56 to <16 x i8>*
%58 = load <16 x i8>, <16 x i8>* %57
%59 = getelementptr inbounds i8, i8* %56, i64 16
%60 = bitcast i8* %59 to <16 x i8>*
%61 = load <16 x i8>, <16 x i8>* %60
%62 = getelementptr inbounds i8, i8* %1, i64 128
%63 = bitcast i8* %62 to <16 x i8>*
store <16 x i8> %58, <16 x i8>* %63
%64 = getelementptr inbounds i8, i8* %1, i64 144
%65 = bitcast i8* %64 to <16 x i8>*
store <16 x i8> %61, <16 x i8>* %65
%66 = or i64 %4, 160
%67 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %66
%68 = bitcast i8* %67 to <16 x i8>*
%69 = load <16 x i8>, <16 x i8>* %68
%70 = getelementptr inbounds i8, i8* %67, i64 16
%71 = bitcast i8* %70 to <16 x i8>*
%72 = load <16 x i8>, <16 x i8>* %71
%73 = getelementptr inbounds i8, i8* %1, i64 160
%74 = bitcast i8* %73 to <16 x i8>*
store <16 x i8> %69, <16 x i8>* %74
%75 = getelementptr inbounds i8, i8* %1, i64 176
%76 = bitcast i8* %75 to <16 x i8>*
store <16 x i8> %72, <16 x i8>* %76
%77 = or i64 %4, 192
%78 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %77
%79 = bitcast i8* %78 to <16 x i8>*
%80 = load <16 x i8>, <16 x i8>* %79
%81 = getelementptr inbounds i8, i8* %78, i64 16
%82 = bitcast i8* %81 to <16 x i8>*
%83 = load <16 x i8>, <16 x i8>* %82
%84 = getelementptr inbounds i8, i8* %1, i64 192
%85 = bitcast i8* %84 to <16 x i8>*
store <16 x i8> %80, <16 x i8>* %85
%86 = getelementptr inbounds i8, i8* %1, i64 208
%87 = bitcast i8* %86 to <16 x i8>*
store <16 x i8> %83, <16 x i8>* %87
%88 = or i64 %4, 224
%89 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %88
%90 = bitcast i8* %89 to <16 x i8>*
%91 = load <16 x i8>, <16 x i8>* %90
%92 = getelementptr inbounds i8, i8* %89, i64 16
%93 = bitcast i8* %92 to <16 x i8>*
%94 = load <16 x i8>, <16 x i8>* %93
%95 = getelementptr inbounds i8, i8* %1, i64 224
%96 = bitcast i8* %95 to <16 x i8>*
store <16 x i8> %91, <16 x i8>* %96
%97 = getelementptr inbounds i8, i8* %1, i64 240
%98 = bitcast i8* %97 to <16 x i8>*
store <16 x i8> %94, <16 x i8>* %98
%99 = or i64 %4, 256
%100 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %99
%101 = bitcast i8* %100 to <16 x i8>*
%102 = load <16 x i8>, <16 x i8>* %101
%103 = getelementptr inbounds i8, i8* %100, i64 16
%104 = bitcast i8* %103 to <16 x i8>*
%105 = load <16 x i8>, <16 x i8>* %104
%106 = getelementptr inbounds i8, i8* %1, i64 256
%107 = bitcast i8* %106 to <16 x i8>*
store <16 x i8> %102, <16 x i8>* %107
%108 = getelementptr inbounds i8, i8* %1, i64 272
%109 = bitcast i8* %108 to <16 x i8>*
store <16 x i8> %105, <16 x i8>* %109
%110 = or i64 %4, 288
%111 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %110
%112 = bitcast i8* %111 to <16 x i8>*
%113 = load <16 x i8>, <16 x i8>* %112
%114 = getelementptr inbounds i8, i8* %111, i64 16
%115 = bitcast i8* %114 to <16 x i8>*
%116 = load <16 x i8>, <16 x i8>* %115
%117 = getelementptr inbounds i8, i8* %1, i64 288
%118 = bitcast i8* %117 to <16 x i8>*
store <16 x i8> %113, <16 x i8>* %118
%119 = getelementptr inbounds i8, i8* %1, i64 304
%120 = bitcast i8* %119 to <16 x i8>*
store <16 x i8> %116, <16 x i8>* %120
%121 = or i64 %4, 320
%122 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %121
%123 = bitcast i8* %122 to <16 x i8>*
%124 = load <16 x i8>, <16 x i8>* %123
%125 = getelementptr inbounds i8, i8* %122, i64 16
%126 = bitcast i8* %125 to <16 x i8>*
%127 = load <16 x i8>, <16 x i8>* %126
%128 = getelementptr inbounds i8, i8* %1, i64 320
%129 = bitcast i8* %128 to <16 x i8>*
store <16 x i8> %124, <16 x i8>* %129
%130 = getelementptr inbounds i8, i8* %1, i64 336
%131 = bitcast i8* %130 to <16 x i8>*
store <16 x i8> %127, <16 x i8>* %131
%132 = or i64 %4, 352
%133 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %132
%134 = bitcast i8* %133 to <16 x i8>*
%135 = load <16 x i8>, <16 x i8>* %134
%136 = getelementptr inbounds i8, i8* %133, i64 16
%137 = bitcast i8* %136 to <16 x i8>*
%138 = load <16 x i8>, <16 x i8>* %137
%139 = getelementptr inbounds i8, i8* %1, i64 352
%140 = bitcast i8* %139 to <16 x i8>*
store <16 x i8> %135, <16 x i8>* %140
%141 = getelementptr inbounds i8, i8* %1, i64 368
%142 = bitcast i8* %141 to <16 x i8>*
store <16 x i8> %138, <16 x i8>* %142
%143 = or i64 %4, 384
%144 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %143
%145 = bitcast i8* %144 to <16 x i8>*
%146 = load <16 x i8>, <16 x i8>* %145
%147 = getelementptr inbounds i8, i8* %144, i64 16
%148 = bitcast i8* %147 to <16 x i8>*
%149 = load <16 x i8>, <16 x i8>* %148
%150 = getelementptr inbounds i8, i8* %1, i64 384
%151 = bitcast i8* %150 to <16 x i8>*
store <16 x i8> %146, <16 x i8>* %151
%152 = getelementptr inbounds i8, i8* %1, i64 400
%153 = bitcast i8* %152 to <16 x i8>*
store <16 x i8> %149, <16 x i8>* %153
%154 = or i64 %4, 416
%155 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %154
%156 = bitcast i8* %155 to <16 x i8>*
%157 = load <16 x i8>, <16 x i8>* %156
%158 = getelementptr inbounds i8, i8* %155, i64 16
%159 = bitcast i8* %158 to <16 x i8>*
%160 = load <16 x i8>, <16 x i8>* %159
%161 = getelementptr inbounds i8, i8* %1, i64 416
%162 = bitcast i8* %161 to <16 x i8>*
store <16 x i8> %157, <16 x i8>* %162
%163 = getelementptr inbounds i8, i8* %1, i64 432
%164 = bitcast i8* %163 to <16 x i8>*
store <16 x i8> %160, <16 x i8>* %164
%165 = or i64 %4, 448
%166 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %165
%167 = bitcast i8* %166 to <16 x i8>*
%168 = load <16 x i8>, <16 x i8>* %167
%169 = getelementptr inbounds i8, i8* %166, i64 16
%170 = bitcast i8* %169 to <16 x i8>*
%171 = load <16 x i8>, <16 x i8>* %170
%172 = getelementptr inbounds i8, i8* %1, i64 448
%173 = bitcast i8* %172 to <16 x i8>*
store <16 x i8> %168, <16 x i8>* %173
%174 = getelementptr inbounds i8, i8* %1, i64 464
%175 = bitcast i8* %174 to <16 x i8>*
store <16 x i8> %171, <16 x i8>* %175
%176 = or i64 %4, 480
%177 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %176
%178 = bitcast i8* %177 to <16 x i8>*
%179 = load <16 x i8>, <16 x i8>* %178
%180 = getelementptr inbounds i8, i8* %177, i64 16
%181 = bitcast i8* %180 to <16 x i8>*
%182 = load <16 x i8>, <16 x i8>* %181
%183 = getelementptr inbounds i8, i8* %1, i64 480
%184 = bitcast i8* %183 to <16 x i8>*
store <16 x i8> %179, <16 x i8>* %184
%185 = getelementptr inbounds i8, i8* %1, i64 496
%186 = bitcast i8* %185 to <16 x i8>*
store <16 x i8> %182, <16 x i8>* %186
br label %210
187: ; preds = %2, %187
%188 = phi i64 [ %208, %187 ], [ 0, %2 ]
%189 = add nuw nsw i64 %188, %4
%190 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %189
%191 = load i8, i8* %190
%192 = getelementptr inbounds i8, i8* %1, i64 %188
store i8 %191, i8* %192
%193 = or i64 %188, 1
%194 = add nuw nsw i64 %193, %4
%195 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %194
%196 = load i8, i8* %195
%197 = getelementptr inbounds i8, i8* %1, i64 %193
store i8 %196, i8* %197
%198 = or i64 %188, 2
%199 = add nuw nsw i64 %198, %4
%200 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %199
%201 = load i8, i8* %200
%202 = getelementptr inbounds i8, i8* %1, i64 %198
store i8 %201, i8* %202
%203 = or i64 %188, 3
%204 = add nuw nsw i64 %203, %4
%205 = getelementptr inbounds i8, i8* inttoptr (i64 3204448256 to i8*), i64 %204
%206 = load i8, i8* %205
%207 = getelementptr inbounds i8, i8* %1, i64 %203
store i8 %206, i8* %207
%208 = add nuw nsw i64 %188, 4
%209 = icmp eq i64 %208, 512
br i1 %209, label %210, label %187
210: ; preds = %187, %12
ret i32 0
}