void midline(int d, char *p) {
  switch (d) {
  case 0:
  case 4:
  case 5:
  case 6:
  case 8:
  case 9:
    *p++ = '|';
    break;
  default:
    *p++ = ' ';
  }
  switch (d) {
  case 2:
  case 3:
  case 4:
  case 5:
  case 6:
  case 8:
  case 9:
    *p++ = '_';
    break;
  default:
    *p++ = ' ';
  }
  switch (d) {
  case 0:
  case 1:
  case 2:
  case 3:
  case 4:
  case 7:
  case 8:
  case 9:
    *p++ = '|';
    break;
  default:
    *p++ = ' ';
  }
}


x86 assembly (clang, -O0):
<midline>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     1146 <midline+0x46>
jmp    111e <midline+0x1e>
mov    -0x14(%rbp),%eax
add    $0xfffffffc,%eax
sub    $0x3,%eax
jb     1146 <midline+0x46>
jmp    1132 <midline+0x32>
mov    -0x14(%rbp),%eax
add    $0xfffffff8,%eax
sub    $0x1,%eax
ja     115d <midline+0x5d>
jmp    1146 <midline+0x46>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x7c,(%rax)
jmp    116f <midline+0x6f>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x20,(%rax)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
add    $0xfffffffe,%eax
sub    $0x5,%eax
jb     119a <midline+0x9a>
jmp    1186 <midline+0x86>
mov    -0x18(%rbp),%eax
add    $0xfffffff8,%eax
sub    $0x1,%eax
ja     11b1 <midline+0xb1>
jmp    119a <midline+0x9a>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x5f,(%rax)
jmp    11c3 <midline+0xc3>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x20,(%rax)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x5,%eax
jb     11eb <midline+0xeb>
jmp    11d7 <midline+0xd7>
mov    -0x1c(%rbp),%eax
add    $0xfffffff9,%eax
sub    $0x2,%eax
ja     1202 <midline+0x102>
jmp    11eb <midline+0xeb>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x7c,(%rax)
jmp    1214 <midline+0x114>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x20,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<midline>:
mov    $0x20,%r9b
movslq %edi,%r8
mov    $0x20,%dl
cmp    $0x9,%edi
ja     1118 <midline+0x18>
lea    0xeec(%rip),%rcx
mov    (%r8,%rcx,1),%dl
lea    -0x10(,%rdi,8),%ecx
movabs $0x5f5f205f5f5f5f5f,%rax
20 5f 5f
shr    %cl,%rax
mov    %dl,(%rsi)
lea    -0x2(%rdi),%ecx
cmp    $0x8,%ecx
mov    $0x20,%ecx
cmovb  %eax,%ecx
mov    %cl,0x1(%rsi)
cmp    $0x9,%edi
ja     114f <midline+0x4f>
lea    0xebf(%rip),%rax
mov    (%r8,%rax,1),%r9b
mov    %r9b,0x2(%rsi)
ret

LLVM IR (-O0):
define void @midline(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
switch i32 %5, label %9 [
i32 0, label %6
i32 4, label %6
i32 5, label %6
i32 6, label %6
i32 8, label %6
i32 9, label %6
]
6: ; preds = %2, %2, %2, %2, %2, %2
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i32 1
store i8* %8, i8** %4
store i8 124, i8* %7
br label %12
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %4
store i8 32, i8* %10
br label %12
12: ; preds = %9, %6
%13 = load i32, i32* %3
switch i32 %13, label %17 [
i32 2, label %14
i32 3, label %14
i32 4, label %14
i32 5, label %14
i32 6, label %14
i32 8, label %14
i32 9, label %14
]
14: ; preds = %12, %12, %12, %12, %12, %12, %12
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %4
store i8 95, i8* %15
br label %20
17: ; preds = %12
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %4
store i8 32, i8* %18
br label %20
20: ; preds = %17, %14
%21 = load i32, i32* %3
switch i32 %21, label %25 [
i32 0, label %22
i32 1, label %22
i32 2, label %22
i32 3, label %22
i32 4, label %22
i32 7, label %22
i32 8, label %22
i32 9, label %22
]
22: ; preds = %20, %20, %20, %20, %20, %20, %20, %20
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %4
store i8 124, i8* %23
br label %28
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %4
store i8 32, i8* %26
br label %28
28: ; preds = %25, %22
ret void
}

LLVM IR (-O2):
@switch.table.midline = [10 x i8] c"| ||| ||"
@switch.table.midline.1 = [10 x i8] c"||||| |||"
define void @midline(i32 %0, i8* nocapture writeonly %1) {
%3 = icmp ult i32 %0, 10
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = sext i32 %0 to i64
%6 = getelementptr inbounds [10 x i8], [10 x i8]* @switch.table.midline, i64 0, i64 %5
%7 = load i8, i8* %6
br label %8
8: ; preds = %2, %4
%9 = phi i8 [ %7, %4 ], [ 32, %2 ]
%10 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %9, i8* %1
%11 = add i32 %0, -2
%12 = icmp ult i32 %11, 8
%13 = zext i32 %11 to i64
%14 = shl nuw nsw i64 %13, 3
%15 = lshr i64 6872247150384734047, %14
%16 = trunc i64 %15 to i8
%17 = select i1 %12, i8 %16, i8 32
store i8 %17, i8* %10
%18 = icmp ult i32 %0, 10
br i1 %18, label %19, label %23
19: ; preds = %8
%20 = sext i32 %0 to i64
%21 = getelementptr inbounds [10 x i8], [10 x i8]* @switch.table.midline.1, i64 0, i64 %20
%22 = load i8, i8* %21
br label %23
23: ; preds = %8, %19
%24 = phi i8 [ %22, %19 ], [ 32, %8 ]
%25 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %24, i8* %25
ret void
}