// File: /workspace/github_c_makefile_star2_O2/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 0x8199
movq %rdi, %r14
cmpl $-0x1, 0x10(%rdi)
jne 0x81b8
movl %edx, %ebx
movq %rsi, %r15
cmpl $-0x1, %edx
je 0x8183
movl (%r15), %eax
cmpl $0x6, %eax
je 0x8127
cmpl $0x1, %eax
je 0x8127
testl %eax, %eax
jne 0x8234
cmpl $0x0, 0x20(%r15)
jne 0x8253
testl %ebx, %ebx
js 0x81d7
cmpl %ebx, 0x20(%r15)
jbe 0x81f6
leaq 0x18(%r15), %r12
movq %r15, 0x8(%r14)
movl %ebx, 0x10(%r14)
movq %r14, %rdi
movl %ebx, %esi
movq %r12, %rdx
callq 0x77ff
movl 0x20(%r15), %eax
cmpl %eax, 0x10(%r14)
jae 0x8215
movl %ebx, %ecx
incq %rcx
cmpq %rax, %rcx
jae 0x8177
movq (%r12), %rdx
movq (%rdx,%rcx,8), %rdx
movl %ecx, 0x10(%rdx)
jmp 0x8162
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 0x82fd
leaq 0x11948(%rip), %rdi     # 0x19ae8
leaq 0x116f9(%rip), %rsi     # 0x198a0
leaq 0x1194f(%rip), %rcx     # 0x19afd
movl $0x364, %edx            # imm = 0x364
callq 0x4100
leaq 0x1196f(%rip), %rdi     # 0x19b2e
leaq 0x116da(%rip), %rsi     # 0x198a0
leaq 0x11930(%rip), %rcx     # 0x19afd
movl $0x365, %edx            # imm = 0x365
callq 0x4100
leaq 0x12ec3(%rip), %rdi     # 0x1b0a1
leaq 0x116bb(%rip), %rsi     # 0x198a0
leaq 0x11911(%rip), %rcx     # 0x19afd
movl $0x376, %edx            # imm = 0x376
callq 0x4100
leaq 0x11976(%rip), %rdi     # 0x19b73
leaq 0x1169c(%rip), %rsi     # 0x198a0
leaq 0x118f2(%rip), %rcx     # 0x19afd
movl $0x377, %edx            # imm = 0x377
callq 0x4100
leaq 0x1197f(%rip), %rdi     # 0x19b9b
leaq 0x1167d(%rip), %rsi     # 0x198a0
leaq 0x118d3(%rip), %rcx     # 0x19afd
movl $0x37b, %edx            # imm = 0x37B
callq 0x4100
leaq 0x1317a(%rip), %rdi     # 0x1b3b5
leaq 0x1165e(%rip), %rsi     # 0x198a0
leaq 0x118b4(%rip), %rcx     # 0x19afd
movl $0x373, %edx            # imm = 0x373
callq 0x4100
leaq 0x11903(%rip), %rdi     # 0x19b5d
leaq 0x1163f(%rip), %rsi     # 0x198a0
leaq 0x11895(%rip), %rcx     # 0x19afd
movl $0x371, %edx            # imm = 0x371
callq 0x4100