void draw_border() {
  int i;
  char *p;
  p = (char *)0xa0000;
  for (i = 0; i <= 0xffff; i++) {
    *p = i & 0xf;
    p++;
  }
}


x86 assembly (clang, -O0):
<draw_border>:
push   %rbp
mov    %rsp,%rbp
mov    $0xa0000,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0xffff,-0x4(%rbp)
jg     1149 <draw_border+0x49>
mov    -0x4(%rbp),%eax
and    $0xf,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1114 <draw_border+0x14>
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_border>:
movaps 0xef9(%rip),%xmm0
mov    $0xa0070,%eax
xor    %ecx,%ecx
movaps 0xefb(%rip),%xmm1
movaps 0xf04(%rip),%xmm2
nopl   0x0(%rax)
movaps %xmm0,%xmm3
andps  %xmm1,%xmm3
movaps %xmm3,-0x70(%rax,%rcx,1)
movaps %xmm3,-0x60(%rax,%rcx,1)
movaps %xmm3,-0x50(%rax,%rcx,1)
movaps %xmm3,-0x40(%rax,%rcx,1)
movaps %xmm3,-0x30(%rax,%rcx,1)
movaps %xmm3,-0x20(%rax,%rcx,1)
movaps %xmm3,-0x10(%rax,%rcx,1)
movaps %xmm3,(%rax,%rcx,1)
sub    $0xffffffffffffff80,%rcx
xorps  %xmm2,%xmm0
cmp    $0x10000,%rcx
jne    1120 <draw_border+0x20>
ret

LLVM IR (-O0):
define void @draw_border() {
%1 = alloca i32
%2 = alloca i8*
store i8* inttoptr (i64 655360 to i8*), i8** %2
store i32 0, i32* %1
br label %3
3: ; preds = %13, %0
%4 = load i32, i32* %1
%5 = icmp sle i32 %4, 65535
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = load i32, i32* %1
%8 = and i32 %7, 15
%9 = trunc i32 %8 to i8
%10 = load i8*, i8** %2
store i8 %9, i8* %10
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %2
br label %13
13: ; preds = %6
%14 = load i32, i32* %1
%15 = add nsw i32 %14, 1
store i32 %15, i32* %1
br label %3
16: ; preds = %3
ret void
}

LLVM IR (-O2):
define void @draw_border() {
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %31, %1 ]
%3 = phi <16 x i8> [ <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, %0 ], [ %32, %1 ]
%4 = getelementptr i8, i8* inttoptr (i64 655360 to i8*), i64 %2
%5 = and <16 x i8> %3, <i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15>
%6 = and <16 x i8> %3, <i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15>
%7 = bitcast i8* %4 to <16 x i8>*
store <16 x i8> %5, <16 x i8>* %7
%8 = getelementptr i8, i8* %4, i64 16
%9 = bitcast i8* %8 to <16 x i8>*
store <16 x i8> %6, <16 x i8>* %9
%10 = or i64 %2, 32
%11 = getelementptr i8, i8* inttoptr (i64 655360 to i8*), i64 %10
%12 = and <16 x i8> %3, <i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15>
%13 = and <16 x i8> %3, <i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15>
%14 = bitcast i8* %11 to <16 x i8>*
store <16 x i8> %12, <16 x i8>* %14
%15 = getelementptr i8, i8* %11, i64 16
%16 = bitcast i8* %15 to <16 x i8>*
store <16 x i8> %13, <16 x i8>* %16
%17 = or i64 %2, 64
%18 = getelementptr i8, i8* inttoptr (i64 655360 to i8*), i64 %17
%19 = and <16 x i8> %3, <i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15>
%20 = and <16 x i8> %3, <i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15>
%21 = bitcast i8* %18 to <16 x i8>*
store <16 x i8> %19, <16 x i8>* %21
%22 = getelementptr i8, i8* %18, i64 16
%23 = bitcast i8* %22 to <16 x i8>*
store <16 x i8> %20, <16 x i8>* %23
%24 = or i64 %2, 96
%25 = getelementptr i8, i8* inttoptr (i64 655360 to i8*), i64 %24
%26 = and <16 x i8> %3, <i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15>
%27 = and <16 x i8> %3, <i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15>
%28 = bitcast i8* %25 to <16 x i8>*
store <16 x i8> %26, <16 x i8>* %28
%29 = getelementptr i8, i8* %25, i64 16
%30 = bitcast i8* %29 to <16 x i8>*
store <16 x i8> %27, <16 x i8>* %30
%31 = add nuw nsw i64 %2, 128
%32 = xor <16 x i8> %3, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
%33 = icmp eq i64 %31, 65536
br i1 %33, label %34, label %1
34: ; preds = %1
ret void
}