// File: /workspace/github_cpp_makefile_star2_O3/joncampbell123[P]haxcc/haxpp.cpp
// Function: do_macro_expand_val(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, __gnu_cxx::__normal_iterator<token const*, std::vector<token, std::allocator<token>>>&, __gnu_cxx::__normal_iterator<token const*, std::vector<token, std::allocator<token>>>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, macro_t const&, bool)
static inline bool do_macro_expand_val(string &fstr,vector<token>::const_iterator &si,const vector<token>::const_iterator sie,const vector<string> &param,const macro_t &macro,const bool variadic_given) {
    if (si == sie)
        throw runtime_error("do_macro_expand_val started with iterator == end");

    if ((*si).tval == token::MACROSUBST) {
        fstr += (*si).sval;
        si++;
        return true;
    }
    else if ((*si).tval == token::MACROPARAM) {
        if ((*si).i.u >= (unsigned long long)param.size())
            throw invalid_argument("macro parameter index out of range");

        fstr += param[size_t((*si).i.u)];
        si++;
        return true;
    }
    else if ((*si).tval == token::VA_ARGS) {
        if (!param.empty() && macro.last_param_variadic && macro.last_param_optional)
            fstr += param[param.size() - size_t(1)];

        si++;
        return true;
    }
    else if ((*si).tval == token::VA_OPT) {
        si++;

        if (si == sie)
            throw invalid_argument("__VA_OPT__ must be followed by (");
        if ((*si).tval != token::OPEN_PARENS)
            throw invalid_argument("__VA_OPT__ must be followed by (");
        si++;

        if (si == sie)
            throw invalid_argument("__VA_OPT__ must be followed by something to expand to");
        if ((*si).tval != token::MACROSUBST)
            throw invalid_argument("__VA_OPT__ must be followed by something to expand to");
        if (variadic_given)
            fstr += (*si).sval;
        si++;

        if (si == sie)
            throw invalid_argument("__VA_OPT__ must be followed by )");
        if ((*si).tval != token::CLOSE_PARENS)
            throw invalid_argument("__VA_OPT__ must be followed by )");
        si++;
        return true;
    }

    return false;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movq (%rsi), %rdx
cmpq %r14, %rdx
je 0x7432
movq %rsi, %rbx
movl (%rdx), %esi
xorl %eax, %eax
cmpl $0x7b, %esi
jg 0x736d
cmpl $0x3, %esi
je 0x73f5
cmpl $0x4, %esi
jne 0x740e
movq 0x8(%rdx), %rax
subq %rcx, %r8
sarq $0x5, %r8
cmpq %r8, %rax
jae 0x7461
shlq $0x5, %rax
movq (%rcx,%rax), %rsi
movq 0x8(%rcx,%rax), %rdx
jmp 0x73fd
cmpl $0x7c, %esi
je 0x7416
cmpl $0x7d, %esi
jne 0x740e
leaq 0x70(%rdx), %rax
movq %rax, (%rbx)
cmpq %r14, %rax
je 0x7482
cmpl $0x20, (%rax)
jne 0x74a3
leaq 0xe0(%rdx), %rax
movq %rax, (%rbx)
cmpq %r14, %rax
je 0x74c1
cmpl $0x3, (%rax)
jne 0x74df
cmpb $0x0, 0x28(%rsp)
je 0x73d1
movq 0x128(%rdx), %rsi
movq 0x130(%rdx), %rdx
callq 0x2090
movq (%rbx), %rax
leaq 0x70(%rax), %rcx
movq %rcx, (%rbx)
cmpq %r14, %rcx
je 0x74fd
cmpl $0x21, (%rcx)
jne 0x751b
addq $0xe0, %rax
movq %rax, %rdx
jmp 0x7409
movq 0x48(%rdx), %rsi
movq 0x50(%rdx), %rdx
callq 0x2090
movq (%rbx), %rdx
addq $0x70, %rdx
movq %rdx, (%rbx)
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r14
retq
cmpq %r8, %rcx
je 0x7405
testb $0x1, %r9b
je 0x7405
testb $0x1, 0x20(%rsp)
je 0x7405
movq -0x20(%r8), %rsi
movq -0x18(%r8), %rdx
jmp 0x73fd
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0xd235(%rip), %rsi      # 0x1467b
movq %rax, %rdi
callq 0x20b0
movq 0x12ba3(%rip), %rsi     # 0x19ff8
movq 0x12b54(%rip), %rdx     # 0x19fb0
jmp 0x7545
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0xd237(%rip), %rsi      # 0x146ac
movq %rax, %rdi
callq 0x23a0
jmp 0x7537
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0xd239(%rip), %rsi      # 0x146cf
movq %rax, %rdi
callq 0x23a0
jmp 0x7537
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0xd218(%rip), %rsi      # 0x146cf
movq %rax, %rdi
callq 0x23a0
jmp 0x7537
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0xd21b(%rip), %rsi      # 0x146f0
movq %rax, %rdi
callq 0x23a0
jmp 0x7537
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0xd1fd(%rip), %rsi      # 0x146f0
movq %rax, %rdi
callq 0x23a0
jmp 0x7537
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0xd215(%rip), %rsi      # 0x14726
movq %rax, %rdi
callq 0x23a0
jmp 0x7537
movl $0x10, %edi
callq 0x20e0
movq %rax, %rbx
leaq 0xd1f7(%rip), %rsi      # 0x14726
movq %rax, %rdi
callq 0x23a0
movq 0x12a9a(%rip), %rsi     # 0x19fd8
movq 0x12a7b(%rip), %rdx     # 0x19fc0
movq %rbx, %rdi
callq 0x2330
jmp 0x755b
jmp 0x755b
jmp 0x755b
jmp 0x755b
jmp 0x755b
jmp 0x755b
jmp 0x755b
movq %rax, %r14
movq %rbx, %rdi
callq 0x2160
movq %r14, %rdi
callq 0x2360