const char *through(const char *const cur, const char *const end) {
  if (cur == end) {
    return end;
  }
  switch (*cur) {
  case '[': {
    through(cur + 1, end);
  } break;
  case ']': {
    return cur;
  } break;
  default:
    break;
  }
  return through(cur + 1, end);
}


x86 assembly (clang, -O0):
<through>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    113b <through+0x2b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a1 <through+0x91>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x5b,%eax
je     1164 <through+0x54>
jmp    1153 <through+0x43>
mov    -0x1c(%rbp),%eax
sub    $0x5d,%eax
je     117a <through+0x6a>
jmp    1187 <through+0x77>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <through@plt>
jmp    118c <through+0x7c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a1 <through+0x91>
jmp    118c <through+0x7c>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <through@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<through>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cmp    %rsi,%rdi
je     1157 <through+0x47>
mov    %rsi,%r14
jmp    1145 <through+0x35>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbx),%rdi
mov    %r14,%rsi
call   1030 <through@plt>
add    $0x1,%rbx
cmp    %r14,%rbx
je     1154 <through+0x44>
movsbl (%rbx),%eax
cmp    $0x5b,%eax
je     1130 <through+0x20>
cmp    $0x5d,%eax
jne    113c <through+0x2c>
jmp    1157 <through+0x47>
mov    %r14,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @through(i8* %0, i8* readnone %1) {
%3 = icmp eq i8* %0, %1
br i1 %3, label %14, label %4
4: ; preds = %2, %11
%5 = phi i8* [ %12, %11 ], [ %0, %2 ]
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
switch i32 %7, label %11 [
i32 91, label %8
i32 93, label %14
]
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %5, i64 1
%10 = tail call i8* @through(i8* %9, i8* %1)
br label %11
11: ; preds = %4, %8
%12 = getelementptr inbounds i8, i8* %5, i64 1
%13 = icmp eq i8* %12, %1
br i1 %13, label %14, label %4
14: ; preds = %11, %4, %2
%15 = phi i8* [ %0, %2 ], [ %5, %4 ], [ %1, %11 ]
ret i8* %15
}