char corresponding_bracket(char bracket) {
  if (bracket == '[')
    return ']';
  if (bracket == ']')
    return '[';
  if (bracket == '(')
    return ')';
  if (bracket == ')')
    return '(';
  if (bracket == '}')
    return '{';
  if (bracket == '{')
    return '}';
  return ' ';
}


x86 assembly (clang, -O0):
<corresponding_bracket>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x5b,%eax
jne    1120 <corresponding_bracket+0x20>
movb   $0x5d,-0x1(%rbp)
jmp    1192 <corresponding_bracket+0x92>
movsbl -0x2(%rbp),%eax
cmp    $0x5d,%eax
jne    1136 <corresponding_bracket+0x36>
movb   $0x5b,-0x1(%rbp)
jmp    1192 <corresponding_bracket+0x92>
movsbl -0x2(%rbp),%eax
cmp    $0x28,%eax
jne    114c <corresponding_bracket+0x4c>
movb   $0x29,-0x1(%rbp)
jmp    1192 <corresponding_bracket+0x92>
movsbl -0x2(%rbp),%eax
cmp    $0x29,%eax
jne    1162 <corresponding_bracket+0x62>
movb   $0x28,-0x1(%rbp)
jmp    1192 <corresponding_bracket+0x92>
movsbl -0x2(%rbp),%eax
cmp    $0x7d,%eax
jne    1178 <corresponding_bracket+0x78>
movb   $0x7b,-0x1(%rbp)
jmp    1192 <corresponding_bracket+0x92>
movsbl -0x2(%rbp),%eax
cmp    $0x7b,%eax
jne    118e <corresponding_bracket+0x8e>
movb   $0x7d,-0x1(%rbp)
jmp    1192 <corresponding_bracket+0x92>
movb   $0x20,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<corresponding_bracket>:
lea    -0x5b(%rdi),%ecx
cmp    $0x22,%cl
ja     1120 <corresponding_bracket+0x20>
mov    $0x5d,%al
movzbl %cl,%ecx
lea    0xeec(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x5b,%al
ret
cmp    $0x28,%dil
je     1138 <corresponding_bracket+0x38>
cmp    $0x29,%dil
jne    112f <corresponding_bracket+0x2f>
mov    $0x28,%al
ret
mov    $0x20,%al
ret
mov    $0x7d,%al
ret
mov    $0x7b,%al
ret
mov    $0x29,%al
ret

LLVM IR (-O0):
define signext i8 @corresponding_bracket(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
%6 = icmp eq i32 %5, 91
br i1 %6, label %7, label %8
7: ; preds = %1
store i8 93, i8* %2
br label %34
8: ; preds = %1
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 93
br i1 %11, label %12, label %13
12: ; preds = %8
store i8 91, i8* %2
br label %34
13: ; preds = %8
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 40
br i1 %16, label %17, label %18
17: ; preds = %13
store i8 41, i8* %2
br label %34
18: ; preds = %13
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 41
br i1 %21, label %22, label %23
22: ; preds = %18
store i8 40, i8* %2
br label %34
23: ; preds = %18
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 125
br i1 %26, label %27, label %28
27: ; preds = %23
store i8 123, i8* %2
br label %34
28: ; preds = %23
%29 = load i8, i8* %3
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 123
br i1 %31, label %32, label %33
32: ; preds = %28
store i8 125, i8* %2
br label %34
33: ; preds = %28
store i8 32, i8* %2
br label %34
34: ; preds = %33, %32, %27, %22, %17, %12, %7
%35 = load i8, i8* %2
ret i8 %35
}

LLVM IR (-O2):
define signext i8 @corresponding_bracket(i8 signext %0) {
switch i8 %0, label %7 [
i8 91, label %8
i8 93, label %2
i8 40, label %3
i8 41, label %4
i8 125, label %5
i8 123, label %6
]
2: ; preds = %1
br label %8
3: ; preds = %1
br label %8
4: ; preds = %1
br label %8
5: ; preds = %1
br label %8
6: ; preds = %1
br label %8
7: ; preds = %1
br label %8
8: ; preds = %1, %7, %6, %5, %4, %3, %2
%9 = phi i8 [ 91, %2 ], [ 41, %3 ], [ 40, %4 ], [ 123, %5 ], [ 125, %6 ], [ 32, %7 ], [ 93, %1 ]
ret i8 %9
}