void copyToSdram(void) {
  unsigned int *dest = (unsigned int *)0x50004000;
  unsigned int *start = (unsigned int *)4096;
  unsigned int *end = (unsigned int *)(8 * 1024);
  while (start < end) {
    *(dest++) = *(start++);
  }
  return;
}


x86 assembly (clang, -O0):
<copyToSdram>:
push   %rbp
mov    %rsp,%rbp
mov    $0x50004000,%eax
mov    %rax,-0x8(%rbp)
mov    $0x1000,%eax
mov    %rax,-0x10(%rbp)
mov    $0x2000,%eax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1154 <copyToSdram+0x54>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
jmp    111f <copyToSdram+0x1f>
pop    %rbp
ret

x86 assembly (clang, -O2):
<copyToSdram>:
mov    $0x1070,%eax
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
movaps -0x70(%rax,%rcx,4),%xmm0
movaps -0x60(%rax,%rcx,4),%xmm1
movaps -0x50(%rax,%rcx,4),%xmm2
movaps -0x40(%rax,%rcx,4),%xmm3
movaps %xmm0,0x50002f90(%rax,%rcx,4)
50
movaps %xmm1,0x50002fa0(%rax,%rcx,4)
50
movaps %xmm2,0x50002fb0(%rax,%rcx,4)
50
movaps %xmm3,0x50002fc0(%rax,%rcx,4)
50
movaps -0x30(%rax,%rcx,4),%xmm0
movaps -0x20(%rax,%rcx,4),%xmm1
movaps %xmm0,0x50002fd0(%rax,%rcx,4)
50
movaps %xmm1,0x50002fe0(%rax,%rcx,4)
50
movaps -0x10(%rax,%rcx,4),%xmm0
movaps (%rax,%rcx,4),%xmm1
movaps %xmm0,0x50002ff0(%rax,%rcx,4)
50
movaps %xmm1,0x50003000(%rax,%rcx,4)
50
add    $0x20,%rcx
cmp    $0x400,%rcx
jne    1110 <copyToSdram+0x10>
ret

LLVM IR (-O0):
define void @copyToSdram() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca i32*
store i32* inttoptr (i64 1342193664 to i32*), i32** %1
store i32* inttoptr (i64 4096 to i32*), i32** %2
store i32* inttoptr (i64 8192 to i32*), i32** %3
br label %4
4: ; preds = %8, %0
%5 = load i32*, i32** %2
%6 = load i32*, i32** %3
%7 = icmp ult i32* %5, %6
br i1 %7, label %8, label %14
8: ; preds = %4
%9 = load i32*, i32** %2
%10 = getelementptr inbounds i32, i32* %9, i32 1
store i32* %10, i32** %2
%11 = load i32, i32* %9
%12 = load i32*, i32** %1
%13 = getelementptr inbounds i32, i32* %12, i32 1
store i32* %13, i32** %1
store i32 %11, i32* %12
br label %4
14: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @copyToSdram() {
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %46, %1 ]
%3 = getelementptr i32, i32* inttoptr (i64 1342193664 to i32*), i64 %2
%4 = getelementptr i32, i32* inttoptr (i64 4096 to i32*), i64 %2
%5 = bitcast i32* %4 to <4 x i32>*
%6 = load <4 x i32>, <4 x i32>* %5
%7 = getelementptr i32, i32* %4, i64 4
%8 = bitcast i32* %7 to <4 x i32>*
%9 = load <4 x i32>, <4 x i32>* %8
%10 = bitcast i32* %3 to <4 x i32>*
store <4 x i32> %6, <4 x i32>* %10
%11 = getelementptr i32, i32* %3, i64 4
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> %9, <4 x i32>* %12
%13 = or i64 %2, 8
%14 = getelementptr i32, i32* inttoptr (i64 1342193664 to i32*), i64 %13
%15 = getelementptr i32, i32* inttoptr (i64 4096 to i32*), i64 %13
%16 = bitcast i32* %15 to <4 x i32>*
%17 = load <4 x i32>, <4 x i32>* %16
%18 = getelementptr i32, i32* %15, i64 4
%19 = bitcast i32* %18 to <4 x i32>*
%20 = load <4 x i32>, <4 x i32>* %19
%21 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> %17, <4 x i32>* %21
%22 = getelementptr i32, i32* %14, i64 4
%23 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> %20, <4 x i32>* %23
%24 = or i64 %2, 16
%25 = getelementptr i32, i32* inttoptr (i64 1342193664 to i32*), i64 %24
%26 = getelementptr i32, i32* inttoptr (i64 4096 to i32*), i64 %24
%27 = bitcast i32* %26 to <4 x i32>*
%28 = load <4 x i32>, <4 x i32>* %27
%29 = getelementptr i32, i32* %26, i64 4
%30 = bitcast i32* %29 to <4 x i32>*
%31 = load <4 x i32>, <4 x i32>* %30
%32 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> %28, <4 x i32>* %32
%33 = getelementptr i32, i32* %25, i64 4
%34 = bitcast i32* %33 to <4 x i32>*
store <4 x i32> %31, <4 x i32>* %34
%35 = or i64 %2, 24
%36 = getelementptr i32, i32* inttoptr (i64 1342193664 to i32*), i64 %35
%37 = getelementptr i32, i32* inttoptr (i64 4096 to i32*), i64 %35
%38 = bitcast i32* %37 to <4 x i32>*
%39 = load <4 x i32>, <4 x i32>* %38
%40 = getelementptr i32, i32* %37, i64 4
%41 = bitcast i32* %40 to <4 x i32>*
%42 = load <4 x i32>, <4 x i32>* %41
%43 = bitcast i32* %36 to <4 x i32>*
store <4 x i32> %39, <4 x i32>* %43
%44 = getelementptr i32, i32* %36, i64 4
%45 = bitcast i32* %44 to <4 x i32>*
store <4 x i32> %42, <4 x i32>* %45
%46 = add nuw nsw i64 %2, 32
%47 = icmp eq i64 %46, 1024
br i1 %47, label %48, label %1
48: ; preds = %1
ret void
}