#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*/ wordexp_t;

/* Variables and functions */
int WRDE_CMDSUB;
int WRDE_NOCMD;
int WRDE_NOSPACE;
int WRDE_SYNTAX;
int parse_backtick(char **, size_t *, size_t *, char const *, size_t *, int,
                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                   int /*<<< orphan*/ *);
int parse_dollars(char **, size_t *, size_t *, char const *, size_t *, int,
                  int /*<<< orphan*/ *, char const *, char const *, int);
int parse_qtd_backslash(char **, size_t *, size_t *, char const *, size_t *);
char *w_addchar(char *, size_t *, size_t *, char const);
int parse_dquote(char **word, size_t *word_length, size_t *max_length,
                 const char *words, size_t *offset, int flags,
                 wordexp_t *pwordexp, const char *ifs, const char *ifs_white) {
  int error;
  for (; words[*offset]; ++(*offset)) {
    switch (words[*offset]) {
    case '"':
      return 0;
    case '$':
      error = parse_dollars(word, word_length, max_length, words, offset, flags,
                            pwordexp, ifs, ifs_white, 1);
      if (error)
        return error;
      break;
    case '`':
      if (flags & WRDE_NOCMD)
        return WRDE_CMDSUB;
      ++(*offset);
      error = parse_backtick(word, word_length, max_length, words, offset,
                             flags, NULL, NULL, NULL);
      if (error)
        return error;
      break;
    case '\\':
      error = parse_qtd_backslash(word, word_length, max_length, words, offset);
      if (error)
        return error;
      break;
    default:
      *word = w_addchar(*word, word_length, max_length, words[*offset]);
      if (*word == NULL)
        return WRDE_NOSPACE;
    }
  }
  return WRDE_SYNTAX;
}


x86 assembly (clang, -O0):
<parse_dquote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1365 <parse_dquote+0x225>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x22,%eax
je     11d4 <parse_dquote+0x94>
jmp    11a1 <parse_dquote+0x61>
mov    -0x3c(%rbp),%eax
sub    $0x24,%eax
je     11e0 <parse_dquote+0xa0>
jmp    11b2 <parse_dquote+0x72>
mov    -0x3c(%rbp),%eax
sub    $0x5c,%eax
je     12c6 <parse_dquote+0x186>
jmp    11c3 <parse_dquote+0x83>
mov    -0x3c(%rbp),%eax
sub    $0x60,%eax
je     123c <parse_dquote+0xfc>
jmp    12fc <parse_dquote+0x1bc>
movl   $0x0,-0x4(%rbp)
jmp    1371 <parse_dquote+0x231>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x34(%rbp),%r9d
mov    0x10(%rbp),%r11
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
movl   $0x1,0x18(%rsp)
call   1060 <parse_dollars@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     1237 <parse_dquote+0xf7>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1371 <parse_dquote+0x231>
jmp    134d <parse_dquote+0x20d>
mov    -0x34(%rbp),%eax
mov    0x2da2(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1262 <parse_dquote+0x122>
mov    0x2d78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1371 <parse_dquote+0x231>
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x34(%rbp),%r9d
xor    %eax,%eax
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1040 <parse_backtick@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     12c1 <parse_dquote+0x181>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1371 <parse_dquote+0x231>
jmp    134d <parse_dquote+0x20d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1030 <parse_qtd_backslash@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     12f7 <parse_dquote+0x1b7>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1371 <parse_dquote+0x231>
jmp    134d <parse_dquote+0x20d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%rcx
movsbl (%rax,%rcx,1),%ecx
call   1050 <w_addchar@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1348 <parse_dquote+0x208>
mov    0x2c9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1371 <parse_dquote+0x231>
jmp    134d <parse_dquote+0x20d>
jmp    1352 <parse_dquote+0x212>
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    116c <parse_dquote+0x2c>
mov    0x2c74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_dquote>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbp
mov    (%r8),%rax
mov    (%rcx,%rax,1),%cl
test   %cl,%cl
je     126d <parse_dquote+0x12d>
mov    %r9d,%r14d
mov    %r8,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
jmp    11a3 <parse_dquote+0x63>
nopl   (%rax)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %rbx,%r8
call   1030 <parse_qtd_backslash@plt>
test   %eax,%eax
jne    1276 <parse_dquote+0x136>
mov    (%rbx),%rcx
lea    0x1(%rcx),%rax
mov    %rax,(%rbx)
movzbl 0x1(%rbp,%rcx,1),%ecx
test   %cl,%cl
je     126d <parse_dquote+0x12d>
movsbl %cl,%ecx
cmp    $0x5b,%ecx
jle    1210 <parse_dquote+0xd0>
cmp    $0x5c,%ecx
je     1170 <parse_dquote+0x30>
cmp    $0x60,%ecx
jne    1248 <parse_dquote+0x108>
mov    0x2e28(%rip),%rcx
test   %r14d,(%rcx)
jne    1285 <parse_dquote+0x145>
add    $0x1,%rax
mov    %rax,(%rbx)
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %rbx,%r8
mov    %r14d,%r9d
call   1040 <parse_backtick@plt>
add    $0x20,%rsp
jmp    1184 <parse_dquote+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x24,%ecx
jne    1243 <parse_dquote+0x103>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
mov    %rbx,%r8
mov    %r14d,%r9d
push   $0x1
push   0x58(%rsp)
push   0x58(%rsp)
push   0x58(%rsp)
call   1060 <parse_dollars@plt>
add    $0x20,%rsp
jmp    1184 <parse_dquote+0x44>
cmp    $0x22,%ecx
je     128e <parse_dquote+0x14e>
mov    0x0(%r13),%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1050 <w_addchar@plt>
mov    %rax,0x0(%r13)
test   %rax,%rax
jne    118c <parse_dquote+0x4c>
mov    0x2d6d(%rip),%rax
jmp    1274 <parse_dquote+0x134>
mov    0x2d6c(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d44(%rip),%rax
jmp    1274 <parse_dquote+0x134>
xor    %eax,%eax
jmp    1276 <parse_dquote+0x136>

LLVM IR (-O0):
@WRDE_NOCMD = global i32 0
@WRDE_CMDSUB = global i32 0
@WRDE_NOSPACE = global i32 0
@WRDE_SYNTAX = global i32 0
define i32 @parse_dquote(i8** %0, i64* %1, i64* %2, i8* %3, i64* %4, i32 %5, i32* %6, i8* %7, i8* %8) {
%10 = alloca i32
%11 = alloca i8**
%12 = alloca i64*
%13 = alloca i64*
%14 = alloca i8*
%15 = alloca i64*
%16 = alloca i32
%17 = alloca i32*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i32
store i8** %0, i8*** %11
store i64* %1, i64** %12
store i64* %2, i64** %13
store i8* %3, i8** %14
store i64* %4, i64** %15
store i32 %5, i32* %16
store i32* %6, i32** %17
store i8* %7, i8** %18
store i8* %8, i8** %19
br label %21
21: ; preds = %106, %9
%22 = load i8*, i8** %14
%23 = load i64*, i64** %15
%24 = load i64, i64* %23
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = icmp ne i8 %26, 0
br i1 %27, label %28, label %110
28: ; preds = %21
%29 = load i8*, i8** %14
%30 = load i64*, i64** %15
%31 = load i64, i64* %30
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
switch i32 %34, label %87 [
i32 34, label %35
i32 36, label %36
i32 96, label %52
i32 92, label %75
]
35: ; preds = %28
store i32 0, i32* %10
br label %112
36: ; preds = %28
%37 = load i8**, i8*** %11
%38 = load i64*, i64** %12
%39 = load i64*, i64** %13
%40 = load i8*, i8** %14
%41 = load i64*, i64** %15
%42 = load i32, i32* %16
%43 = load i32*, i32** %17
%44 = load i8*, i8** %18
%45 = load i8*, i8** %19
%46 = call i32 @parse_dollars(i8** %37, i64* %38, i64* %39, i8* %40, i64* %41, i32 %42, i32* %43, i8* %44, i8* %45, i32 1)
store i32 %46, i32* %20
%47 = load i32, i32* %20
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %36
%50 = load i32, i32* %20
store i32 %50, i32* %10
br label %112
51: ; preds = %36
br label %105
52: ; preds = %28
%53 = load i32, i32* %16
%54 = load i32, i32* @WRDE_NOCMD
%55 = and i32 %53, %54
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %52
%58 = load i32, i32* @WRDE_CMDSUB
store i32 %58, i32* %10
br label %112
59: ; preds = %52
%60 = load i64*, i64** %15
%61 = load i64, i64* %60
%62 = add i64 %61, 1
store i64 %62, i64* %60
%63 = load i8**, i8*** %11
%64 = load i64*, i64** %12
%65 = load i64*, i64** %13
%66 = load i8*, i8** %14
%67 = load i64*, i64** %15
%68 = load i32, i32* %16
%69 = call i32 @parse_backtick(i8** %63, i64* %64, i64* %65, i8* %66, i64* %67, i32 %68, i32* null, i32* null, i32* null)
store i32 %69, i32* %20
%70 = load i32, i32* %20
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %59
%73 = load i32, i32* %20
store i32 %73, i32* %10
br label %112
74: ; preds = %59
br label %105
75: ; preds = %28
%76 = load i8**, i8*** %11
%77 = load i64*, i64** %12
%78 = load i64*, i64** %13
%79 = load i8*, i8** %14
%80 = load i64*, i64** %15
%81 = call i32 @parse_qtd_backslash(i8** %76, i64* %77, i64* %78, i8* %79, i64* %80)
store i32 %81, i32* %20
%82 = load i32, i32* %20
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %75
%85 = load i32, i32* %20
store i32 %85, i32* %10
br label %112
86: ; preds = %75
br label %105
87: ; preds = %28
%88 = load i8**, i8*** %11
%89 = load i8*, i8** %88
%90 = load i64*, i64** %12
%91 = load i64*, i64** %13
%92 = load i8*, i8** %14
%93 = load i64*, i64** %15
%94 = load i64, i64* %93
%95 = getelementptr inbounds i8, i8* %92, i64 %94
%96 = load i8, i8* %95
%97 = call i8* @w_addchar(i8* %89, i64* %90, i64* %91, i8 signext %96)
%98 = load i8**, i8*** %11
store i8* %97, i8** %98
%99 = load i8**, i8*** %11
%100 = load i8*, i8** %99
%101 = icmp eq i8* %100, null
br i1 %101, label %102, label %104
102: ; preds = %87
%103 = load i32, i32* @WRDE_NOSPACE
store i32 %103, i32* %10
br label %112
104: ; preds = %87
br label %105
105: ; preds = %104, %86, %74, %51
br label %106
106: ; preds = %105
%107 = load i64*, i64** %15
%108 = load i64, i64* %107
%109 = add i64 %108, 1
store i64 %109, i64* %107
br label %21
110: ; preds = %21
%111 = load i32, i32* @WRDE_SYNTAX
store i32 %111, i32* %10
br label %112
112: ; preds = %110, %102, %84, %72, %57, %49, %35
%113 = load i32, i32* %10
ret i32 %113
}

LLVM IR (-O2):
@WRDE_NOCMD = global i32 0
@WRDE_CMDSUB = global i32 0
@WRDE_NOSPACE = global i32 0
@WRDE_SYNTAX = global i32 0
define i32 @parse_dquote(i8** %0, i64* %1, i64* %2, i8* %3, i64* %4, i32 %5, i32* %6, i8* %7, i8* %8) {
%10 = load i64, i64* %4
%11 = getelementptr inbounds i8, i8* %3, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %46, label %14
14: ; preds = %9, %40
%15 = phi i8 [ %44, %40 ], [ %12, %9 ]
%16 = phi i64 [ %42, %40 ], [ %10, %9 ]
%17 = sext i8 %15 to i32
switch i32 %17, label %34 [
i32 34, label %48
i32 36, label %18
i32 96, label %21
i32 92, label %31
]
18: ; preds = %14
%19 = tail call i32 @parse_dollars(i8** %0, i64* %1, i64* %2, i8* %3, i64* %4, i32 %5, i32* %6, i8* %7, i8* %8, i32 1)
%20 = icmp eq i32 %19, 0
br i1 %20, label %40, label %48
21: ; preds = %14
%22 = load i32, i32* @WRDE_NOCMD
%23 = and i32 %22, %5
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = load i32, i32* @WRDE_CMDSUB
br label %48
27: ; preds = %21
%28 = add i64 %16, 1
store i64 %28, i64* %4
%29 = tail call i32 @parse_backtick(i8** %0, i64* %1, i64* %2, i8* %3, i64* %4, i32 %5, i32* null, i32* null, i32* null)
%30 = icmp eq i32 %29, 0
br i1 %30, label %40, label %48
31: ; preds = %14
%32 = tail call i32 @parse_qtd_backslash(i8** %0, i64* %1, i64* %2, i8* %3, i64* %4)
%33 = icmp eq i32 %32, 0
br i1 %33, label %40, label %48
34: ; preds = %14
%35 = load i8*, i8** %0
%36 = tail call i8* @w_addchar(i8* %35, i64* %1, i64* %2, i8 signext %15)
store i8* %36, i8** %0
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = load i32, i32* @WRDE_NOSPACE
br label %48
40: ; preds = %18, %27, %31, %34
%41 = load i64, i64* %4
%42 = add i64 %41, 1
store i64 %42, i64* %4
%43 = getelementptr inbounds i8, i8* %3, i64 %42
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 0
br i1 %45, label %46, label %14
46: ; preds = %40, %9
%47 = load i32, i32* @WRDE_SYNTAX
br label %48
48: ; preds = %31, %27, %18, %14, %46, %38, %25
%49 = phi i32 [ %39, %38 ], [ %26, %25 ], [ %47, %46 ], [ %32, %31 ], [ %29, %27 ], [ %19, %18 ], [ 0, %14 ]
ret i32 %49
}