// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rsi, -0x10(%rbp)
movl %edx, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x8440
jmp 0x845f
leaq 0x2ad46(%rip), %rdi     # 0x3318d
leaq 0x2aa26(%rip), %rsi     # 0x32e74
movl $0x364, %edx            # imm = 0x364
leaq 0x2ad48(%rip), %rcx     # 0x331a2
callq 0x4100
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x10(%rax)
jne 0x846b
jmp 0x848a
leaq 0x2ad61(%rip), %rdi     # 0x331d3
leaq 0x2a9fb(%rip), %rsi     # 0x32e74
movl $0x365, %edx            # imm = 0x365
leaq 0x2ad1d(%rip), %rcx     # 0x331a2
callq 0x4100
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
je 0x8649
movq $0x0, -0x30(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x1, (%rax)
je 0x84bc
movq -0x20(%rbp), %rax
cmpl $0x6, (%rax)
jne 0x84ca
movq -0x20(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x30(%rbp)
jmp 0x852d
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x850c
movq -0x20(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x84eb
jmp 0x850a
leaq 0x2ad10(%rip), %rdi     # 0x33202
leaq 0x2a97b(%rip), %rsi     # 0x32e74
movl $0x371, %edx            # imm = 0x371
leaq 0x2ac9d(%rip), %rcx     # 0x331a2
callq 0x4100
jmp 0x852b
leaq 0x2c9dc(%rip), %rdi     # 0x34eef
leaq 0x2a95a(%rip), %rsi     # 0x32e74
movl $0x373, %edx            # imm = 0x373
leaq 0x2ac7c(%rip), %rcx     # 0x331a2
callq 0x4100
jmp 0x852d
cmpl $0x0, -0x24(%rbp)
jl 0x8535
jmp 0x8554
leaq 0x2c610(%rip), %rdi     # 0x34b4c
leaq 0x2a931(%rip), %rsi     # 0x32e74
movl $0x376, %edx            # imm = 0x376
leaq 0x2ac53(%rip), %rcx     # 0x331a2
callq 0x4100
movl -0x24(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x8562
jmp 0x8581
leaq 0x2acaf(%rip), %rdi     # 0x33218
leaq 0x2a904(%rip), %rsi     # 0x32e74
movl $0x377, %edx            # imm = 0x377
leaq 0x2ac26(%rip), %rcx     # 0x331a2
callq 0x4100
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x24(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0x6c50
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x30(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x85b9
jmp 0x85d8
leaq 0x2ac80(%rip), %rdi     # 0x33240
leaq 0x2a8ad(%rip), %rsi     # 0x32e74
movl $0x37b, %edx            # imm = 0x37B
leaq 0x2abcf(%rip), %rcx     # 0x331a2
callq 0x4100
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x8647
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl -0x34(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movl -0x34(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x40(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x30(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jae 0x861b
jmp 0x863a
leaq 0x2ac4b(%rip), %rdi     # 0x3326d
leaq 0x2a84b(%rip), %rsi     # 0x32e74
movl $0x37f, %edx            # imm = 0x37F
leaq 0x2ab6d(%rip), %rcx     # 0x331a2
callq 0x4100
jmp 0x863c
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x85e1
jmp 0x8656
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x87f0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)