char bracketrev(char b) {
  switch (b) {
  case '<':
    return '>';
  case '(':
    return ')';
  case '[':
    return ']';
  case '{':
    return '}';
  case '>':
    return '<';
  case ')':
    return '(';
  case ']':
    return '[';
  case '}':
    return '{';
  default:
    return '\0';
  }
}


x86 assembly (clang, -O0):
<bracketrev>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x28,%eax
je     119f <bracketrev+0x9f>
jmp    111f <bracketrev+0x1f>
mov    -0x8(%rbp),%eax
sub    $0x29,%eax
je     11c3 <bracketrev+0xc3>
jmp    1130 <bracketrev+0x30>
mov    -0x8(%rbp),%eax
sub    $0x3c,%eax
je     1196 <bracketrev+0x96>
jmp    1141 <bracketrev+0x41>
mov    -0x8(%rbp),%eax
sub    $0x3e,%eax
je     11ba <bracketrev+0xba>
jmp    1152 <bracketrev+0x52>
mov    -0x8(%rbp),%eax
sub    $0x5b,%eax
je     11a8 <bracketrev+0xa8>
jmp    1163 <bracketrev+0x63>
mov    -0x8(%rbp),%eax
sub    $0x5d,%eax
je     11cc <bracketrev+0xcc>
jmp    1174 <bracketrev+0x74>
mov    -0x8(%rbp),%eax
sub    $0x7b,%eax
je     11b1 <bracketrev+0xb1>
jmp    1185 <bracketrev+0x85>
mov    -0x8(%rbp),%eax
sub    $0x7d,%eax
je     11d5 <bracketrev+0xd5>
jmp    11de <bracketrev+0xde>
movb   $0x3e,-0x1(%rbp)
jmp    11e2 <bracketrev+0xe2>
movb   $0x29,-0x1(%rbp)
jmp    11e2 <bracketrev+0xe2>
movb   $0x5d,-0x1(%rbp)
jmp    11e2 <bracketrev+0xe2>
movb   $0x7d,-0x1(%rbp)
jmp    11e2 <bracketrev+0xe2>
movb   $0x3c,-0x1(%rbp)
jmp    11e2 <bracketrev+0xe2>
movb   $0x28,-0x1(%rbp)
jmp    11e2 <bracketrev+0xe2>
movb   $0x5b,-0x1(%rbp)
jmp    11e2 <bracketrev+0xe2>
movb   $0x7b,-0x1(%rbp)
jmp    11e2 <bracketrev+0xe2>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bracketrev>:
lea    -0x28(%rdi),%ecx
cmp    $0x35,%ecx
ja     111d <bracketrev+0x1d>
mov    $0x3e,%al
lea    0xeef(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x29,%al
ret
cmp    $0x7b,%edi
je     1139 <bracketrev+0x39>
cmp    $0x7d,%edi
jne    112a <bracketrev+0x2a>
mov    $0x7b,%al
ret
xor    %eax,%eax
ret
mov    $0x28,%al
ret
mov    $0x3c,%al
ret
mov    $0x5d,%al
ret
mov    $0x5b,%al
ret
mov    $0x7d,%al
ret

LLVM IR (-O0):
define signext i8 @bracketrev(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %14 [
i32 60, label %6
i32 40, label %7
i32 91, label %8
i32 123, label %9
i32 62, label %10
i32 41, label %11
i32 93, label %12
i32 125, label %13
]
6: ; preds = %1
store i8 62, i8* %2
br label %15
7: ; preds = %1
store i8 41, i8* %2
br label %15
8: ; preds = %1
store i8 93, i8* %2
br label %15
9: ; preds = %1
store i8 125, i8* %2
br label %15
10: ; preds = %1
store i8 60, i8* %2
br label %15
11: ; preds = %1
store i8 40, i8* %2
br label %15
12: ; preds = %1
store i8 91, i8* %2
br label %15
13: ; preds = %1
store i8 123, i8* %2
br label %15
14: ; preds = %1
store i8 0, i8* %2
br label %15
15: ; preds = %14, %13, %12, %11, %10, %9, %8, %7, %6
%16 = load i8, i8* %2
ret i8 %16
}

LLVM IR (-O2):
define signext i8 @bracketrev(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %10 [
i32 60, label %11
i32 40, label %3
i32 91, label %4
i32 123, label %5
i32 62, label %6
i32 41, label %7
i32 93, label %8
i32 125, label %9
]
3: ; preds = %1
br label %11
4: ; preds = %1
br label %11
5: ; preds = %1
br label %11
6: ; preds = %1
br label %11
7: ; preds = %1
br label %11
8: ; preds = %1
br label %11
9: ; preds = %1
br label %11
10: ; preds = %1
br label %11
11: ; preds = %1, %10, %9, %8, %7, %6, %5, %4, %3
%12 = phi i8 [ 0, %10 ], [ 123, %9 ], [ 91, %8 ], [ 40, %7 ], [ 60, %6 ], [ 125, %5 ], [ 93, %4 ], [ 41, %3 ], [ 62, %1 ]
ret i8 %12
}