// File: /workspace/github_c_makefile_star2_O3/craigbarnes[P]lua-gumbo/lib/parser.c
// Function: insert_node
static void insert_node(GumboNode* node, InsertionLocation location) {
  assert(node->parent == NULL);
  assert(node->index_within_parent == (unsigned int) -1);
  GumboNode* parent = location.target;
  int index = location.index;
  if (index != -1) {
    GumboVector* children = NULL;
    if (
      parent->type == GUMBO_NODE_ELEMENT
      || parent->type == GUMBO_NODE_TEMPLATE
    ) {
      children = &parent->v.element.children;
    } else if (parent->type == GUMBO_NODE_DOCUMENT) {
      children = &parent->v.document.children;
      assert(children->length == 0);
    } else {
      assert(0);
    }

    assert(index >= 0);
    assert((unsigned int) index < children->length);
    node->parent = parent;
    node->index_within_parent = index;
    gumbo_vector_insert_at((void*) node, index, children);
    assert(node->index_within_parent < children->length);
    for (unsigned int i = index + 1; i < children->length; ++i) {
      GumboNode* sibling = children->data[i];
      sibling->index_within_parent = i;
      assert(sibling->index_within_parent < children->length);
    }
  } else {
    append_node(parent, node);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
cmpq $0x0, 0x8(%rdi)
jne 0x861b
movq %rdi, %r14
cmpl $-0x1, 0x10(%rdi)
jne 0x863a
movl %edx, %ebx
movq %rsi, %r15
cmpl $-0x1, %edx
je 0x8605
movl (%r15), %eax
cmpl $0x6, %eax
je 0x859b
cmpl $0x1, %eax
je 0x859b
testl %eax, %eax
jne 0x86b6
cmpl $0x0, 0x20(%r15)
jne 0x86d5
testl %ebx, %ebx
js 0x8659
cmpl %ebx, 0x20(%r15)
jbe 0x8678
leaq 0x18(%r15), %r12
movq %r15, 0x8(%r14)
movl %ebx, 0x10(%r14)
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
callq 0x7c0e
movl 0x20(%r15), %eax
cmpl %eax, 0x10(%r14)
jae 0x8697
leal 0x1(%rbx), %ecx
cmpl %eax, %ecx
jae 0x85f9
movq (%r12), %rdx
movl %ebx, %esi
leaq (%rdx,%rsi,8), %rdx
addq $0x8, %rdx
movq (%rdx), %rsi
movl %ecx, 0x10(%rsi)
addq $0x8, %rdx
incl %ecx
cmpl %ecx, %eax
jne 0x85e9
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %r15, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x8779
leaq 0x13556(%rip), %rdi     # 0x1bb78
leaq 0x13307(%rip), %rsi     # 0x1b930
leaq 0x1355d(%rip), %rcx     # 0x1bb8d
movl $0x364, %edx            # imm = 0x364
callq 0x4100
leaq 0x1357d(%rip), %rdi     # 0x1bbbe
leaq 0x132e8(%rip), %rsi     # 0x1b930
leaq 0x1353e(%rip), %rcx     # 0x1bb8d
movl $0x365, %edx            # imm = 0x365
callq 0x4100
leaq 0x14ad1(%rip), %rdi     # 0x1d131
leaq 0x132c9(%rip), %rsi     # 0x1b930
leaq 0x1351f(%rip), %rcx     # 0x1bb8d
movl $0x376, %edx            # imm = 0x376
callq 0x4100
leaq 0x13584(%rip), %rdi     # 0x1bc03
leaq 0x132aa(%rip), %rsi     # 0x1b930
leaq 0x13500(%rip), %rcx     # 0x1bb8d
movl $0x377, %edx            # imm = 0x377
callq 0x4100
leaq 0x1358d(%rip), %rdi     # 0x1bc2b
leaq 0x1328b(%rip), %rsi     # 0x1b930
leaq 0x134e1(%rip), %rcx     # 0x1bb8d
movl $0x37b, %edx            # imm = 0x37B
callq 0x4100
leaq 0x14d88(%rip), %rdi     # 0x1d445
leaq 0x1326c(%rip), %rsi     # 0x1b930
leaq 0x134c2(%rip), %rcx     # 0x1bb8d
movl $0x373, %edx            # imm = 0x373
callq 0x4100
leaq 0x13511(%rip), %rdi     # 0x1bbed
leaq 0x1324d(%rip), %rsi     # 0x1b930
leaq 0x134a3(%rip), %rcx     # 0x1bb8d
movl $0x371, %edx            # imm = 0x371
callq 0x4100