#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*/ strcspn(char *, char *);
char *strdup_len(char *, int);
char *get_option(char **pp, int *state) {
  char *p, *p0, *option = NULL;
  if (*pp) {
    for (p = *pp;; p++) {
      switch (*p) {
      case '[':
        *state += 1;
        continue;
      case ']':
        *state -= 1;
        if (*state > 0)
          continue;
        p = NULL;
        break;
      case ' ':
      case '\t':
      case '\r':
      case ',':
      case '-':
        continue;
      case '\n':
        if (*state > 0 || p[1] == ' ')
          continue;
        p = NULL;
        break;
      case '\0':
        p = NULL;
        break;
      default:
        p0 = p;
        p += strcspn(p0, " \t\r\n,]");
        option = strdup_len(p0, p - p0);
        break;
      }
      break;
    }
    *pp = p;
  }
  return option;
}


x86 assembly (clang, -O0):
<get_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     12c1 <get_option+0x1a1>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x2c(%rbp)
test   %eax,%eax
je     1251 <get_option+0x131>
jmp    1168 <get_option+0x48>
mov    -0x2c(%rbp),%eax
sub    $0x9,%eax
je     121c <get_option+0xfc>
jmp    1179 <get_option+0x59>
mov    -0x2c(%rbp),%eax
sub    $0xa,%eax
je     1221 <get_option+0x101>
jmp    118a <get_option+0x6a>
mov    -0x2c(%rbp),%eax
sub    $0xd,%eax
je     121c <get_option+0xfc>
jmp    119b <get_option+0x7b>
mov    -0x2c(%rbp),%eax
sub    $0x20,%eax
je     121c <get_option+0xfc>
jmp    11ac <get_option+0x8c>
mov    -0x2c(%rbp),%eax
add    $0xffffffd4,%eax
sub    $0x2,%eax
jb     121c <get_option+0xfc>
jmp    11c0 <get_option+0xa0>
mov    -0x2c(%rbp),%eax
sub    $0x5b,%eax
je     11e2 <get_option+0xc2>
jmp    11d1 <get_option+0xb1>
mov    -0x2c(%rbp),%eax
sub    $0x5d,%eax
je     11f2 <get_option+0xd2>
jmp    125e <get_option+0x13e>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    12a5 <get_option+0x185>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jle    120f <get_option+0xef>
jmp    12a5 <get_option+0x185>
movq   $0x0,-0x18(%rbp)
jmp    12a0 <get_option+0x180>
jmp    12a5 <get_option+0x185>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jg     123f <get_option+0x11f>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x20,%eax
jne    1244 <get_option+0x124>
jmp    12a5 <get_option+0x185>
movq   $0x0,-0x18(%rbp)
jmp    12a0 <get_option+0x180>
movq   $0x0,-0x18(%rbp)
jmp    12a0 <get_option+0x180>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xd8f(%rip),%rsi
call   1040 <strcspn@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
call   1030 <strdup_len@plt>
mov    %rax,-0x28(%rbp)
jmp    12b6 <get_option+0x196>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1151 <get_option+0x31>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_option>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%rbx
test   %rbx,%rbx
je     1193 <get_option+0x73>
mov    %rdi,%r14
xor    %r15d,%r15d
movabs $0x300100002200,%rax
jmp    1154 <get_option+0x34>
mov    (%rsi),%ecx
lea    -0x1(%rcx),%edx
mov    %edx,(%rsi)
cmp    $0x1,%ecx
jle    118f <get_option+0x6f>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
movsbl (%rbx),%ecx
cmp    $0x2d,%ecx
ja     1180 <get_option+0x60>
bt     %rcx,%rax
jb     1150 <get_option+0x30>
cmp    $0xa,%rcx
jne    1175 <get_option+0x55>
cmpl   $0x0,(%rsi)
jg     1150 <get_option+0x30>
cmpb   $0x20,0x1(%rbx)
je     1150 <get_option+0x30>
jmp    118f <get_option+0x6f>
test   %rcx,%rcx
je     118f <get_option+0x6f>
nopw   0x0(%rax,%rax,1)
cmp    $0x5d,%ecx
je     113f <get_option+0x1f>
cmp    $0x5b,%ecx
jne    1197 <get_option+0x77>
addl   $0x1,(%rsi)
jmp    1150 <get_option+0x30>
xor    %eax,%eax
jmp    11b5 <get_option+0x95>
xor    %eax,%eax
jmp    11b8 <get_option+0x98>
lea    0xe62(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcspn@plt>
movslq %eax,%rsi
lea    (%rbx,%rsi,1),%r15
mov    %rbx,%rdi
call   1030 <strdup_len@plt>
mov    %r15,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c" \09\0D\0A,]\00"
define i8* @get_option(i8** %0, i32* %1) {
%3 = alloca i8**
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8** %0, i8*** %3
store i32* %1, i32** %4
store i8* null, i8** %7
%8 = load i8**, i8*** %3
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %67
11: ; preds = %2
%12 = load i8**, i8*** %3
%13 = load i8*, i8** %12
store i8* %13, i8** %5
br label %14
14: ; preds = %61, %11
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %45 [
i32 91, label %18
i32 93, label %22
i32 32, label %31
i32 9, label %31
i32 13, label %31
i32 44, label %31
i32 45, label %31
i32 10, label %32
i32 0, label %44
]
18: ; preds = %14
%19 = load i32*, i32** %4
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
store i32 %21, i32* %19
br label %61
22: ; preds = %14
%23 = load i32*, i32** %4
%24 = load i32, i32* %23
%25 = sub nsw i32 %24, 1
store i32 %25, i32* %23
%26 = load i32*, i32** %4
%27 = load i32, i32* %26
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %22
br label %61
30: ; preds = %22
store i8* null, i8** %5
br label %60
31: ; preds = %14, %14, %14, %14, %14
br label %61
32: ; preds = %14
%33 = load i32*, i32** %4
%34 = load i32, i32* %33
%35 = icmp sgt i32 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %32
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 32
br i1 %41, label %42, label %43
42: ; preds = %36, %32
br label %61
43: ; preds = %36
store i8* null, i8** %5
br label %60
44: ; preds = %14
store i8* null, i8** %5
br label %60
45: ; preds = %14
%46 = load i8*, i8** %5
store i8* %46, i8** %6
%47 = load i8*, i8** %6
%48 = call i32 @strcspn(i8* %47, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%49 = load i8*, i8** %5
%50 = sext i32 %48 to i64
%51 = getelementptr inbounds i8, i8* %49, i64 %50
store i8* %51, i8** %5
%52 = load i8*, i8** %6
%53 = load i8*, i8** %5
%54 = load i8*, i8** %6
%55 = ptrtoint i8* %53 to i64
%56 = ptrtoint i8* %54 to i64
%57 = sub i64 %55, %56
%58 = trunc i64 %57 to i32
%59 = call i8* @strdup_len(i8* %52, i32 %58)
store i8* %59, i8** %7
br label %60
60: ; preds = %45, %44, %43, %30
br label %64
61: ; preds = %42, %31, %29, %18
%62 = load i8*, i8** %5
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %5
br label %14
64: ; preds = %60
%65 = load i8*, i8** %5
%66 = load i8**, i8*** %3
store i8* %65, i8** %66
br label %67
67: ; preds = %64, %2
%68 = load i8*, i8** %7
ret i8* %68
}

LLVM IR (-O2):
@.str = [7 x i8] c" \09\0D\0A,]\00"
define i8* @get_option(i8** nocapture %0, i32* nocapture %1) {
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, null
br i1 %4, label %33, label %5
5: ; preds = %2, %28
%6 = phi i8* [ %29, %28 ], [ %3, %2 ]
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %23 [
i32 91, label %9
i32 93, label %12
i32 32, label %28
i32 9, label %28
i32 13, label %28
i32 44, label %28
i32 45, label %28
i32 10, label %16
i32 0, label %30
]
9: ; preds = %5
%10 = load i32, i32* %1
%11 = add nsw i32 %10, 1
store i32 %11, i32* %1
br label %28
12: ; preds = %5
%13 = load i32, i32* %1
%14 = add nsw i32 %13, -1
store i32 %14, i32* %1
%15 = icmp sgt i32 %13, 1
br i1 %15, label %28, label %30
16: ; preds = %5
%17 = load i32, i32* %1
%18 = icmp sgt i32 %17, 0
br i1 %18, label %28, label %19
19: ; preds = %16
%20 = getelementptr inbounds i8, i8* %6, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 32
br i1 %22, label %28, label %30
23: ; preds = %5
%24 = tail call i32 @strcspn(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %6, i64 %25
%27 = tail call i8* @strdup_len(i8* %6, i32 %24)
br label %30
28: ; preds = %16, %19, %5, %5, %5, %5, %5, %12, %9
%29 = getelementptr inbounds i8, i8* %6, i64 1
br label %5
30: ; preds = %5, %19, %12, %23
%31 = phi i8* [ %26, %23 ], [ null, %12 ], [ null, %19 ], [ null, %5 ]
%32 = phi i8* [ %27, %23 ], [ null, %12 ], [ null, %19 ], [ null, %5 ]
store i8* %31, i8** %0
br label %33
33: ; preds = %30, %2
%34 = phi i8* [ %32, %30 ], [ null, %2 ]
ret i8* %34
}