// File: jaxonwang[P]suffixtree/main.cc
// Function: SuffixTreeBase::break_edge(InternalNode*&, char, unsigned long)
internal_node_ptr break_edge(internal_node_ptr &edge_owner, const CharT c,
                               const size_type pos) {
    // break edge[start, end] into [start, pos] [post+1, end]
    auto real_node = edge_owner;
    auto &e = real_node->adj_edges[c];
    auto edge_pair = e->break_edge(pos);
    auto first_edge = move(edge_pair.first);
    auto second_edge = move(edge_pair.second);
    std::unique_ptr<InternalNode> new_internal_ptr{new InternalNode()};
    internal_node_ptr new_internal = new_internal_ptr.get();
    node_holder.push_back(move(new_internal_ptr));

    const CharT breakpoint_c = text[pos + 1];
    new_internal->children[breakpoint_c] = real_node->children[c];
    new_internal->adj_edges[breakpoint_c] = move(second_edge);

    real_node->children[c] = new_internal;
    real_node->adj_edges[c] = move(first_edge);
    return new_internal;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
addq $0x40, %rdi
leaq -0x11(%rbp), %rsi
callq 0x5de0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x5a50
movq %rax, %rsi
movq -0x20(%rbp), %rdx
movq (%rsi), %rax
movq 0x28(%rax), %rax
leaq -0x40(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq *%rax
movq -0x90(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x7990
leaq -0x38(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x7990
movl $0x80, %edi
callq 0x2190
movq %rax, -0x88(%rbp)
jmp 0x5b0b
movq -0x88(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, -0xc0(%rbp)
movaps %xmm0, 0x70(%rdi)
movaps %xmm0, 0x60(%rdi)
movaps %xmm0, 0x50(%rdi)
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x3130
movq -0x88(%rbp), %rsi
leaq -0x58(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x3170
movq -0xb0(%rbp), %rdi
callq 0x31a0
movq -0xb0(%rbp), %rsi
movq %rax, %rcx
movq -0x98(%rbp), %rax
movq %rcx, -0x70(%rbp)
addq $0x30, %rax
movq %rax, -0xa8(%rbp)
leaq -0x78(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x3200
movq -0xa8(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x31d0
jmp 0x5ba8
leaq -0x78(%rbp), %rdi
callq 0x3250
movq -0x98(%rbp), %rdi
movq -0x20(%rbp), %rsi
incq %rsi
callq 0x21c0
movb (%rax), %al
movb %al, -0x79(%rbp)
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
leaq -0x11(%rbp), %rsi
callq 0x7300
movq %rax, -0xc8(%rbp)
jmp 0x5be3
movq -0xc8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xd8(%rbp)
movq -0x70(%rbp), %rdi
addq $0x8, %rdi
leaq -0x79(%rbp), %rsi
callq 0x7300
movq %rax, -0xd0(%rbp)
jmp 0x5c0e
movq -0xd0(%rbp), %rax
movq -0xd8(%rbp), %rcx
movq %rcx, (%rax)
movq -0x70(%rbp), %rdi
addq $0x40, %rdi
leaq -0x79(%rbp), %rsi
callq 0x5de0
movq %rax, -0xe0(%rbp)
jmp 0x5c39
movq -0xe0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x7230
movq -0x70(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
leaq -0x11(%rbp), %rsi
callq 0x7300
movq %rax, -0xe8(%rbp)
jmp 0x5c6e
movq -0xe8(%rbp), %rax
movq -0xf0(%rbp), %rcx
movq %rcx, (%rax)
movq -0x28(%rbp), %rdi
addq $0x40, %rdi
leaq -0x11(%rbp), %rsi
callq 0x5de0
movq %rax, -0xf8(%rbp)
jmp 0x5c99
movq -0xf8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x7230
movq -0x70(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x32d0
leaq -0x50(%rbp), %rdi
callq 0x3c00
leaq -0x48(%rbp), %rdi
callq 0x3c00
leaq -0x40(%rbp), %rdi
callq 0x8f50
movq -0x100(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x5d22
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3250
jmp 0x5d19
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x32d0
leaq -0x50(%rbp), %rdi
callq 0x3c00
leaq -0x48(%rbp), %rdi
callq 0x3c00
leaq -0x40(%rbp), %rdi
callq 0x8f50
movq -0x60(%rbp), %rdi
callq 0x2280
nopw %cs:(%rax,%rax)