int main() {
  unsigned int *volatile ar = (unsigned int *)0x80000000U;
  unsigned int *volatile cr = (unsigned int *)0x80000000U + 1;
  unsigned int *volatile iesr = (unsigned int *)0x80000000U + 2;
  unsigned int *volatile ccr = (unsigned int *)0x80000000U + 3;
  printf("Writing to AR\n");
  *ar = 0xDEADBEEF;
  printf("Reading from AR: 0x%08x\n", *ar);
  printf("Writing to CR\n");
  *cr = 0xBA5EBA11;
  printf("Reading from CR: 0x%08x\n", *cr);
  printf("Writing to IESR\n");
  *iesr = 0xC001D00D;
  printf("Reading from IESR: 0x%08x\n", *iesr);
  printf("Writing to CCR\n");
  *ccr = 0x1BADBABE;
  printf("Reading from AR: 0x%08x\n", *ccr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x80000000,%eax
mov    %rax,-0x10(%rbp)
mov    $0x80000000,%eax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    $0x80000000,%eax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    $0x80000000,%eax
add    $0xc,%rax
mov    %rax,-0x28(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movl   $0xdeadbeef,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movl   $0xba5eba11,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movl   $0xc001d00d,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
movl   $0x1badbabe,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    $0x80000000,%eax
mov    %rax,0x18(%rsp)
lea    0x4(%rax),%rcx
mov    %rcx,0x10(%rsp)
lea    0x8(%rax),%rcx
mov    %rcx,0x8(%rsp)
or     $0xc,%rax
mov    %rax,(%rsp)
lea    0xefd(%rip),%rdi
call   1030 <puts@plt>
mov    0x18(%rsp),%rax
movl   $0xdeadbeef,(%rax)
mov    0x18(%rsp),%rax
mov    (%rax),%esi
lea    0xe92(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xedc(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%rax
movl   $0xba5eba11,(%rax)
mov    0x10(%rsp),%rax
mov    (%rax),%esi
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rax
movl   $0xc001d00d,(%rax)
mov    0x8(%rsp),%rax
mov    (%rax),%esi
lea    0xe69(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%rax
movl   $0x1badbabe,(%rax)
mov    (%rsp),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Writing to AR\0A\00"
@.str.1 = [25 x i8] c"Reading from AR: 0x%08x\0A\00"
@.str.2 = [15 x i8] c"Writing to CR\0A\00"
@.str.3 = [25 x i8] c"Reading from CR: 0x%08x\0A\00"
@.str.4 = [17 x i8] c"Writing to IESR\0A\00"
@.str.5 = [27 x i8] c"Reading from IESR: 0x%08x\0A\00"
@.str.6 = [16 x i8] c"Writing to CCR\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
store i32 0, i32* %1
store volatile i32* inttoptr (i64 2147483648 to i32*), i32** %2
store volatile i32* getelementptr inbounds (i32, i32* inttoptr (i64 2147483648 to i32*), i64 1), i32** %3
store volatile i32* getelementptr inbounds (i32, i32* inttoptr (i64 2147483648 to i32*), i64 2), i32** %4
store volatile i32* getelementptr inbounds (i32, i32* inttoptr (i64 2147483648 to i32*), i64 3), i32** %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = load volatile i32*, i32** %2
store i32 -559038737, i32* %7
%8 = load volatile i32*, i32** %2
%9 = load i32, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%12 = load volatile i32*, i32** %3
store i32 -1168197103, i32* %12
%13 = load volatile i32*, i32** %3
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%17 = load volatile i32*, i32** %4
store i32 -1073623027, i32* %17
%18 = load volatile i32*, i32** %4
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%22 = load volatile i32*, i32** %5
store i32 464370366, i32* %22
%23 = load volatile i32*, i32** %5
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [25 x i8] c"Reading from AR: 0x%08x\0A\00"
@.str.3 = [25 x i8] c"Reading from CR: 0x%08x\0A\00"
@.str.5 = [27 x i8] c"Reading from IESR: 0x%08x\0A\00"
@str = [14 x i8] c"Writing to AR\00"
@str.7 = [14 x i8] c"Writing to CR\00"
@str.8 = [16 x i8] c"Writing to IESR\00"
@str.9 = [15 x i8] c"Writing to CCR\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = bitcast i32** %1 to i8*
store volatile i32* inttoptr (i64 2147483648 to i32*), i32** %1
%6 = bitcast i32** %2 to i8*
store volatile i32* inttoptr (i64 2147483652 to i32*), i32** %2
%7 = bitcast i32** %3 to i8*
store volatile i32* inttoptr (i64 2147483656 to i32*), i32** %3
%8 = bitcast i32** %4 to i8*
store volatile i32* inttoptr (i64 2147483660 to i32*), i32** %4
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%10 = load volatile i32*, i32** %1
store i32 -559038737, i32* %10
%11 = load volatile i32*, i32** %1
%12 = load i32, i32* %11
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.7, i64 0, i64 0))
%15 = load volatile i32*, i32** %2
store i32 -1168197103, i32* %15
%16 = load volatile i32*, i32** %2
%17 = load i32, i32* %16
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.8, i64 0, i64 0))
%20 = load volatile i32*, i32** %3
store i32 -1073623027, i32* %20
%21 = load volatile i32*, i32** %3
%22 = load i32, i32* %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %22)
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.9, i64 0, i64 0))
%25 = load volatile i32*, i32** %4
store i32 464370366, i32* %25
%26 = load volatile i32*, i32** %4
%27 = load i32, i32* %26
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %27)
ret i32 0
}