// File: jliesch[P]ofxget/pugixml/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)
					return error("Unknown variable: variable set is not provided");

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

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

				_lexer.next();

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

			case lex_open_brace:
			{
				_lexer.next();

				xpath_ast_node* n = parse_expression();
				if (!n) return 0;

				if (_lexer.current() != lex_close_brace)
					return error("Expected ')' to match an opening '('");

				_lexer.next();

				return n;
			}

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

				_lexer.next();

				return alloc_node(ast_string_constant, xpath_type_string, value);
			}

			case lex_number:
			{
				double value = 0;

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

				_lexer.next();

				return alloc_node(ast_number_constant, xpath_type_number, value);
			}

			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)
					return error("Unrecognized function call");
				_lexer.next();

				while (_lexer.current() != lex_close_brace)
				{
					if (argc > 0)
					{
						if (_lexer.current() != lex_comma)
							return error("No comma between function arguments");
						_lexer.next();
					}

					xpath_ast_node* n = parse_expression();
					if (!n) return 0;

					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:
				return error("Unrecognizable primary expression");
			}
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x88(%rbp)
addq $0x8, %rdi
callq 0x5af60
addl $-0xb, %eax
movl %eax, %ecx
movq %rcx, -0x80(%rbp)
subl $0x9, %eax
ja 0x5bf2c
movq -0x80(%rbp), %rax
leaq 0xf344(%rip), %rcx      # 0x6ae64
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x88(%rbp), %rdi
addq $0x8, %rdi
callq 0x5b700
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, -0x20(%rbp)
movq 0x8(%rcx), %rcx
movq %rcx, -0x18(%rbp)
cmpq $0x0, 0x38(%rax)
jne 0x5bb75
movq -0x88(%rbp), %rdi
leaq 0x119b6(%rip), %rsi     # 0x6d51d
callq 0x5af80
movq %rax, -0x8(%rbp)
jmp 0x5bf43
movq -0x88(%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 0x5bfc0
testb $0x1, %al
jne 0x5bbb9
movq -0x88(%rbp), %rdi
callq 0x5c090
movq %rax, -0x8(%rbp)
jmp 0x5bf43
cmpq $0x0, -0x28(%rbp)
jne 0x5bbdc
movq -0x88(%rbp), %rdi
leaq 0x1197e(%rip), %rsi     # 0x6d54c
callq 0x5af80
movq %rax, -0x8(%rbp)
jmp 0x5bf43
movq -0x88(%rbp), %rdi
addq $0x8, %rdi
callq 0x5a830
movq -0x28(%rbp), %rdi
callq 0x4a1d0
movq -0x88(%rbp), %rdi
movl %eax, %edx
movq -0x28(%rbp), %rcx
movl $0x14, %esi
callq 0x5c0f0
movq %rax, -0x8(%rbp)
jmp 0x5bf43
movq -0x88(%rbp), %rdi
addq $0x8, %rdi
callq 0x5a830
movq -0x88(%rbp), %rdi
xorl %esi, %esi
callq 0x5af10
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x5bc4b
movq $0x0, -0x8(%rbp)
jmp 0x5bf43
movq -0x88(%rbp), %rdi
addq $0x8, %rdi
callq 0x5af60
cmpl $0xd, %eax
je 0x5bc7c
movq -0x88(%rbp), %rdi
leaq 0x1191d(%rip), %rsi     # 0x6d58b
callq 0x5af80
movq %rax, -0x8(%rbp)
jmp 0x5bf43
movq -0x88(%rbp), %rdi
addq $0x8, %rdi
callq 0x5a830
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5bf43
movq -0x88(%rbp), %rdi
addq $0x8, %rdi
callq 0x5b700
movq -0x88(%rbp), %rdi
movq %rax, %rsi
callq 0x5c150
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x5bcd0
movq $0x0, -0x8(%rbp)
jmp 0x5bf43
movq -0x88(%rbp), %rdi
addq $0x8, %rdi
callq 0x5a830
movq -0x88(%rbp), %rdi
movq -0x38(%rbp), %rcx
movl $0x12, %esi
movl $0x3, %edx
callq 0x5c200
movq %rax, -0x8(%rbp)
jmp 0x5bf43
movq -0x88(%rbp), %rdi
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movq %rdi, %rax
addq $0x48, %rax
movq %rax, -0x98(%rbp)
addq $0x8, %rdi
callq 0x5b700
movq -0x88(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x90(%rbp)
addq $0x8, %rdi
callq 0x5b700
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq 0x8(%rax), %rdx
leaq -0x40(%rbp), %rcx
callq 0x5c260
testb $0x1, %al
jne 0x5bd77
movq -0x88(%rbp), %rdi
callq 0x5c090
movq %rax, -0x8(%rbp)
jmp 0x5bf43
movq -0x88(%rbp), %rdi
addq $0x8, %rdi
callq 0x5a830
movq -0x88(%rbp), %rdi
movsd -0x40(%rbp), %xmm0
movl $0x13, %esi
movl $0x2, %edx
callq 0x5c320
movq %rax, -0x8(%rbp)
jmp 0x5bf43
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x72b0
movq -0x88(%rbp), %rdi
movq $0x0, -0x58(%rbp)
addq $0x8, %rdi
callq 0x5b700
movq -0x88(%rbp), %rdi
movq (%rax), %rcx
movq %rcx, -0x68(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
addq $0x8, %rdi
callq 0x5a830
movq -0x88(%rbp), %rdi
movq $0x0, -0x70(%rbp)
addq $0x8, %rdi
callq 0x5af60
cmpl $0xc, %eax
je 0x5be2b
movq -0x88(%rbp), %rdi
leaq 0x11793(%rip), %rsi     # 0x6d5b0
callq 0x5af80
movq %rax, -0x8(%rbp)
jmp 0x5bf43
movq -0x88(%rbp), %rdi
addq $0x8, %rdi
callq 0x5a830
movq -0x88(%rbp), %rdi
addq $0x8, %rdi
callq 0x5af60
cmpl $0xd, %eax
je 0x5befe
cmpq $0x0, -0x58(%rbp)
jbe 0x5be9c
movq -0x88(%rbp), %rdi
addq $0x8, %rdi
callq 0x5af60
cmpl $0x15, %eax
je 0x5be8c
movq -0x88(%rbp), %rdi
leaq 0x1174d(%rip), %rsi     # 0x6d5cb
callq 0x5af80
movq %rax, -0x8(%rbp)
jmp 0x5bf43
movq -0x88(%rbp), %rdi
addq $0x8, %rdi
callq 0x5a830
movq -0x88(%rbp), %rdi
xorl %esi, %esi
callq 0x5af10
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0x5bec2
movq $0x0, -0x8(%rbp)
jmp 0x5bf43
cmpq $0x2, -0x58(%rbp)
jae 0x5bed8
movq -0x78(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, -0x50(%rbp,%rax,8)
jmp 0x5bee5
movq -0x70(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x5c380
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x5be3b
movq -0x88(%rbp), %rdi
addq $0x8, %rdi
callq 0x5a830
movq -0x88(%rbp), %rdi
movq -0x58(%rbp), %rdx
leaq -0x50(%rbp), %rcx
leaq -0x68(%rbp), %rsi
callq 0x5c3a0
movq %rax, -0x8(%rbp)
jmp 0x5bf43
movq -0x88(%rbp), %rdi
leaq 0x116b5(%rip), %rsi     # 0x6d5ef
callq 0x5af80
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq