#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *strchr(char *, char);
char *strsep(char **, char *);
int at_parse_brackets(FILE *fp, char *buf, int (*cb)(FILE *, const char *)) {
  char *start, *end, *str;
  if ((!(start = strchr(buf, '('))) || (!(end = strchr(++start, ')'))))
    return -1;
  *end = '\0';
  while ((str = strsep(&start, ",")))
    cb(fp, str);
  return 0;
}


x86 assembly (clang, -O0):
<at_parse_brackets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x28,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1174 <at_parse_brackets+0x54>
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
mov    %rdi,-0x28(%rbp)
mov    $0x29,%esi
call   1030 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1180 <at_parse_brackets+0x60>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bf <at_parse_brackets+0x9f>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x28(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1040 <strsep@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     11b8 <at_parse_brackets+0x98>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   *%rax
jmp    1187 <at_parse_brackets+0x67>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<at_parse_brackets>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    $0x28,%esi
call   1030 <strchr@plt>
mov    $0xffffffff,%r15d
test   %rax,%rax
je     11a9 <at_parse_brackets+0x89>
add    $0x1,%rax
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
mov    $0x29,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11a9 <at_parse_brackets+0x89>
movb   $0x0,(%rax)
lea    0xe91(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1040 <strsep@plt>
xor    %r15d,%r15d
test   %rax,%rax
je     11a9 <at_parse_brackets+0x89>
lea    0xe78(%rip),%r12
lea    0x8(%rsp),%rbp
nopl   (%rax)
mov    %rbx,%rdi
mov    %rax,%rsi
call   *%r14
mov    %rbp,%rdi
mov    %r12,%rsi
call   1040 <strsep@plt>
test   %rax,%rax
jne    1190 <at_parse_brackets+0x70>
mov    %r15d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
define i32 @at_parse_brackets(i32* %0, i8* %1, i32 (i32*, i8*)* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32 (i32*, i8*)*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 (i32*, i8*)* %2, i32 (i32*, i8*)** %7
%11 = load i8*, i8** %6
%12 = call i8* @strchr(i8* %11, i8 signext 40)
store i8* %12, i8** %8
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %19
14: ; preds = %3
%15 = load i8*, i8** %8
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %8
%17 = call i8* @strchr(i8* %16, i8 signext 41)
store i8* %17, i8** %9
%18 = icmp ne i8* %17, null
br i1 %18, label %20, label %19
19: ; preds = %14, %3
store i32 -1, i32* %4
br label %31
20: ; preds = %14
%21 = load i8*, i8** %9
store i8 0, i8* %21
br label %22
22: ; preds = %25, %20
%23 = call i8* @strsep(i8** %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %23, i8** %10
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i32 (i32*, i8*)*, i32 (i32*, i8*)** %7
%27 = load i32*, i32** %5
%28 = load i8*, i8** %10
%29 = call i32 %26(i32* %27, i8* %28)
br label %22
30: ; preds = %22
store i32 0, i32* %4
br label %31
31: ; preds = %30, %19
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
define i32 @at_parse_brackets(i32* %0, i8* %1, i32 (i32*, i8*)* nocapture %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = tail call i8* @strchr(i8* dereferenceable(1) %1, i8 signext 40)
%7 = icmp eq i8* %6, null
br i1 %7, label %20, label %8
8: ; preds = %3
%9 = getelementptr inbounds i8, i8* %6, i64 1
store i8* %9, i8** %4
%10 = tail call i8* @strchr(i8* %9, i8 signext 41)
%11 = icmp eq i8* %10, null
br i1 %11, label %20, label %12
12: ; preds = %8
store i8 0, i8* %10
%13 = call i8* @strsep(i8** %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %20, label %15
15: ; preds = %12, %15
%16 = phi i8* [ %18, %15 ], [ %13, %12 ]
%17 = call i32 %2(i32* %0, i8* %16)
%18 = call i8* @strsep(i8** %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %15
20: ; preds = %15, %12, %3, %8
%21 = phi i32 [ -1, %8 ], [ -1, %3 ], [ 0, %12 ], [ 0, %15 ]
ret i32 %21
}