// File: /workspace/github_c_makefile_star2_O1/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 0x8a4b
movq %rdi, %r14
cmpl $-0x1, 0x10(%rdi)
jne 0x8a6a
movl %edx, %ebx
movq %rsi, %r15
cmpl $-0x1, %edx
je 0x8a35
movl (%r15), %eax
cmpl $0x6, %eax
je 0x89cb
cmpl $0x1, %eax
je 0x89cb
testl %eax, %eax
jne 0x8ae6
cmpl $0x0, 0x20(%r15)
jne 0x8b05
testl %ebx, %ebx
js 0x8a89
cmpl %ebx, 0x20(%r15)
jbe 0x8aa8
leaq 0x18(%r15), %r12
movq %r15, 0x8(%r14)
movl %ebx, 0x10(%r14)
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
callq 0x7fe1
movl 0x20(%r15), %eax
cmpl %eax, 0x10(%r14)
jae 0x8ac7
leal 0x1(%rbx), %ecx
cmpl %eax, %ecx
jae 0x8a29
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 0x8a19
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 0x8ba9
leaq 0x15006(%rip), %rdi     # 0x1da58
leaq 0x14db7(%rip), %rsi     # 0x1d810
leaq 0x1500d(%rip), %rcx     # 0x1da6d
movl $0x364, %edx            # imm = 0x364
callq 0x4100
leaq 0x1502d(%rip), %rdi     # 0x1da9e
leaq 0x14d98(%rip), %rsi     # 0x1d810
leaq 0x14fee(%rip), %rcx     # 0x1da6d
movl $0x365, %edx            # imm = 0x365
callq 0x4100
leaq 0x16581(%rip), %rdi     # 0x1f011
leaq 0x14d79(%rip), %rsi     # 0x1d810
leaq 0x14fcf(%rip), %rcx     # 0x1da6d
movl $0x376, %edx            # imm = 0x376
callq 0x4100
leaq 0x15034(%rip), %rdi     # 0x1dae3
leaq 0x14d5a(%rip), %rsi     # 0x1d810
leaq 0x14fb0(%rip), %rcx     # 0x1da6d
movl $0x377, %edx            # imm = 0x377
callq 0x4100
leaq 0x1503d(%rip), %rdi     # 0x1db0b
leaq 0x14d3b(%rip), %rsi     # 0x1d810
leaq 0x14f91(%rip), %rcx     # 0x1da6d
movl $0x37b, %edx            # imm = 0x37B
callq 0x4100
leaq 0x16838(%rip), %rdi     # 0x1f325
leaq 0x14d1c(%rip), %rsi     # 0x1d810
leaq 0x14f72(%rip), %rcx     # 0x1da6d
movl $0x373, %edx            # imm = 0x373
callq 0x4100
leaq 0x14fc1(%rip), %rdi     # 0x1dacd
leaq 0x14cfd(%rip), %rsi     # 0x1d810
leaq 0x14f53(%rip), %rcx     # 0x1da6d
movl $0x371, %edx            # imm = 0x371
callq 0x4100