void copy_2th_to_sdram(void) {
  unsigned int *pdwSrc = (unsigned int *)2048;
  unsigned int *pdwDest = (unsigned int *)0x30004000;
  while (pdwSrc < (unsigned int *)4096) {
    *pdwDest = *pdwSrc;
    pdwDest++;
    pdwSrc++;
  }
}


x86 assembly (clang, -O0):
<copy_2th_to_sdram>:
push   %rbp
mov    %rsp,%rbp
mov    $0x800,%eax
mov    %rax,-0x8(%rbp)
mov    $0x30004000,%eax
mov    %rax,-0x10(%rbp)
mov    $0x1000,%eax
cmp    %rax,-0x8(%rbp)
jae    114e <copy_2th_to_sdram+0x4e>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    1116 <copy_2th_to_sdram+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_2th_to_sdram>:
mov    $0x870,%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,0x30003790(%rax,%rcx,4)
30
movaps %xmm1,0x300037a0(%rax,%rcx,4)
30
movaps %xmm2,0x300037b0(%rax,%rcx,4)
30
movaps %xmm3,0x300037c0(%rax,%rcx,4)
30
movaps -0x30(%rax,%rcx,4),%xmm0
movaps -0x20(%rax,%rcx,4),%xmm1
movaps %xmm0,0x300037d0(%rax,%rcx,4)
30
movaps %xmm1,0x300037e0(%rax,%rcx,4)
30
movaps -0x10(%rax,%rcx,4),%xmm0
movaps (%rax,%rcx,4),%xmm1
movaps %xmm0,0x300037f0(%rax,%rcx,4)
30
movaps %xmm1,0x30003800(%rax,%rcx,4)
30
add    $0x20,%rcx
cmp    $0x200,%rcx
jne    1110 <copy_2th_to_sdram+0x10>
ret

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

LLVM IR (-O2):
define void @copy_2th_to_sdram() {
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %46, %1 ]
%3 = getelementptr i32, i32* inttoptr (i64 805322752 to i32*), i64 %2
%4 = getelementptr i32, i32* inttoptr (i64 2048 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 805322752 to i32*), i64 %13
%15 = getelementptr i32, i32* inttoptr (i64 2048 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 805322752 to i32*), i64 %24
%26 = getelementptr i32, i32* inttoptr (i64 2048 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 805322752 to i32*), i64 %35
%37 = getelementptr i32, i32* inttoptr (i64 2048 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, 512
br i1 %47, label %48, label %1
48: ; preds = %1
ret void
}