// File: dlbeer[P]summary_map/./summary_map.hpp
// Function: summary_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, summary, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, aggregator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, int>, summary>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, int>>>::swap_with_successor(summary_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, summary, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, aggregator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, int>, summary>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, int>>>::node*)
static void swap_with_successor(node *n)
    {
	node *p = n->parent;
	node *s = leftmost_child(n->right);

	if (s->parent == n) {
	    // This is a tricky case: we can't just swap pointers,
	    // because we'd end up with a cycle.
	    node *left = n->left;
	    node *right = s->right;

	    s->left = left;
	    s->right = n;
	    s->parent = p;

	    n->right = right;
	    n->parent = s;

	    left->parent = s;
	} else {
	    s->left = n->left;

	    std::swap(n->right, s->right);
	    std::swap(n->parent, s->parent);

	    s->left->parent = s;
	    s->right->parent = s;

	    n->parent->left = n;
	}

	std::swap(n->flags, s->flags);
	n->left = 0;

	fix_downptr(p, n, s);

	if (n->right)
	    n->right->parent = n;
    }

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq 0x40(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rdi
callq 0x4d30
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq 0x40(%rax), %rax
cmpq 0x20(%rsp), %rax
jne 0x491a
movq 0x20(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rax
movq 0x38(%rax), %rax
movq %rax, (%rsp)
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x30(%rax)
movq 0x20(%rsp), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x38(%rax)
movq 0x18(%rsp), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x40(%rax)
movq (%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x38(%rax)
movq 0x10(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x40(%rax)
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x40(%rax)
jmp 0x4990
movq 0x20(%rsp), %rax
movq 0x30(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x30(%rax)
movq 0x20(%rsp), %rdi
addq $0x38, %rdi
movq 0x10(%rsp), %rsi
addq $0x38, %rsi
callq 0x4d80
movq 0x20(%rsp), %rdi
addq $0x40, %rdi
movq 0x10(%rsp), %rsi
addq $0x40, %rsi
callq 0x4d80
movq 0x10(%rsp), %rcx
movq 0x10(%rsp), %rax
movq 0x30(%rax), %rax
movq %rcx, 0x40(%rax)
movq 0x10(%rsp), %rcx
movq 0x10(%rsp), %rax
movq 0x38(%rax), %rax
movq %rcx, 0x40(%rax)
movq 0x20(%rsp), %rcx
movq 0x20(%rsp), %rax
movq 0x40(%rax), %rax
movq %rcx, 0x30(%rax)
movq 0x20(%rsp), %rdi
addq $0x2c, %rdi
movq 0x10(%rsp), %rsi
addq $0x2c, %rsi
callq 0x4dc0
movq 0x20(%rsp), %rax
movq $0x0, 0x30(%rax)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x10(%rsp), %rdx
callq 0x43a0
movq 0x20(%rsp), %rax
cmpq $0x0, 0x38(%rax)
je 0x49e6
movq 0x20(%rsp), %rcx
movq 0x20(%rsp), %rax
movq 0x38(%rax), %rax
movq %rcx, 0x40(%rax)
addq $0x28, %rsp
retq
nopl (%rax,%rax)