void opt(void) {
  int *p, wk;
  int data[100];
  __builtin_prefetch(&data[0], 0, 0);
  __builtin_prefetch(&data[0], 0, 1);
  __builtin_prefetch(&data[0], 0, 2);
  __builtin_prefetch(&data[0], 0, 3);
  __builtin_prefetch(&data[0], 1, 0);
  __builtin_prefetch(&data[0], 1, 1);
  __builtin_prefetch(&data[0], 1, 2);
  __builtin_prefetch(&data[0], 1, 3);
  for (p = &data[0]; p < &data[9]; p++) {
    if (*p > *(p + 1)) {
      wk = *p;
      *p = *(p + 1);
      *(p + 1) = wk;
    }
  }
}


x86 assembly (clang, -O0):
<opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
lea    -0x1a0(%rbp),%rax
prefetchnta (%rax)
lea    -0x1a0(%rbp),%rax
prefetcht2 (%rax)
lea    -0x1a0(%rbp),%rax
prefetcht1 (%rax)
lea    -0x1a0(%rbp),%rax
prefetcht0 (%rax)
lea    -0x1a0(%rbp),%rax
prefetchnta (%rax)
lea    -0x1a0(%rbp),%rax
prefetcht2 (%rax)
lea    -0x1a0(%rbp),%rax
prefetcht1 (%rax)
lea    -0x1a0(%rbp),%rax
prefetcht0 (%rax)
lea    -0x1a0(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
lea    -0x1a0(%rbp),%rcx
add    $0x24,%rcx
cmp    %rcx,%rax
jae    11c7 <opt+0xc7>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%rcx
cmp    0x4(%rcx),%eax
jle    11b1 <opt+0xb1>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
jmp    11b6 <opt+0xb6>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    1166 <opt+0x66>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<opt>:
sub    $0x118,%rsp
lea    -0x80(%rsp),%rcx
prefetchnta -0x80(%rsp)
prefetcht2 -0x80(%rsp)
prefetcht1 -0x80(%rsp)
prefetcht0 -0x80(%rsp)
prefetchnta -0x80(%rsp)
prefetcht2 -0x80(%rsp)
prefetcht1 -0x80(%rsp)
prefetcht0 -0x80(%rsp)
lea    -0x5c(%rsp),%rax
jmp    114d <opt+0x4d>
nopl   0x0(%rax,%rax,1)
mov    %edi,(%rcx)
mov    %edx,0x4(%rcx)
mov    %rsi,%rcx
cmp    %rax,%rsi
jae    115c <opt+0x5c>
lea    0x4(%rcx),%rsi
mov    0x4(%rcx),%edi
cmp    %edi,%edx
jg     1140 <opt+0x40>
mov    %edi,%edx
jmp    1145 <opt+0x45>
add    $0x118,%rsp
ret

LLVM IR (-O0):
define void @opt() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca [100 x i32]
%4 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%5 = bitcast i32* %4 to i8*
%6 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%7 = bitcast i32* %6 to i8*
%8 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%9 = bitcast i32* %8 to i8*
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%11 = bitcast i32* %10 to i8*
%12 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%13 = bitcast i32* %12 to i8*
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%15 = bitcast i32* %14 to i8*
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%17 = bitcast i32* %16 to i8*
%18 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%19 = bitcast i32* %18 to i8*
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
store i32* %20, i32** %1
br label %21
21: ; preds = %43, %0
%22 = load i32*, i32** %1
%23 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 9
%24 = icmp ult i32* %22, %23
br i1 %24, label %25, label %46
25: ; preds = %21
%26 = load i32*, i32** %1
%27 = load i32, i32* %26
%28 = load i32*, i32** %1
%29 = getelementptr inbounds i32, i32* %28, i64 1
%30 = load i32, i32* %29
%31 = icmp sgt i32 %27, %30
br i1 %31, label %32, label %42
32: ; preds = %25
%33 = load i32*, i32** %1
%34 = load i32, i32* %33
store i32 %34, i32* %2
%35 = load i32*, i32** %1
%36 = getelementptr inbounds i32, i32* %35, i64 1
%37 = load i32, i32* %36
%38 = load i32*, i32** %1
store i32 %37, i32* %38
%39 = load i32, i32* %2
%40 = load i32*, i32** %1
%41 = getelementptr inbounds i32, i32* %40, i64 1
store i32 %39, i32* %41
br label %42
42: ; preds = %32, %25
br label %43
43: ; preds = %42
%44 = load i32*, i32** %1
%45 = getelementptr inbounds i32, i32* %44, i32 1
store i32* %45, i32** %1
br label %21
46: ; preds = %21
ret void
}

LLVM IR (-O2):
define void @opt() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 9
br label %5
5: ; preds = %0, %12
%6 = phi i32 [ undef, %0 ], [ %13, %12 ]
%7 = phi i32* [ %3, %0 ], [ %8, %12 ]
%8 = getelementptr inbounds i32, i32* %7, i64 1
%9 = load i32, i32* %8
%10 = icmp sgt i32 %6, %9
br i1 %10, label %11, label %12
11: ; preds = %5
store i32 %9, i32* %7
store i32 %6, i32* %8
br label %12
12: ; preds = %5, %11
%13 = phi i32 [ %9, %5 ], [ %6, %11 ]
%14 = icmp ult i32* %8, %4
br i1 %14, label %5, label %15
15: ; preds = %12
ret void
}