// File: adamiaonr[P]rid-analytics/src/pugixml.cpp
// Function: pugi::impl::(anonymous namespace)::xpath_parser::parse_primary_expression()
xpath_ast_node* parse_primary_expression()
		{
			switch (_lexer.current())
			{
			case lex_var_ref:
			{
				xpath_lexer_string name = _lexer.contents();

				if (!_variables)
					throw_error("Unknown variable: variable set is not provided");

				xpath_variable* var = 0;
				if (!get_variable_scratch(_scratch, _variables, name.begin, name.end, &var))
					throw_error_oom();

				if (!var)
					throw_error("Unknown variable: variable set does not contain the given name");

				_lexer.next();

				return new (alloc_node()) xpath_ast_node(ast_variable, var->type(), var);
			}

			case lex_open_brace:
			{
				_lexer.next();

				xpath_ast_node* n = parse_expression();

				if (_lexer.current() != lex_close_brace)
					throw_error("Unmatched braces");

				_lexer.next();

				return n;
			}

			case lex_quoted_string:
			{
				const char_t* value = alloc_string(_lexer.contents());

				xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_string_constant, xpath_type_string, value);
				_lexer.next();

				return n;
			}

			case lex_number:
			{
				double value = 0;

				if (!convert_string_to_number_scratch(_scratch, _lexer.contents().begin, _lexer.contents().end, &value))
					throw_error_oom();

				xpath_ast_node* n = new (alloc_node()) xpath_ast_node(ast_number_constant, xpath_type_number, value);
				_lexer.next();

				return n;
			}

			case lex_string:
			{
				xpath_ast_node* args[2] = {0};
				size_t argc = 0;

				xpath_lexer_string function = _lexer.contents();
				_lexer.next();

				xpath_ast_node* last_arg = 0;

				if (_lexer.current() != lex_open_brace)
					throw_error("Unrecognized function call");
				_lexer.next();

				if (_lexer.current() != lex_close_brace)
					args[argc++] = parse_expression();

				while (_lexer.current() != lex_close_brace)
				{
					if (_lexer.current() != lex_comma)
						throw_error("No comma between function arguments");
					_lexer.next();

					xpath_ast_node* n = parse_expression();

					if (argc < 2) args[argc] = n;
					else last_arg->set_next(n);

					argc++;
					last_arg = n;
				}

				_lexer.next();

				return parse_function(function, argc, args);
			}

			default:
				throw_error("Unrecognizable primary expression");

				return 0;
			}
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x98(%rbp)
addq $0x8, %rdi
callq 0x1eed0
addl $-0xb, %eax
movl %eax, %ecx
movq %rcx, -0x90(%rbp)
subl $0x9, %eax
ja 0x20298
movq -0x90(%rbp), %rax
leaq 0x3e7ba(%rip), %rcx     # 0x5e630
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x1f6e0
movq %rax, %rcx
movq -0x98(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, -0x20(%rbp)
movq 0x8(%rcx), %rcx
movq %rcx, -0x18(%rbp)
cmpq $0x0, 0x38(%rax)
jne 0x1fec2
movq -0x98(%rbp), %rdi
leaq 0x40e72(%rip), %rsi     # 0x60d2f
callq 0x1eef0
movq -0x98(%rbp), %rax
movq $0x0, -0x28(%rbp)
movq %rax, %rdi
addq $0x48, %rdi
movq 0x38(%rax), %rsi
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rcx
leaq -0x28(%rbp), %r8
callq 0x20350
testb $0x1, %al
jne 0x1fefd
movq -0x98(%rbp), %rdi
callq 0x1f930
cmpq $0x0, -0x28(%rbp)
jne 0x1ff17
movq -0x98(%rbp), %rdi
leaq 0x40e4c(%rip), %rsi     # 0x60d5e
callq 0x1eef0
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x1e7c0
movq -0x98(%rbp), %rdi
callq 0x1f650
movq %rax, -0xa0(%rbp)
movq -0x28(%rbp), %rdi
callq 0xf580
movq -0xa0(%rbp), %rdi
movl %eax, %edx
movq -0x28(%rbp), %rcx
movl $0x14, %esi
callq 0x20420
movq -0xa0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x202b3
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x1e7c0
movq -0x98(%rbp), %rdi
callq 0x1eea0
movq -0x98(%rbp), %rdi
movq %rax, -0x30(%rbp)
addq $0x8, %rdi
callq 0x1eed0
cmpl $0xd, %eax
je 0x1ffb2
movq -0x98(%rbp), %rdi
leaq 0x40df0(%rip), %rsi     # 0x60d9d
callq 0x1eef0
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x1e7c0
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x202b3
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x1f6e0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x204b0
movq -0x98(%rbp), %rdi
movq %rax, -0x38(%rbp)
callq 0x1f650
movq %rax, %rdi
movq %rdi, -0xa8(%rbp)
movq -0x38(%rbp), %rcx
movl $0x12, %esi
movl $0x3, %edx
callq 0x20580
movq -0xa8(%rbp), %rax
movq -0x98(%rbp), %rdi
movq %rax, -0x40(%rbp)
addq $0x8, %rdi
callq 0x1e7c0
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x202b3
movq -0x98(%rbp), %rdi
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movq %rdi, %rax
addq $0x48, %rax
movq %rax, -0xb8(%rbp)
addq $0x8, %rdi
callq 0x1f6e0
movq -0x98(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
addq $0x8, %rdi
callq 0x1f6e0
movq -0xb8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
movq 0x8(%rax), %rdx
leaq -0x48(%rbp), %rcx
callq 0x20610
testb $0x1, %al
jne 0x200ae
movq -0x98(%rbp), %rdi
callq 0x1f930
movq -0x98(%rbp), %rdi
callq 0x1f650
movq %rax, %rdi
movq %rdi, -0xc0(%rbp)
movsd -0x48(%rbp), %xmm0
movl $0x13, %esi
movl $0x2, %edx
callq 0x206d0
movq -0xc0(%rbp), %rax
movq -0x98(%rbp), %rdi
movq %rax, -0x50(%rbp)
addq $0x8, %rdi
callq 0x1e7c0
movq -0x50(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x202b3
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x5290
movq -0x98(%rbp), %rdi
movq $0x0, -0x68(%rbp)
addq $0x8, %rdi
callq 0x1f6e0
movq -0x98(%rbp), %rdi
movq (%rax), %rcx
movq %rcx, -0x78(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
addq $0x8, %rdi
callq 0x1e7c0
movq -0x98(%rbp), %rdi
movq $0x0, -0x80(%rbp)
addq $0x8, %rdi
callq 0x1eed0
cmpl $0xc, %eax
je 0x20177
movq -0x98(%rbp), %rdi
leaq 0x40c3c(%rip), %rsi     # 0x60dae
callq 0x1eef0
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x1e7c0
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x1eed0
cmpl $0xd, %eax
je 0x201bf
movq -0x98(%rbp), %rdi
callq 0x1eea0
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x68(%rbp)
movq %rcx, -0x60(%rbp,%rax,8)
jmp 0x201c1
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x1eed0
cmpl $0xd, %eax
je 0x2026a
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x1eed0
cmpl $0x15, %eax
je 0x20202
movq -0x98(%rbp), %rdi
leaq 0x40bcc(%rip), %rsi     # 0x60dc9
callq 0x1eef0
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x1e7c0
movq -0x98(%rbp), %rdi
callq 0x1eea0
movq %rax, -0x88(%rbp)
cmpq $0x2, -0x68(%rbp)
jae 0x2023e
movq -0x88(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, -0x60(%rbp,%rax,8)
jmp 0x2024e
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x20760
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x201c1
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x1e7c0
movq -0x98(%rbp), %rdi
movq -0x68(%rbp), %rdx
leaq -0x60(%rbp), %rcx
leaq -0x78(%rbp), %rsi
callq 0x20780
movq %rax, -0x8(%rbp)
jmp 0x202b3
movq -0x98(%rbp), %rdi
leaq 0x40b47(%rip), %rsi     # 0x60ded
callq 0x1eef0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq