void vfdlib_drawSolidRectangleUnclipped(char *buffer, int xLeft, int yTop,
                                        int xWidth, int yHeight, char shade) {
  int widthRemaining;
  char doubleShade = shade | (shade << 4);
  char *lineStart;
  lineStart = buffer + (yTop << 6) + (xLeft >> 1);
  while (yHeight-- > 0) {
    buffer = lineStart;
    widthRemaining = xWidth;
    if (xLeft & 0x1) {
      *buffer &= 0x0F;
      *buffer |= (shade << 4);
      widthRemaining--;
      buffer++;
    }
    while (widthRemaining > 1) {
      *(buffer++) = doubleShade;
      widthRemaining -= 2;
    }
    if (widthRemaining > 0) {
      *buffer &= 0xF0;
      *buffer |= shade;
      buffer++;
    }
    lineStart += 64;
  }
}


x86 assembly (clang, -O0):
<vfdlib_drawSolidRectangleUnclipped>:
push   %rbp
mov    %rsp,%rbp
mov    %r9b,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
movsbl -0x19(%rbp),%ecx
shl    $0x4,%ecx
or     %ecx,%eax
mov    %al,-0x21(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x6,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    -0xc(%rbp),%ecx
sar    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
jle    1225 <vfdlib_drawSolidRectangleUnclipped+0x125>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11af <vfdlib_drawSolidRectangleUnclipped+0xaf>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
and    $0xf,%ecx
mov    %cl,(%rax)
movsbl -0x19(%rbp),%edx
shl    $0x4,%edx
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
or     %edx,%ecx
mov    %cl,(%rax)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11b4 <vfdlib_drawSolidRectangleUnclipped+0xb4>
cmpl   $0x1,-0x20(%rbp)
jle    11e0 <vfdlib_drawSolidRectangleUnclipped+0xe0>
mov    -0x21(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x20(%rbp)
jmp    11b4 <vfdlib_drawSolidRectangleUnclipped+0xb4>
cmpl   $0x0,-0x20(%rbp)
jle    1214 <vfdlib_drawSolidRectangleUnclipped+0x114>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
and    $0xf0,%ecx
mov    %cl,(%rax)
movsbl -0x19(%rbp),%edx
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
or     %edx,%ecx
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x30(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x30(%rbp)
jmp    114b <vfdlib_drawSolidRectangleUnclipped+0x4b>
pop    %rbp
ret

x86 assembly (clang, -O2):
<vfdlib_drawSolidRectangleUnclipped>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,0x10(%rsp)
test   %r8d,%r8d
jle    123e <vfdlib_drawSolidRectangleUnclipped+0x12e>
mov    0x10(%rsp),%eax
mov    %eax,%ebx
shl    $0x4,%bl
mov    %bl,0xf(%rsp)
or     %al,%bl
mov    %bl,0xe(%rsp)
shl    $0x6,%edx
movslq %edx,%rax
lea    (%rdi,%rax,1),%rbx
mov    %esi,%edx
sar    %edx
movslq %edx,%rdx
add    %rdx,%rbx
lea    -0x1(%rcx),%ebp
mov    %ebp,0x14(%rsp)
add    $0x1,%r8d
add    %rax,%rdx
lea    (%rdi,%rdx,1),%r14
add    $0x1,%r14
mov    %rcx,0x20(%rsp)
mov    %esi,0x18(%rsp)
jmp    1196 <vfdlib_drawSolidRectangleUnclipped+0x86>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x40,%rbx
add    $0xffffffff,%r8d
add    $0x40,%r14
cmp    $0x1,%r8d
jbe    123e <vfdlib_drawSolidRectangleUnclipped+0x12e>
mov    %ecx,%r15d
mov    %rbx,%r13
test   $0x1,%sil
jne    11b0 <vfdlib_drawSolidRectangleUnclipped+0xa0>
cmp    $0x2,%r15d
jge    11cf <vfdlib_drawSolidRectangleUnclipped+0xbf>
cmp    $0x1,%r15d
jne    1180 <vfdlib_drawSolidRectangleUnclipped+0x70>
jmp    122a <vfdlib_drawSolidRectangleUnclipped+0x11a>
movzbl -0x1(%r14),%eax
and    $0xf,%al
or     0xf(%rsp),%al
mov    %al,-0x1(%r14)
mov    0x14(%rsp),%eax
mov    %eax,%r15d
mov    %r14,%r13
cmp    $0x2,%r15d
jl     11a8 <vfdlib_drawSolidRectangleUnclipped+0x98>
mov    $0x3,%eax
cmovle %r15d,%eax
neg    %eax
lea    (%r15,%rax,1),%r12d
add    $0x1,%r12d
mov    %r12d,%ebp
shr    %ebp
lea    0x1(%rbp),%rdx
movzbl 0xe(%rsp),%esi
mov    %r13,%rdi
mov    %r8d,0x1c(%rsp)
call   1030 <memset@plt>
mov    0x18(%rsp),%esi
mov    0x20(%rsp),%rcx
mov    0x1c(%rsp),%r8d
add    %rbp,%r13
add    $0x1,%r13
and    $0xfffffffe,%r12d
neg    %r12d
add    %r12d,%r15d
add    $0xfffffffe,%r15d
cmp    $0x1,%r15d
jne    1180 <vfdlib_drawSolidRectangleUnclipped+0x70>
movzbl 0x0(%r13),%eax
and    $0xf0,%al
or     0x10(%rsp),%al
mov    %al,0x0(%r13)
jmp    1180 <vfdlib_drawSolidRectangleUnclipped+0x70>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @vfdlib_drawSolidRectangleUnclipped(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i8 signext %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
%13 = alloca i32
%14 = alloca i8
%15 = alloca i8*
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i8 %5, i8* %12
%16 = load i8, i8* %12
%17 = sext i8 %16 to i32
%18 = load i8, i8* %12
%19 = sext i8 %18 to i32
%20 = shl i32 %19, 4
%21 = or i32 %17, %20
%22 = trunc i32 %21 to i8
store i8 %22, i8* %14
%23 = load i8*, i8** %7
%24 = load i32, i32* %9
%25 = shl i32 %24, 6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
%28 = load i32, i32* %8
%29 = ashr i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
store i8* %31, i8** %15
br label %32
32: ; preds = %88, %6
%33 = load i32, i32* %11
%34 = add nsw i32 %33, -1
store i32 %34, i32* %11
%35 = icmp sgt i32 %33, 0
br i1 %35, label %36, label %91
36: ; preds = %32
%37 = load i8*, i8** %15
store i8* %37, i8** %7
%38 = load i32, i32* %10
store i32 %38, i32* %13
%39 = load i32, i32* %8
%40 = and i32 %39, 1
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %60
42: ; preds = %36
%43 = load i8*, i8** %7
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = and i32 %45, 15
%47 = trunc i32 %46 to i8
store i8 %47, i8* %43
%48 = load i8, i8* %12
%49 = sext i8 %48 to i32
%50 = shl i32 %49, 4
%51 = load i8*, i8** %7
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = or i32 %53, %50
%55 = trunc i32 %54 to i8
store i8 %55, i8* %51
%56 = load i32, i32* %13
%57 = add nsw i32 %56, -1
store i32 %57, i32* %13
%58 = load i8*, i8** %7
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %7
br label %60
60: ; preds = %42, %36
br label %61
61: ; preds = %64, %60
%62 = load i32, i32* %13
%63 = icmp sgt i32 %62, 1
br i1 %63, label %64, label %70
64: ; preds = %61
%65 = load i8, i8* %14
%66 = load i8*, i8** %7
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %7
store i8 %65, i8* %66
%68 = load i32, i32* %13
%69 = sub nsw i32 %68, 2
store i32 %69, i32* %13
br label %61
70: ; preds = %61
%71 = load i32, i32* %13
%72 = icmp sgt i32 %71, 0
br i1 %72, label %73, label %88
73: ; preds = %70
%74 = load i8*, i8** %7
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = and i32 %76, 240
%78 = trunc i32 %77 to i8
store i8 %78, i8* %74
%79 = load i8, i8* %12
%80 = sext i8 %79 to i32
%81 = load i8*, i8** %7
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = or i32 %83, %80
%85 = trunc i32 %84 to i8
store i8 %85, i8* %81
%86 = load i8*, i8** %7
%87 = getelementptr inbounds i8, i8* %86, i32 1
store i8* %87, i8** %7
br label %88
88: ; preds = %73, %70
%89 = load i8*, i8** %15
%90 = getelementptr inbounds i8, i8* %89, i64 64
store i8* %90, i8** %15
br label %32
91: ; preds = %32
ret void
}

LLVM IR (-O2):
define void @vfdlib_drawSolidRectangleUnclipped(i8* nocapture %0, i32 %1, i32 %2, i32 %3, i32 %4, i8 signext %5) {
%7 = shl i8 %5, 4
%8 = or i8 %7, %5
%9 = icmp sgt i32 %4, 0
br i1 %9, label %10, label %56
10: ; preds = %6
%11 = shl i32 %2, 6
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = ashr i32 %1, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = and i32 %1, 1
%18 = icmp eq i32 %17, 0
%19 = add nsw i32 %3, -1
br label %20
20: ; preds = %10, %53
%21 = phi i32 [ %4, %10 ], [ %23, %53 ]
%22 = phi i8* [ %16, %10 ], [ %54, %53 ]
%23 = add nsw i32 %21, -1
br i1 %18, label %29, label %24
24: ; preds = %20
%25 = load i8, i8* %22
%26 = and i8 %25, 15
%27 = or i8 %26, %7
store i8 %27, i8* %22
%28 = getelementptr inbounds i8, i8* %22, i64 1
br label %29
29: ; preds = %24, %20
%30 = phi i32 [ %19, %24 ], [ %3, %20 ]
%31 = phi i8* [ %28, %24 ], [ %22, %20 ]
%32 = icmp sgt i32 %30, 1
br i1 %32, label %33, label %45
33: ; preds = %29
%34 = add nuw i32 %30, 1
%35 = call i32 @llvm.smin.i32(i32 %30, i32 3)
%36 = sub nuw i32 %34, %35
%37 = lshr i32 %36, 1
%38 = zext i32 %37 to i64
%39 = add nuw nsw i64 %38, 1
%40 = getelementptr i8, i8* %31, i64 1
%41 = getelementptr i8, i8* %40, i64 %38
%42 = and i32 %36, -2
%43 = add nsw i32 %30, -2
%44 = sub nsw i32 %43, %42
br label %45
45: ; preds = %33, %29
%46 = phi i32 [ %30, %29 ], [ %44, %33 ]
%47 = phi i8* [ %31, %29 ], [ %41, %33 ]
%48 = icmp eq i32 %46, 1
br i1 %48, label %49, label %53
49: ; preds = %45
%50 = load i8, i8* %47
%51 = and i8 %50, -16
%52 = or i8 %51, %5
store i8 %52, i8* %47
br label %53
53: ; preds = %49, %45
%54 = getelementptr inbounds i8, i8* %22, i64 64
%55 = icmp ugt i32 %21, 1
br i1 %55, label %20, label %56
56: ; preds = %53, %6
ret void
}