void search(int c) {
  extern int brace, brack, paren;
  if (c == '{')
    --brace;
  else if (c == '}')
    ++brace;
  else if (c == '[')
    --brack;
  else if (c == ']')
    ++brack;
  else if (c == '(')
    --paren;
  else if (c == ')')
    ++paren;
}


x86 assembly (clang, -O0):
<search>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0x7b,-0x4(%rbp)
jne    112b <search+0x2b>
mov    0x2eb0(%rip),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    0x2ea4(%rip),%rax
mov    %ecx,(%rax)
jmp    11f3 <search+0xf3>
cmpl   $0x7d,-0x4(%rbp)
jne    114f <search+0x4f>
mov    0x2e8c(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2e80(%rip),%rax
mov    %ecx,(%rax)
jmp    11ee <search+0xee>
cmpl   $0x5b,-0x4(%rbp)
jne    1173 <search+0x73>
mov    0x2e90(%rip),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    0x2e84(%rip),%rax
mov    %ecx,(%rax)
jmp    11e9 <search+0xe9>
cmpl   $0x5d,-0x4(%rbp)
jne    1197 <search+0x97>
mov    0x2e6c(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2e60(%rip),%rax
mov    %ecx,(%rax)
jmp    11e4 <search+0xe4>
cmpl   $0x28,-0x4(%rbp)
jne    11bb <search+0xbb>
mov    0x2e30(%rip),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    0x2e24(%rip),%rax
mov    %ecx,(%rax)
jmp    11df <search+0xdf>
cmpl   $0x29,-0x4(%rbp)
jne    11da <search+0xda>
mov    0x2e0c(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2e00(%rip),%rax
mov    %ecx,(%rax)
jmp    11df <search+0xdf>
jmp    11e4 <search+0xe4>
jmp    11e9 <search+0xe9>
jmp    11ee <search+0xee>
jmp    11f3 <search+0xf3>
pop    %rbp
ret

x86 assembly (clang, -O2):
<search>:
mov    $0xffffffff,%eax
lea    -0x5b(%rdi),%edx
cmp    $0x22,%edx
ja     1132 <search+0x32>
mov    0x2eb4(%rip),%rcx
lea    0xee5(%rip),%rsi
movslq (%rsi,%rdx,4),%rdx
add    %rsi,%rdx
jmp    *%rdx
mov    $0x1,%eax
mov    0x2ec0(%rip),%rcx
jmp    114f <search+0x4f>
cmp    $0x28,%edi
je     1141 <search+0x41>
cmp    $0x29,%edi
jne    1151 <search+0x51>
mov    $0x1,%eax
mov    0x2e90(%rip),%rcx
jmp    114f <search+0x4f>
mov    $0x1,%eax
add    %eax,(%rcx)
ret

LLVM IR (-O0):
@brace = external global i32
@brack = external global i32
@paren = external global i32
define void @search(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 123
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* @brace
%7 = add nsw i32 %6, -1
store i32 %7, i32* @brace
br label %43
8: ; preds = %1
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 125
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* @brace
%13 = add nsw i32 %12, 1
store i32 %13, i32* @brace
br label %42
14: ; preds = %8
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 91
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* @brack
%19 = add nsw i32 %18, -1
store i32 %19, i32* @brack
br label %41
20: ; preds = %14
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 93
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* @brack
%25 = add nsw i32 %24, 1
store i32 %25, i32* @brack
br label %40
26: ; preds = %20
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 40
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* @paren
%31 = add nsw i32 %30, -1
store i32 %31, i32* @paren
br label %39
32: ; preds = %26
%33 = load i32, i32* %2
%34 = icmp eq i32 %33, 41
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i32, i32* @paren
%37 = add nsw i32 %36, 1
store i32 %37, i32* @paren
br label %38
38: ; preds = %35, %32
br label %39
39: ; preds = %38, %29
br label %40
40: ; preds = %39, %23
br label %41
41: ; preds = %40, %17
br label %42
42: ; preds = %41, %11
br label %43
43: ; preds = %42, %5
ret void
}

LLVM IR (-O2):
@brace = external global i32
@brack = external global i32
@paren = external global i32
define void @search(i32 %0) {
switch i32 %0, label %12 [
i32 123, label %7
i32 125, label %2
i32 91, label %3
i32 93, label %4
i32 40, label %5
i32 41, label %6
]
2: ; preds = %1
br label %7
3: ; preds = %1
br label %7
4: ; preds = %1
br label %7
5: ; preds = %1
br label %7
6: ; preds = %1
br label %7
7: ; preds = %1, %3, %5, %6, %4, %2
%8 = phi i32* [ @brace, %2 ], [ @brack, %4 ], [ @paren, %6 ], [ @paren, %5 ], [ @brack, %3 ], [ @brace, %1 ]
%9 = phi i32 [ 1, %2 ], [ 1, %4 ], [ 1, %6 ], [ -1, %5 ], [ -1, %3 ], [ -1, %1 ]
%10 = load i32, i32* %8
%11 = add nsw i32 %10, %9
store i32 %11, i32* %8
br label %12
12: ; preds = %7, %1
ret void
}