char *match_bracket(str)
char *str;
{
  int depth;
  char *match();
  depth = 1;
  while (*str && depth != 0) {
    switch (*str++) {
    case '\'':
      str = match('\'', str + 1) + 1;
      break;
    case '"':
      str = match('"', str + 1) + 1;
      break;
    case '(':
      depth++;
      break;
    case ')':
      depth--;
      break;
    }
  }
  return (str - 1);
}


x86 assembly (clang, -O0):
<match_bracket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xd(%rbp)
je     1142 <match_bracket+0x32>
cmpl   $0x0,-0xc(%rbp)
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1152 <match_bracket+0x42>
jmp    11e8 <match_bracket+0xd8>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
add    $0xffffffde,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x7,%eax
ja     11e3 <match_bracket+0xd3>
mov    -0x18(%rbp),%rax
lea    0xe7f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rsi
add    $0x1,%rsi
mov    $0x27,%edi
mov    $0x0,%al
call   1030 <match@plt>
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11e3 <match_bracket+0xd3>
mov    -0x8(%rbp),%rsi
add    $0x1,%rsi
mov    $0x22,%edi
mov    $0x0,%al
call   1030 <match@plt>
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11e3 <match_bracket+0xd3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e3 <match_bracket+0xd3>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <match_bracket+0x13>
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_bracket>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rsi
mov    (%rdi),%cl
test   %cl,%cl
je     11b0 <match_bracket+0xa0>
mov    $0x1,%ebx
lea    0xed3(%rip),%r14
nopl   (%rax)
movsbl %cl,%ecx
lea    0x1(%rsi),%rax
add    $0xffffffde,%ecx
cmp    $0x7,%ecx
ja     11a0 <match_bracket+0x90>
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
jmp    *%rcx
add    $0x2,%rsi
mov    $0x22,%edi
jmp    1169 <match_bracket+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x2,%rsi
mov    $0x27,%edi
xor    %eax,%eax
call   1030 <match@plt>
add    $0x1,%rax
jmp    11a0 <match_bracket+0x90>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebx
jmp    11a0 <match_bracket+0x90>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rax),%ecx
test   %cl,%cl
je     11b3 <match_bracket+0xa3>
mov    %rax,%rsi
test   %ebx,%ebx
jne    1130 <match_bracket+0x20>
jmp    11b3 <match_bracket+0xa3>
mov    %rsi,%rax
add    $0xffffffffffffffff,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @match_bracket(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 1, i32* %3
br label %4
4: ; preds = %35, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
br label %12
12: ; preds = %9, %4
%13 = phi i1 [ false, %4 ], [ %11, %9 ]
br i1 %13, label %14, label %36
14: ; preds = %12
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %2
%17 = load i8, i8* %15
%18 = sext i8 %17 to i32
switch i32 %18, label %35 [
i32 39, label %19
i32 34, label %24
i32 40, label %29
i32 41, label %32
]
19: ; preds = %14
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = call i8* (i32, i8*, ...) bitcast (i8* (...)* @match to i8* (i32, i8*, ...)*)(i32 39, i8* %21)
%23 = getelementptr inbounds i8, i8* %22, i64 1
store i8* %23, i8** %2
br label %35
24: ; preds = %14
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = call i8* (i32, i8*, ...) bitcast (i8* (...)* @match to i8* (i32, i8*, ...)*)(i32 34, i8* %26)
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8* %28, i8** %2
br label %35
29: ; preds = %14
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %35
32: ; preds = %14
%33 = load i32, i32* %3
%34 = add nsw i32 %33, -1
store i32 %34, i32* %3
br label %35
35: ; preds = %14, %32, %29, %24, %19
br label %4
36: ; preds = %12
%37 = load i8*, i8** %2
%38 = getelementptr inbounds i8, i8* %37, i64 -1
ret i8* %38
}

LLVM IR (-O2):
define i8* @match_bracket(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %29, label %4
4: ; preds = %1, %22
%5 = phi i8 [ %25, %22 ], [ %2, %1 ]
%6 = phi i32 [ %24, %22 ], [ 1, %1 ]
%7 = phi i8* [ %23, %22 ], [ %0, %1 ]
%8 = sext i8 %5 to i32
%9 = getelementptr inbounds i8, i8* %7, i64 1
switch i32 %8, label %22 [
i32 39, label %10
i32 34, label %14
i32 40, label %18
i32 41, label %20
]
10: ; preds = %4
%11 = getelementptr inbounds i8, i8* %7, i64 2
%12 = tail call i8* (i32, i8*, ...) bitcast (i8* (...)* @match to i8* (i32, i8*, ...)*)(i32 39, i8* %11)
%13 = getelementptr inbounds i8, i8* %12, i64 1
br label %22
14: ; preds = %4
%15 = getelementptr inbounds i8, i8* %7, i64 2
%16 = tail call i8* (i32, i8*, ...) bitcast (i8* (...)* @match to i8* (i32, i8*, ...)*)(i32 34, i8* %15)
%17 = getelementptr inbounds i8, i8* %16, i64 1
br label %22
18: ; preds = %4
%19 = add nsw i32 %6, 1
br label %22
20: ; preds = %4
%21 = add nsw i32 %6, -1
br label %22
22: ; preds = %4, %20, %18, %14, %10
%23 = phi i8* [ %9, %4 ], [ %9, %20 ], [ %9, %18 ], [ %17, %14 ], [ %13, %10 ]
%24 = phi i32 [ %6, %4 ], [ %21, %20 ], [ %19, %18 ], [ %6, %14 ], [ %6, %10 ]
%25 = load i8, i8* %23
%26 = icmp ne i8 %25, 0
%27 = icmp ne i32 %24, 0
%28 = select i1 %26, i1 %27, i1 false
br i1 %28, label %4, label %29
29: ; preds = %22, %1
%30 = phi i8* [ %0, %1 ], [ %23, %22 ]
%31 = getelementptr inbounds i8, i8* %30, i64 -1
ret i8* %31
}