int checkDramData(volatile unsigned int *pBaseAddress,
                  const unsigned int pExpectedValue) {
  unsigned int index;
  for (index = 0; index < (0x10000 * 1); index += 1) {
    if ((pBaseAddress[index] & 0xFFFF) != (pExpectedValue & 0xFFFF))
      printf("0x%8.8X 0\n\r", (unsigned int)&pBaseAddress[index]);
    if ((pBaseAddress[index] & 0xFFFF0000) != (pExpectedValue & 0xFFFF0000))
      printf("0x%8.8X 1\n\r", (unsigned int)&pBaseAddress[index]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<checkDramData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x10000,-0x10(%rbp)
jae    11c2 <checkDramData+0xb2>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
and    $0xffff,%eax
mov    -0xc(%rbp),%ecx
and    $0xffff,%ecx
cmp    %ecx,%eax
je     1171 <checkDramData+0x61>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %eax,%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
and    $0xffff0000,%eax
mov    -0xc(%rbp),%ecx
and    $0xffff0000,%ecx
cmp    %ecx,%eax
je     11af <checkDramData+0x9f>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %eax,%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b4 <checkDramData+0xa4>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <checkDramData+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkDramData>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r12d
mov    %rdi,%rbx
lea    0xee7(%rip),%r14
lea    0xed4(%rip),%r15
xor    %ebp,%ebp
jmp    113d <checkDramData+0x2d>
add    $0x4,%rbp
cmp    $0x40000,%rbp
je     1171 <checkDramData+0x61>
mov    (%rbx,%rbp,1),%eax
mov    %r12d,%ecx
xor    %ax,%cx
je     1155 <checkDramData+0x45>
lea    (%rbx,%rbp,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx,%rbp,1),%eax
xor    %r12d,%eax
cmp    $0x10000,%eax
jb     1130 <checkDramData+0x20>
lea    (%rbx,%rbp,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1130 <checkDramData+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"0x%8.8X 0\0A\0D\00"
@.str.1 = [12 x i8] c"0x%8.8X 1\0A\0D\00"
define i32 @checkDramData(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %44, %2
%7 = load i32, i32* %5
%8 = icmp ult i32 %7, 65536
br i1 %8, label %9, label %47
9: ; preds = %6
%10 = load i32*, i32** %3
%11 = load i32, i32* %5
%12 = zext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %10, i64 %12
%14 = load volatile i32, i32* %13
%15 = and i32 %14, 65535
%16 = load i32, i32* %4
%17 = and i32 %16, 65535
%18 = icmp ne i32 %15, %17
br i1 %18, label %19, label %26
19: ; preds = %9
%20 = load i32*, i32** %3
%21 = load i32, i32* %5
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = ptrtoint i32* %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %19, %9
%27 = load i32*, i32** %3
%28 = load i32, i32* %5
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load volatile i32, i32* %30
%32 = and i32 %31, -65536
%33 = load i32, i32* %4
%34 = and i32 %33, -65536
%35 = icmp ne i32 %32, %34
br i1 %35, label %36, label %43
36: ; preds = %26
%37 = load i32*, i32** %3
%38 = load i32, i32* %5
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
%41 = ptrtoint i32* %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %36, %26
br label %44
44: ; preds = %43
%45 = load i32, i32* %5
%46 = add i32 %45, 1
store i32 %46, i32* %5
br label %6
47: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"0x%8.8X 0\0A\0D\00"
@.str.1 = [12 x i8] c"0x%8.8X 1\0A\0D\00"
define i32 @checkDramData(i32* %0, i32 %1) {
br label %3
3: ; preds = %2, %22
%4 = phi i64 [ 0, %2 ], [ %23, %22 ]
%5 = getelementptr inbounds i32, i32* %0, i64 %4
%6 = load volatile i32, i32* %5
%7 = xor i32 %6, %1
%8 = and i32 %7, 65535
%9 = icmp eq i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %3
%11 = ptrtoint i32* %5 to i64
%12 = trunc i64 %11 to i32
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %10, %3
%15 = load volatile i32, i32* %5
%16 = xor i32 %15, %1
%17 = icmp ult i32 %16, 65536
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = ptrtoint i32* %5 to i64
%20 = trunc i64 %19 to i32
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %14, %18
%23 = add nuw nsw i64 %4, 1
%24 = icmp eq i64 %23, 65536
br i1 %24, label %25, label %3
25: ; preds = %22
ret i32 0
}