// File: 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 %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movb %r9b, %al
movq %rdx, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
andb $0x1, %al
movb %al, -0x31(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x16310
testb $0x1, %al
jne 0xc76a
jmp 0xc7c6
movl $0x10, %edi
callq 0x3130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x88(%rbp)
leaq 0x191c3(%rip), %rsi     # 0x2594b
callq 0x30d0
jmp 0xc78f
movq -0x88(%rbp), %rdi
movq 0x2685b(%rip), %rsi     # 0x32ff8
movq 0x2680c(%rip), %rdx     # 0x32fb0
callq 0x34b0
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x31f0
jmp 0xcc74
movq -0x20(%rbp), %rdi
callq 0x162b0
cmpl $0x3, (%rax)
jne 0xc805
movq -0x20(%rbp), %rdi
callq 0x162b0
movq %rax, %rsi
addq $0x48, %rsi
movq -0x18(%rbp), %rdi
callq 0x3390
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x162d0
movq %rax, -0x50(%rbp)
movb $0x1, -0x1(%rbp)
jmp 0xcc66
movq -0x20(%rbp), %rdi
callq 0x162b0
cmpl $0x4, (%rax)
jne 0xc8e7
movq -0x20(%rbp), %rdi
callq 0x162b0
movq 0x8(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x28(%rbp), %rdi
callq 0x161c0
movq %rax, %rcx
movq -0x90(%rbp), %rax
cmpq %rcx, %rax
jb 0xc89f
movl $0x10, %edi
callq 0x3130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x98(%rbp)
leaq 0x1911b(%rip), %rsi     # 0x2597c
callq 0x3530
jmp 0xc868
movq -0x98(%rbp), %rdi
movq 0x26762(%rip), %rsi     # 0x32fd8
movq 0x26743(%rip), %rdx     # 0x32fc0
callq 0x34b0
movq -0x98(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x31f0
jmp 0xcc74
movq -0x28(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x20(%rbp), %rdi
callq 0x162b0
movq -0xa0(%rbp), %rdi
movq 0x8(%rax), %rsi
callq 0x188c0
movq %rax, %rsi
movq -0x18(%rbp), %rdi
callq 0x3390
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x162d0
movq %rax, -0x58(%rbp)
movb $0x1, -0x1(%rbp)
jmp 0xcc66
movq -0x20(%rbp), %rdi
callq 0x162b0
cmpl $0x7c, (%rax)
jne 0xc961
movq -0x28(%rbp), %rdi
callq 0x188e0
testb $0x1, %al
jne 0xc949
movq -0x30(%rbp), %rax
testb $0x1, 0x30(%rax)
je 0xc949
movq -0x30(%rbp), %rax
testb $0x1, 0x31(%rax)
je 0xc949
movq -0x28(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x28(%rbp), %rdi
callq 0x161c0
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x188c0
movq %rax, %rsi
movq -0x18(%rbp), %rdi
callq 0x3390
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x162d0
movq %rax, -0x60(%rbp)
movb $0x1, -0x1(%rbp)
jmp 0xcc66
movq -0x20(%rbp), %rdi
callq 0x162b0
cmpl $0x7d, (%rax)
jne 0xcc5c
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x162d0
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x16310
testb $0x1, %al
jne 0xc995
jmp 0xc9f1
movl $0x10, %edi
callq 0x3130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb0(%rbp)
leaq 0x18fec(%rip), %rsi     # 0x2599f
callq 0x3530
jmp 0xc9ba
movq -0xb0(%rbp), %rdi
movq 0x26610(%rip), %rsi     # 0x32fd8
movq 0x265f1(%rip), %rdx     # 0x32fc0
callq 0x34b0
movq -0xb0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x31f0
jmp 0xcc74
movq -0x20(%rbp), %rdi
callq 0x162b0
cmpl $0x20, (%rax)
je 0xca5b
movl $0x10, %edi
callq 0x3130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
leaq 0x18f82(%rip), %rsi     # 0x2599f
callq 0x3530
jmp 0xca24
movq -0xb8(%rbp), %rdi
movq 0x265a6(%rip), %rsi     # 0x32fd8
movq 0x26587(%rip), %rdx     # 0x32fc0
callq 0x34b0
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x31f0
jmp 0xcc74
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x162d0
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x16310
testb $0x1, %al
jne 0xca7d
jmp 0xcad9
movl $0x10, %edi
callq 0x3130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc0(%rbp)
leaq 0x18f25(%rip), %rsi     # 0x259c0
callq 0x3530
jmp 0xcaa2
movq -0xc0(%rbp), %rdi
movq 0x26528(%rip), %rsi     # 0x32fd8
movq 0x26509(%rip), %rdx     # 0x32fc0
callq 0x34b0
movq -0xc0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x31f0
jmp 0xcc74
movq -0x20(%rbp), %rdi
callq 0x162b0
cmpl $0x3, (%rax)
je 0xcb43
movl $0x10, %edi
callq 0x3130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc8(%rbp)
leaq 0x18ebb(%rip), %rsi     # 0x259c0
callq 0x3530
jmp 0xcb0c
movq -0xc8(%rbp), %rdi
movq 0x264be(%rip), %rsi     # 0x32fd8
movq 0x2649f(%rip), %rdx     # 0x32fc0
callq 0x34b0
movq -0xc8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x31f0
jmp 0xcc74
testb $0x1, -0x31(%rbp)
je 0xcb62
movq -0x20(%rbp), %rdi
callq 0x162b0
movq %rax, %rsi
addq $0x48, %rsi
movq -0x18(%rbp), %rdi
callq 0x3390
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x162d0
movq %rax, -0x78(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x16310
testb $0x1, %al
jne 0xcb84
jmp 0xcbe0
movl $0x10, %edi
callq 0x3130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xd0(%rbp)
leaq 0x18e54(%rip), %rsi     # 0x259f6
callq 0x3530
jmp 0xcba9
movq -0xd0(%rbp), %rdi
movq 0x26421(%rip), %rsi     # 0x32fd8
movq 0x26402(%rip), %rdx     # 0x32fc0
callq 0x34b0
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x31f0
jmp 0xcc74
movq -0x20(%rbp), %rdi
callq 0x162b0
cmpl $0x21, (%rax)
je 0xcc47
movl $0x10, %edi
callq 0x3130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xd8(%rbp)
leaq 0x18dea(%rip), %rsi     # 0x259f6
callq 0x3530
jmp 0xcc13
movq -0xd8(%rbp), %rdi
movq 0x263b7(%rip), %rsi     # 0x32fd8
movq 0x26398(%rip), %rdx     # 0x32fc0
callq 0x34b0
movq -0xd8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x31f0
jmp 0xcc74
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x162d0
movq %rax, -0x80(%rbp)
movb $0x1, -0x1(%rbp)
jmp 0xcc66
jmp 0xcc5e
jmp 0xcc60
jmp 0xcc62
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xe0, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x34e0
nopl (%rax)