#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_NOSPACE;
int WRDE_SYNTAX;
int exec_comm(char *, char **, size_t *, size_t *, int, int /*<<< orphan*/ *,
              char const *, char const *);
int /*<<< orphan*/ free(char *);
int parse_backslash(char **, size_t *, size_t *, char const *, size_t *);
int parse_qtd_backslash(char **, size_t *, size_t *, char const *, size_t *);
char *w_addchar(char *, size_t *, size_t *, char const);
char *w_newword(size_t *, size_t *);
int parse_backtick(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;
  int squoting = 0;
  size_t comm_length;
  size_t comm_maxlen;
  char *comm = w_newword(&comm_length, &comm_maxlen);
  for (; words[*offset]; ++(*offset)) {
    switch (words[*offset]) {
    case '`':
      error = exec_comm(comm, word, word_length, max_length, flags, pwordexp,
                        ifs, ifs_white);
      free(comm);
      return error;
    case '\\':
      if (squoting) {
        error = parse_qtd_backslash(&comm, &comm_length, &comm_maxlen, words,
                                    offset);
        if (error) {
          free(comm);
          return error;
        }
        break;
      }
      ++(*offset);
      error = parse_backslash(&comm, &comm_length, &comm_maxlen, words, offset);
      if (error) {
        free(comm);
        return error;
      }
      break;
    case '\'':
      squoting = 1 - squoting;
    default:
      comm = w_addchar(comm, &comm_length, &comm_maxlen, words[*offset]);
      if (comm == NULL)
        return WRDE_NOSPACE;
    }
  }
  free(comm);
  return WRDE_SYNTAX;
}


x86 assembly (clang, -O0):
<parse_backtick>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%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)
movl   $0x0,-0x3c(%rbp)
lea    -0x48(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1080 <w_newword@plt>
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     133e <parse_backtick+0x1de>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x5c(%rbp)
sub    $0x27,%eax
je     12d6 <parse_backtick+0x176>
jmp    11d9 <parse_backtick+0x79>
mov    -0x5c(%rbp),%eax
sub    $0x5c,%eax
je     1240 <parse_backtick+0xe0>
jmp    11ea <parse_backtick+0x8a>
mov    -0x5c(%rbp),%eax
sub    $0x60,%eax
jne    12e1 <parse_backtick+0x181>
jmp    11fb <parse_backtick+0x9b>
mov    -0x58(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x34(%rbp),%r8d
mov    0x10(%rbp),%r9
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <exec_comm@plt>
mov    %eax,-0x38(%rbp)
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1353 <parse_backtick+0x1f3>
cmpl   $0x0,-0x3c(%rbp)
je     1289 <parse_backtick+0x129>
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    -0x58(%rbp),%rdi
lea    -0x48(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1030 <parse_qtd_backslash@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     1284 <parse_backtick+0x124>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1353 <parse_backtick+0x1f3>
jmp    1326 <parse_backtick+0x1c6>
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    -0x58(%rbp),%rdi
lea    -0x48(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1070 <parse_backslash@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     12d1 <parse_backtick+0x171>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1353 <parse_backtick+0x1f3>
jmp    1326 <parse_backtick+0x1c6>
mov    $0x1,%eax
sub    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%rcx
lea    -0x48(%rbp),%rsi
lea    -0x50(%rbp),%rdx
movsbl (%rax,%rcx,1),%ecx
call   1060 <w_addchar@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1321 <parse_backtick+0x1c1>
mov    0x2cc9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1353 <parse_backtick+0x1f3>
jmp    1326 <parse_backtick+0x1c6>
jmp    132b <parse_backtick+0x1cb>
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    11a4 <parse_backtick+0x44>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    0x2c9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_backtick>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,%r14d
mov    %r8,%rbp
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,0x20(%rsp)
lea    0x30(%rsp),%rdi
lea    0x28(%rsp),%rsi
call   1080 <w_newword@plt>
mov    %rax,(%rsp)
mov    0x0(%rbp),%rdx
mov    (%rbx,%rdx,1),%cl
test   %cl,%cl
je     1271 <parse_backtick+0x111>
mov    %r12,0x10(%rsp)
mov    %r15,0x18(%rsp)
mov    %r14d,0xc(%rsp)
xor    %r12d,%r12d
lea    0x30(%rsp),%r14
lea    0x28(%rsp),%r15
jmp    120c <parse_backtick+0xac>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x1,%eax
sub    %r12d,%eax
mov    %eax,%r12d
mov    (%rsp),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <w_addchar@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     1282 <parse_backtick+0x122>
mov    0x0(%rbp),%rax
lea    0x1(%rax),%rdx
mov    %rdx,0x0(%rbp)
movzbl 0x1(%rbx,%rax,1),%ecx
test   %cl,%cl
je     126d <parse_backtick+0x10d>
movsbl %cl,%ecx
cmp    $0x27,%ecx
je     11d0 <parse_backtick+0x70>
cmp    $0x5c,%ecx
je     1220 <parse_backtick+0xc0>
cmp    $0x60,%ecx
jne    11db <parse_backtick+0x7b>
jmp    129e <parse_backtick+0x13e>
test   %r12d,%r12d
je     1248 <parse_backtick+0xe8>
mov    %rsp,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
call   1030 <parse_qtd_backslash@plt>
mov    $0x1,%r12d
test   %eax,%eax
je     11f7 <parse_backtick+0x97>
jmp    12d2 <parse_backtick+0x172>
add    $0x1,%rdx
mov    %rdx,0x0(%rbp)
mov    %rsp,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
call   1070 <parse_backslash@plt>
xor    %r12d,%r12d
test   %eax,%eax
je     11f7 <parse_backtick+0x97>
jmp    12d2 <parse_backtick+0x172>
mov    (%rsp),%rax
mov    %rax,%rdi
call   1040 <free@plt>
mov    0x2d68(%rip),%rax
jmp    1289 <parse_backtick+0x129>
mov    0x2d57(%rip),%rax
mov    (%rax),%r13d
mov    %r13d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rsp),%rdi
mov    0x20(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    0x18(%rsp),%rcx
mov    0xc(%rsp),%r8d
mov    0x70(%rsp),%r9
push   0x80(%rsp)
push   0x80(%rsp)
call   1050 <exec_comm@plt>
add    $0x10,%rsp
mov    %eax,%r13d
mov    (%rsp),%rdi
call   1040 <free@plt>
jmp    128c <parse_backtick+0x12c>

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

LLVM IR (-O2):
@WRDE_NOSPACE = global i32 0
@WRDE_SYNTAX = global i32 0
define i32 @parse_backtick(i8** %0, i64* %1, i64* %2, i8* %3, i64* %4, i32 %5, i32* %6, i8* %7, i8* %8) {
%10 = alloca i64
%11 = alloca i64
%12 = alloca i8*
%13 = bitcast i64* %10 to i8*
%14 = bitcast i64* %11 to i8*
%15 = bitcast i8** %12 to i8*
%16 = call i8* @w_newword(i64* %10, i64* %11)
store i8* %16, i8** %12
%17 = load i64, i64* %4
%18 = getelementptr inbounds i8, i8* %3, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %64, label %21
21: ; preds = %9, %55
%22 = phi i8 [ %60, %55 ], [ %19, %9 ]
%23 = phi i64 [ %58, %55 ], [ %17, %9 ]
%24 = phi i32 [ %56, %55 ], [ 0, %9 ]
%25 = sext i8 %22 to i32
switch i32 %25, label %48 [
i32 96, label %26
i32 92, label %31
i32 39, label %46
]
26: ; preds = %21
%27 = load i8*, i8** %12
%28 = call i32 @exec_comm(i8* %27, i8** %0, i64* %1, i64* %2, i32 %5, i32* %6, i8* %7, i8* %8)
%29 = load i8*, i8** %12
%30 = call i32 @free(i8* %29)
br label %68
31: ; preds = %21
%32 = icmp eq i32 %24, 0
br i1 %32, label %39, label %33
33: ; preds = %31
%34 = call i32 @parse_qtd_backslash(i8** %12, i64* %10, i64* %11, i8* %3, i64* %4)
%35 = icmp eq i32 %34, 0
br i1 %35, label %55, label %36
36: ; preds = %33
%37 = load i8*, i8** %12
%38 = call i32 @free(i8* %37)
br label %68
39: ; preds = %31
%40 = add i64 %23, 1
store i64 %40, i64* %4
%41 = call i32 @parse_backslash(i8** %12, i64* %10, i64* %11, i8* %3, i64* %4)
%42 = icmp eq i32 %41, 0
br i1 %42, label %55, label %43
43: ; preds = %39
%44 = load i8*, i8** %12
%45 = call i32 @free(i8* %44)
br label %68
46: ; preds = %21
%47 = sub nsw i32 1, %24
br label %48
48: ; preds = %21, %46
%49 = phi i32 [ %24, %21 ], [ %47, %46 ]
%50 = load i8*, i8** %12
%51 = call i8* @w_addchar(i8* %50, i64* %10, i64* %11, i8 signext %22)
store i8* %51, i8** %12
%52 = icmp eq i8* %51, null
br i1 %52, label %53, label %55
53: ; preds = %48
%54 = load i32, i32* @WRDE_NOSPACE
br label %68
55: ; preds = %33, %39, %48
%56 = phi i32 [ %49, %48 ], [ 1, %33 ], [ 0, %39 ]
%57 = load i64, i64* %4
%58 = add i64 %57, 1
store i64 %58, i64* %4
%59 = getelementptr inbounds i8, i8* %3, i64 %58
%60 = load i8, i8* %59
%61 = icmp eq i8 %60, 0
br i1 %61, label %62, label %21
62: ; preds = %55
%63 = load i8*, i8** %12
br label %64
64: ; preds = %62, %9
%65 = phi i8* [ %63, %62 ], [ %16, %9 ]
%66 = call i32 @free(i8* %65)
%67 = load i32, i32* @WRDE_SYNTAX
br label %68
68: ; preds = %64, %53, %43, %36, %26
%69 = phi i32 [ %54, %53 ], [ %34, %36 ], [ %41, %43 ], [ %28, %26 ], [ %67, %64 ]
ret i32 %69
}