#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ *memchr(char *, char, int);
char *strchr(char *, char);
int _advance_past_brackets(char *tok, char **str) {
  if (memchr(tok, '[', *str - tok) != NULL &&
      memchr(tok, ']', *str - tok) == NULL) {
    char *q = strchr(*str, ']');
    if (q && memchr(*str, '[', q - *str) == NULL) {
      *str = q + 1;
      return (1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<_advance_past_brackets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
mov    $0x5b,%esi
call   1040 <memchr@plt>
cmp    $0x0,%rax
je     11eb <_advance_past_brackets+0xcb>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
mov    $0x5d,%esi
call   1040 <memchr@plt>
cmp    $0x0,%rax
jne    11eb <_advance_past_brackets+0xcb>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    $0x5d,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11e6 <_advance_past_brackets+0xc6>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
mov    %eax,%edx
mov    $0x5b,%esi
call   1040 <memchr@plt>
cmp    $0x0,%rax
jne    11e6 <_advance_past_brackets+0xc6>
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11f2 <_advance_past_brackets+0xd2>
jmp    11eb <_advance_past_brackets+0xcb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_advance_past_brackets>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    (%rsi),%edx
sub    %ebp,%edx
mov    $0x5b,%esi
call   1040 <memchr@plt>
xor    %r15d,%r15d
test   %rax,%rax
je     1159 <_advance_past_brackets+0x39>
mov    (%rbx),%edx
sub    %ebp,%edx
mov    %rbp,%rdi
mov    $0x5d,%esi
call   1040 <memchr@plt>
test   %rax,%rax
je     1167 <_advance_past_brackets+0x47>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rbp
mov    %rbp,%rdi
mov    $0x5d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1159 <_advance_past_brackets+0x39>
mov    %rax,%r14
mov    %r14d,%edx
sub    %ebp,%edx
mov    %rbp,%rdi
mov    $0x5b,%esi
call   1040 <memchr@plt>
test   %rax,%rax
jne    1159 <_advance_past_brackets+0x39>
add    $0x1,%r14
mov    %r14,(%rbx)
mov    $0x1,%r15d
jmp    1159 <_advance_past_brackets+0x39>

LLVM IR (-O0):
define i32 @_advance_past_brackets(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
%7 = load i8*, i8** %4
%8 = load i8**, i8*** %5
%9 = load i8*, i8** %8
%10 = load i8*, i8** %4
%11 = ptrtoint i8* %9 to i64
%12 = ptrtoint i8* %10 to i64
%13 = sub i64 %11, %12
%14 = trunc i64 %13 to i32
%15 = call i32* @memchr(i8* %7, i8 signext 91, i32 %14)
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %51
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = load i8**, i8*** %5
%20 = load i8*, i8** %19
%21 = load i8*, i8** %4
%22 = ptrtoint i8* %20 to i64
%23 = ptrtoint i8* %21 to i64
%24 = sub i64 %22, %23
%25 = trunc i64 %24 to i32
%26 = call i32* @memchr(i8* %18, i8 signext 93, i32 %25)
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %51
28: ; preds = %17
%29 = load i8**, i8*** %5
%30 = load i8*, i8** %29
%31 = call i8* @strchr(i8* %30, i8 signext 93)
store i8* %31, i8** %6
%32 = load i8*, i8** %6
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %50
34: ; preds = %28
%35 = load i8**, i8*** %5
%36 = load i8*, i8** %35
%37 = load i8*, i8** %6
%38 = load i8**, i8*** %5
%39 = load i8*, i8** %38
%40 = ptrtoint i8* %37 to i64
%41 = ptrtoint i8* %39 to i64
%42 = sub i64 %40, %41
%43 = trunc i64 %42 to i32
%44 = call i32* @memchr(i8* %36, i8 signext 91, i32 %43)
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %50
46: ; preds = %34
%47 = load i8*, i8** %6
%48 = getelementptr inbounds i8, i8* %47, i64 1
%49 = load i8**, i8*** %5
store i8* %48, i8** %49
store i32 1, i32* %3
br label %52
50: ; preds = %34, %28
br label %51
51: ; preds = %50, %17, %2
store i32 0, i32* %3
br label %52
52: ; preds = %51, %46
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
define i32 @_advance_past_brackets(i8* %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = ptrtoint i8* %3 to i64
%5 = ptrtoint i8* %0 to i64
%6 = sub i64 %4, %5
%7 = trunc i64 %6 to i32
%8 = tail call i32* @memchr(i8* %0, i8 signext 91, i32 %7)
%9 = icmp eq i32* %8, null
br i1 %9, label %30, label %10
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = ptrtoint i8* %11 to i64
%13 = sub i64 %12, %5
%14 = trunc i64 %13 to i32
%15 = tail call i32* @memchr(i8* %0, i8 signext 93, i32 %14)
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %30
17: ; preds = %10
%18 = load i8*, i8** %1
%19 = tail call i8* @strchr(i8* dereferenceable(1) %18, i8 signext 93)
%20 = icmp eq i8* %19, null
br i1 %20, label %30, label %21
21: ; preds = %17
%22 = ptrtoint i8* %19 to i64
%23 = ptrtoint i8* %18 to i64
%24 = sub i64 %22, %23
%25 = trunc i64 %24 to i32
%26 = tail call i32* @memchr(i8* %18, i8 signext 91, i32 %25)
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %30
28: ; preds = %21
%29 = getelementptr inbounds i8, i8* %19, i64 1
store i8* %29, i8** %1
br label %30
30: ; preds = %17, %21, %2, %10, %28
%31 = phi i32 [ 1, %28 ], [ 0, %10 ], [ 0, %2 ], [ 0, %21 ], [ 0, %17 ]
ret i32 %31
}