int get_dblrepbar(char *p) {
  int bar_type;
  bar_type = 0;
  for (;;) {
    switch (*p++) {
    case '|':
      bar_type <<= 4;
      bar_type |= 1;
      continue;
    case '[':
      bar_type <<= 4;
      bar_type |= 2;
      continue;
    case ']':
      bar_type <<= 4;
      bar_type |= 3;
      continue;
    case ':':
      bar_type <<= 4;
      bar_type |= 4;
      continue;
    default:
      break;
    }
    break;
  }
  return bar_type;
}


x86 assembly (clang, -O0):
<get_dblrepbar>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x10(%rbp)
sub    $0x3a,%eax
je     11aa <get_dblrepbar+0xaa>
jmp    1132 <get_dblrepbar+0x32>
mov    -0x10(%rbp),%eax
sub    $0x5b,%eax
je     117c <get_dblrepbar+0x7c>
jmp    1143 <get_dblrepbar+0x43>
mov    -0x10(%rbp),%eax
sub    $0x5d,%eax
je     1193 <get_dblrepbar+0x93>
jmp    1154 <get_dblrepbar+0x54>
mov    -0x10(%rbp),%eax
sub    $0x7c,%eax
jne    11c1 <get_dblrepbar+0xc1>
jmp    1165 <get_dblrepbar+0x65>
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <get_dblrepbar+0xf>
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <get_dblrepbar+0xf>
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x3,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <get_dblrepbar+0xf>
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <get_dblrepbar+0xf>
jmp    11c6 <get_dblrepbar+0xc6>
jmp    11cb <get_dblrepbar+0xcb>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dblrepbar>:
xor    %eax,%eax
jmp    111e <get_dblrepbar+0x1e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x4,%ecx
add    $0x1,%rdi
shl    $0x4,%eax
or     %ecx,%eax
movsbl (%rdi),%edx
cmp    $0x5c,%edx
jg     1140 <get_dblrepbar+0x40>
cmp    $0x3a,%edx
je     1110 <get_dblrepbar+0x10>
mov    $0x2,%ecx
cmp    $0x5b,%edx
je     1115 <get_dblrepbar+0x15>
jmp    1167 <get_dblrepbar+0x67>
nopw   0x0(%rax,%rax,1)
cmp    $0x5d,%edx
je     1160 <get_dblrepbar+0x60>
cmp    $0x7c,%edx
jne    1167 <get_dblrepbar+0x67>
mov    $0x1,%ecx
jmp    1115 <get_dblrepbar+0x15>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x3,%ecx
jmp    1115 <get_dblrepbar+0x15>
ret

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

LLVM IR (-O2):
define i32 @get_dblrepbar(i8* nocapture %0) {
br label %2
2: ; preds = %9, %1
%3 = phi i8* [ %0, %1 ], [ %5, %9 ]
%4 = phi i32 [ 0, %1 ], [ %12, %9 ]
%5 = getelementptr inbounds i8, i8* %3, i64 1
%6 = load i8, i8* %3
%7 = sext i8 %6 to i32
switch i32 %7, label %15 [
i32 124, label %8
i32 91, label %9
i32 93, label %13
i32 58, label %14
]
8: ; preds = %2
br label %9
9: ; preds = %2, %8, %13, %14
%10 = phi i32 [ 1, %8 ], [ 3, %13 ], [ 4, %14 ], [ 2, %2 ]
%11 = shl i32 %4, 4
%12 = or i32 %11, %10
br label %2
13: ; preds = %2
br label %9
14: ; preds = %2
br label %9
15: ; preds = %2
ret i32 %4
}