// File: /workspace/github_cpp_makefile_star2_O2/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 %rsi, %rbx
movq (%rsi), %rsi
cmpq %rdx, %rsi
je 0x5c7f
movl (%rsi), %eax
cmpl $0x7d, %eax
je 0x5c00
cmpl $0x4, %eax
je 0x5bad
cmpl $0x7c, %eax
je 0x5be0
cmpl $0x3, %eax
jne 0x5c75
addq $0x48, %rsi
jmp 0x5bcf
movq 0x8(%rsi), %rax
movq (%rcx), %rsi
movq 0x8(%rcx), %rcx
subq %rsi, %rcx
sarq $0x5, %rcx
cmpq %rcx, %rax
jae 0x5cac
shlq $0x5, %rax
addq %rax, %rsi
callq 0x23e0
movq (%rbx), %rsi
addq $0x70, %rsi
jmp 0x5c6e
movq 0x8(%rcx), %rax
cmpq %rax, (%rcx)
je 0x5bd7
cmpb $0x1, 0x30(%r8)
jne 0x5bd7
cmpb $0x1, 0x31(%r8)
jne 0x5bd7
addq $-0x20, %rax
movq %rax, %rsi
jmp 0x5bcf
movq %rdx, %r14
leaq 0x70(%rsi), %rax
movq %rax, (%rbx)
cmpq %rdx, %rax
je 0x5ccb
cmpl $0x20, (%rax)
jne 0x5cea
leaq 0xe0(%rsi), %rax
movq %rax, (%rbx)
cmpq %r14, %rax
je 0x5d06
cmpl $0x3, (%rax)
jne 0x5d22
testb %r9b, %r9b
je 0x5c4c
addq $0x128, %rsi            # imm = 0x128
callq 0x23e0
movq (%rbx), %rax
leaq 0x70(%rax), %rcx
movq %rcx, (%rbx)
cmpq %r14, %rcx
je 0x5d3e
cmpl $0x21, (%rcx)
jne 0x5d5a
addq $0xe0, %rax
movq %rax, %rsi
movq %rsi, (%rbx)
movb $0x1, %al
jmp 0x5c77
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0xa9ea(%rip), %rsi      # 0x1067b
movq %rax, %rdi
callq 0x20a0
movq 0x12358(%rip), %rsi     # 0x17ff8
movq 0x12309(%rip), %rdx     # 0x17fb0
jmp 0x5d82
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0xa9ee(%rip), %rsi      # 0x106ac
movq %rax, %rdi
callq 0x23a0
jmp 0x5d74
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0xa9f2(%rip), %rsi      # 0x106cf
movq %rax, %rdi
callq 0x23a0
jmp 0x5d74
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0xa9d3(%rip), %rsi      # 0x106cf
movq %rax, %rdi
callq 0x23a0
jmp 0x5d74
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0xa9d8(%rip), %rsi      # 0x106f0
movq %rax, %rdi
callq 0x23a0
jmp 0x5d74
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0xa9bc(%rip), %rsi      # 0x106f0
movq %rax, %rdi
callq 0x23a0
jmp 0x5d74
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0xa9d6(%rip), %rsi      # 0x10726
movq %rax, %rdi
callq 0x23a0
jmp 0x5d74
pushq $0x10
popq %rdi
callq 0x20e0
movq %rax, %rbx
leaq 0xa9ba(%rip), %rsi      # 0x10726
movq %rax, %rdi
callq 0x23a0
movq 0x1225d(%rip), %rsi     # 0x17fd8
movq 0x1223e(%rip), %rdx     # 0x17fc0
movq %rbx, %rdi
callq 0x2340
jmp 0x5d98
jmp 0x5d98
jmp 0x5d98
jmp 0x5d98
jmp 0x5d98
jmp 0x5d98
jmp 0x5d98
movq %rax, %r14
movq %rbx, %rdi
callq 0x2160
movq %r14, %rdi
callq 0x2370