#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 */
struct cnfnode {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ append_node(struct cnfnode *, struct cnfnode *);
int /*<<< orphan*/ cnfnode_setval(struct cnfnode *, char *);
struct cnfnode *create_cnfnode(char *);
int /*<<< orphan*/ dup_next_quoted_b(char const **, char *, int, char const);
int /*<<< orphan*/ dup_next_word_b(char const **, char *, int);
int /*<<< orphan*/ skip_spaces(char const **);
struct cnfnode *parse_cmdline(const char **pp, const char *optstring) {
  struct cnfnode *cn_top, *cn_opt;
  const char *p, *po;
  char buf[256];
  p = *pp;
  dup_next_word_b(&p, buf, sizeof(buf));
  cn_top = create_cnfnode(buf);
  while (*p) {
    const char *p0;
    p0 = p;
    skip_spaces(&p);
    dup_next_word_b(&p, buf, sizeof(buf));
    if (buf[0] == '-') {
      int c = buf[1];
      po = optstring;
      while (*po && *po != c)
        po++;
      if (*po) {
        cn_opt = create_cnfnode(buf);
        skip_spaces(&p);
        po++;
        if (*po == ':') {
          if (*p != '\"' && *p != '\'')
            dup_next_word_b(&p, buf, sizeof(buf));
          else
            dup_next_quoted_b(&p, buf, sizeof(buf), *p);
          cnfnode_setval(cn_opt, buf);
        }
        append_node(cn_top, cn_opt);
      } else
        break;
    } else {
      p = p0;
      break;
    }
  }
  *pp = p;
  return cn_top;
}


x86 assembly (clang, -O0):
<parse_cmdline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
lea    -0x130(%rbp),%rsi
lea    -0x28(%rbp),%rdi
mov    $0x100,%edx
call   1050 <dup_next_word_b@plt>
lea    -0x130(%rbp),%rdi
call   1080 <create_cnfnode@plt>
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     1329 <parse_cmdline+0x1c9>
mov    -0x28(%rbp),%rax
mov    %rax,-0x138(%rbp)
lea    -0x28(%rbp),%rdi
call   1070 <skip_spaces@plt>
lea    -0x130(%rbp),%rsi
lea    -0x28(%rbp),%rdi
mov    $0x100,%edx
call   1050 <dup_next_word_b@plt>
movsbl -0x130(%rbp),%eax
cmp    $0x2d,%eax
jne    1314 <parse_cmdline+0x1b4>
movsbl -0x12f(%rbp),%eax
mov    %eax,-0x13c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x13d(%rbp)
je     122c <parse_cmdline+0xcc>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    -0x13c(%rbp),%eax
setne  %al
mov    %al,-0x13d(%rbp)
mov    -0x13d(%rbp),%al
test   $0x1,%al
jne    123f <parse_cmdline+0xdf>
jmp    1250 <parse_cmdline+0xf0>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11fe <parse_cmdline+0x9e>
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     130a <parse_cmdline+0x1aa>
lea    -0x130(%rbp),%rdi
call   1080 <create_cnfnode@plt>
mov    %rax,-0x20(%rbp)
lea    -0x28(%rbp),%rdi
call   1070 <skip_spaces@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    12f8 <parse_cmdline+0x198>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
je     12cc <parse_cmdline+0x16c>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
je     12cc <parse_cmdline+0x16c>
lea    -0x130(%rbp),%rsi
lea    -0x28(%rbp),%rdi
mov    $0x100,%edx
call   1050 <dup_next_word_b@plt>
jmp    12e8 <parse_cmdline+0x188>
lea    -0x130(%rbp),%rsi
mov    -0x28(%rbp),%rax
lea    -0x28(%rbp),%rdi
mov    $0x100,%edx
movsbl (%rax),%ecx
call   1030 <dup_next_quoted_b@plt>
mov    -0x20(%rbp),%rdi
lea    -0x130(%rbp),%rsi
call   1060 <cnfnode_setval@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <append_node@plt>
jmp    130f <parse_cmdline+0x1af>
jmp    1329 <parse_cmdline+0x1c9>
jmp    1324 <parse_cmdline+0x1c4>
mov    -0x138(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1329 <parse_cmdline+0x1c9>
jmp    11a3 <parse_cmdline+0x43>
mov    -0x28(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_cmdline>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%r14
mov    %rdi,0x8(%rsp)
mov    (%rdi),%rax
mov    %rax,(%rsp)
mov    %rsp,%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x100,%edx
call   1050 <dup_next_word_b@plt>
mov    %rbx,%rdi
call   1080 <create_cnfnode@plt>
mov    %rax,%r12
mov    (%rsp),%rbp
cmpb   $0x0,0x0(%rbp)
je     129d <parse_cmdline+0x13d>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <skip_spaces@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x100,%edx
call   1050 <dup_next_word_b@plt>
cmpb   $0x2d,0x10(%rsp)
jne    129d <parse_cmdline+0x13d>
lea    0x10(%rsp),%r13
mov    %rsp,%rbx
xchg   %ax,%ax
mov    0x11(%rsp),%al
mov    %r14,%r15
nopw   0x0(%rax,%rax,1)
movzbl (%r15),%ecx
add    $0x1,%r15
test   %cl,%cl
je     1200 <parse_cmdline+0xa0>
cmp    %al,%cl
jne    11f0 <parse_cmdline+0x90>
test   %cl,%cl
je     1299 <parse_cmdline+0x139>
mov    %r13,%rdi
call   1080 <create_cnfnode@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1070 <skip_spaces@plt>
cmpb   $0x3a,(%r15)
jne    125f <parse_cmdline+0xff>
mov    (%rsp),%rax
mov    (%rax),%al
cmp    $0x22,%al
je     122f <parse_cmdline+0xcf>
cmp    $0x27,%al
jne    1244 <parse_cmdline+0xe4>
movsbl %al,%ecx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x100,%edx
call   1030 <dup_next_quoted_b@plt>
jmp    1254 <parse_cmdline+0xf4>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x100,%edx
call   1050 <dup_next_word_b@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1060 <cnfnode_setval@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1040 <append_node@plt>
mov    (%rsp),%rbp
cmpb   $0x0,0x0(%rbp)
je     129d <parse_cmdline+0x13d>
mov    %rbx,%rdi
call   1070 <skip_spaces@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x100,%edx
call   1050 <dup_next_word_b@plt>
cmpb   $0x2d,0x10(%rsp)
je     11e0 <parse_cmdline+0x80>
jmp    129d <parse_cmdline+0x13d>
mov    (%rsp),%rbp
mov    0x8(%rsp),%rax
mov    %rbp,(%rax)
mov    %r12,%rax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.cnfnode = type { i32 }
define %struct.cnfnode* @parse_cmdline(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca %struct.cnfnode*
%6 = alloca %struct.cnfnode*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [256 x i8]
%10 = alloca i8*
%11 = alloca i32
store i8** %0, i8*** %3
store i8* %1, i8** %4
%12 = load i8**, i8*** %3
%13 = load i8*, i8** %12
store i8* %13, i8** %7
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%15 = call i32 @dup_next_word_b(i8** %7, i8* %14, i32 256)
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%17 = call %struct.cnfnode* @create_cnfnode(i8* %16)
store %struct.cnfnode* %17, %struct.cnfnode** %5
br label %18
18: ; preds = %96, %2
%19 = load i8*, i8** %7
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 0
br i1 %21, label %22, label %97
22: ; preds = %18
%23 = load i8*, i8** %7
store i8* %23, i8** %10
%24 = call i32 @skip_spaces(i8** %7)
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%26 = call i32 @dup_next_word_b(i8** %7, i8* %25, i32 256)
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 45
br i1 %30, label %31, label %94
31: ; preds = %22
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 1
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
store i32 %34, i32* %11
%35 = load i8*, i8** %4
store i8* %35, i8** %8
br label %36
36: ; preds = %49, %31
%37 = load i8*, i8** %8
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %47
41: ; preds = %36
%42 = load i8*, i8** %8
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = load i32, i32* %11
%46 = icmp ne i32 %44, %45
br label %47
47: ; preds = %41, %36
%48 = phi i1 [ false, %36 ], [ %46, %41 ]
br i1 %48, label %49, label %52
49: ; preds = %47
%50 = load i8*, i8** %8
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %8
br label %36
52: ; preds = %47
%53 = load i8*, i8** %8
%54 = load i8, i8* %53
%55 = icmp ne i8 %54, 0
br i1 %55, label %56, label %92
56: ; preds = %52
%57 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%58 = call %struct.cnfnode* @create_cnfnode(i8* %57)
store %struct.cnfnode* %58, %struct.cnfnode** %6
%59 = call i32 @skip_spaces(i8** %7)
%60 = load i8*, i8** %8
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %8
%62 = load i8*, i8** %8
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 58
br i1 %65, label %66, label %88
66: ; preds = %56
%67 = load i8*, i8** %7
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 34
br i1 %70, label %71, label %79
71: ; preds = %66
%72 = load i8*, i8** %7
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp ne i32 %74, 39
br i1 %75, label %76, label %79
76: ; preds = %71
%77 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%78 = call i32 @dup_next_word_b(i8** %7, i8* %77, i32 256)
br label %84
79: ; preds = %71, %66
%80 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%81 = load i8*, i8** %7
%82 = load i8, i8* %81
%83 = call i32 @dup_next_quoted_b(i8** %7, i8* %80, i32 256, i8 signext %82)
br label %84
84: ; preds = %79, %76
%85 = load %struct.cnfnode*, %struct.cnfnode** %6
%86 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%87 = call i32 @cnfnode_setval(%struct.cnfnode* %85, i8* %86)
br label %88
88: ; preds = %84, %56
%89 = load %struct.cnfnode*, %struct.cnfnode** %5
%90 = load %struct.cnfnode*, %struct.cnfnode** %6
%91 = call i32 @append_node(%struct.cnfnode* %89, %struct.cnfnode* %90)
br label %93
92: ; preds = %52
br label %97
93: ; preds = %88
br label %96
94: ; preds = %22
%95 = load i8*, i8** %10
store i8* %95, i8** %7
br label %97
96: ; preds = %93
br label %18
97: ; preds = %94, %92, %18
%98 = load i8*, i8** %7
%99 = load i8**, i8*** %3
store i8* %98, i8** %99
%100 = load %struct.cnfnode*, %struct.cnfnode** %5
ret %struct.cnfnode* %100
}

LLVM IR (-O2):
%struct.cnfnode = type { i32 }
define %struct.cnfnode* @parse_cmdline(i8** nocapture %0, i8* nocapture %1) {
%3 = alloca i8*
%4 = alloca [256 x i8]
%5 = bitcast i8** %3 to i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = load i8*, i8** %0
store i8* %7, i8** %3
%8 = call i32 @dup_next_word_b(i8** %3, i8* %6, i32 256)
%9 = call %struct.cnfnode* @create_cnfnode(i8* %6)
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %55, label %13
13: ; preds = %2
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 1
%15 = call i32 @skip_spaces(i8** %3)
%16 = call i32 @dup_next_word_b(i8** %3, i8* %6, i32 256)
%17 = load i8, i8* %6
%18 = icmp eq i8 %17, 45
br i1 %18, label %24, label %55
19: ; preds = %50
%20 = call i32 @skip_spaces(i8** %3)
%21 = call i32 @dup_next_word_b(i8** %3, i8* %6, i32 256)
%22 = load i8, i8* %6
%23 = icmp eq i8 %22, 45
br i1 %23, label %24, label %55
24: ; preds = %13, %19
%25 = load i8, i8* %14
br label %26
26: ; preds = %26, %24
%27 = phi i8* [ %1, %24 ], [ %32, %26 ]
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
%30 = icmp eq i8 %28, %25
%31 = select i1 %29, i1 true, i1 %30
%32 = getelementptr inbounds i8, i8* %27, i64 1
br i1 %31, label %33, label %26
33: ; preds = %26
br i1 %29, label %34, label %36
34: ; preds = %33
%35 = load i8*, i8** %3
br label %55
36: ; preds = %33
%37 = call %struct.cnfnode* @create_cnfnode(i8* %6)
%38 = call i32 @skip_spaces(i8** %3)
%39 = load i8, i8* %32
%40 = icmp eq i8 %39, 58
br i1 %40, label %41, label %50
41: ; preds = %36
%42 = load i8*, i8** %3
%43 = load i8, i8* %42
switch i8 %43, label %44 [
i8 34, label %46
i8 39, label %46
]
44: ; preds = %41
%45 = call i32 @dup_next_word_b(i8** %3, i8* %6, i32 256)
br label %48
46: ; preds = %41, %41
%47 = call i32 @dup_next_quoted_b(i8** %3, i8* %6, i32 256, i8 signext %43)
br label %48
48: ; preds = %46, %44
%49 = call i32 @cnfnode_setval(%struct.cnfnode* %37, i8* %6)
br label %50
50: ; preds = %36, %48
%51 = call i32 @append_node(%struct.cnfnode* %9, %struct.cnfnode* %37)
%52 = load i8*, i8** %3
%53 = load i8, i8* %52
%54 = icmp eq i8 %53, 0
br i1 %54, label %55, label %19
55: ; preds = %19, %50, %13, %34, %2
%56 = phi i8* [ %10, %2 ], [ %35, %34 ], [ %10, %13 ], [ %52, %50 ], [ %52, %19 ]
store i8* %56, i8** %0
ret %struct.cnfnode* %9
}