// File: cegme[P]vose/VoseTree.cc
// Function: VoseTree::merge_bags()
Vose VoseTree::merge_bags() {
  Vose v;
  size_t i = 0;
  for(; i != nodes.size(); ++i) {
    if (!nodes[i].isBag) break;
    v = v.merge(nodes[i].bag);
  }
  nodes.erase(nodes.begin(), nodes.begin()+i-1); // -1 because we have to replace it
  nodes[0] = vosetreenode(v);
  
  branches.erase(branches.begin(), branches.begin()+i-1);
  branches[0] = v.weight();
  v.init();
  return v;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
movq %rdi, -0x2a0(%rbp)
movq %rdi, %rax
movq %rax, -0x298(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x290(%rbp)
movb $0x0, -0x11(%rbp)
callq 0x4480
movq $0x0, -0x20(%rbp)
movq -0x290(%rbp), %rdi
movq -0x20(%rbp), %rax
movq %rax, -0x2a8(%rbp)
addq $0x38, %rdi
callq 0x4520
movq %rax, %rcx
movq -0x2a8(%rbp), %rax
cmpq %rcx, %rax
je 0x2c80
movq -0x290(%rbp), %rdi
addq $0x38, %rdi
movq -0x20(%rbp), %rsi
callq 0x4550
testb $0x1, (%rax)
jne 0x2c09
jmp 0x2c80
movq -0x290(%rbp), %rdi
addq $0x38, %rdi
movq -0x20(%rbp), %rsi
callq 0x4550
movq -0x2a0(%rbp), %rsi
movq %rax, %rdx
addq $0x38, %rdx
leaq -0xb0(%rbp), %rdi
callq 0x11650
jmp 0x2c39
movq -0x2a0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x48f0
leaq -0xb0(%rbp), %rdi
callq 0x46f0
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x2bc0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
jmp 0x2ee3
movq -0x290(%rbp), %rdi
addq $0x38, %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x4ce0
movq %rax, -0xd0(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x4d10
movq -0x2b8(%rbp), %rdi
callq 0x4ce0
movq %rax, -0xf0(%rbp)
movq -0x20(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x4d50
movq %rax, -0xe8(%rbp)
leaq -0xe8(%rbp), %rdi
movl $0x1, %esi
callq 0x4d90
movq %rax, -0xe0(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x4d10
movq -0x2b8(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq -0xd8(%rbp), %rdx
callq 0x4c50
movq %rax, -0x2b0(%rbp)
jmp 0x2d29
movq -0x2a0(%rbp), %rsi
movq -0x2b0(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x4570
jmp 0x2d4c
leaq -0x1c0(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x4680
jmp 0x2d61
movq -0x290(%rbp), %rdi
addq $0x38, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4550
movq %rax, %rdi
leaq -0x1c0(%rbp), %rsi
movq %rsi, -0x2d0(%rbp)
callq 0x4980
movq -0x2d0(%rbp), %rdi
callq 0x49e0
leaq -0x250(%rbp), %rdi
callq 0x46f0
movq -0x290(%rbp), %rdi
addq $0x20, %rdi
movq %rdi, -0x2c8(%rbp)
callq 0x4bb0
movq %rax, -0x260(%rbp)
leaq -0x258(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x4e70
movq -0x2c8(%rbp), %rdi
callq 0x4bb0
movq %rax, -0x280(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x280(%rbp), %rdi
callq 0x4eb0
movq %rax, -0x278(%rbp)
leaq -0x278(%rbp), %rdi
movl $0x1, %esi
callq 0x4ef0
movq %rax, -0x270(%rbp)
leaq -0x268(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x4e70
movq -0x2c8(%rbp), %rdi
movq -0x258(%rbp), %rsi
movq -0x268(%rbp), %rdx
callq 0x4de0
movq %rax, -0x2c0(%rbp)
jmp 0x2e4c
movq -0x2a0(%rbp), %rdi
movq -0x2c0(%rbp), %rax
movq %rax, -0x288(%rbp)
callq 0x4a10
movq %rax, -0x2d8(%rbp)
jmp 0x2e6f
movq -0x290(%rbp), %rdi
addq $0x20, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x48d0
movq -0x2d8(%rbp), %rcx
movq -0x2a0(%rbp), %rdi
movq %rcx, (%rax)
callq 0x10d30
jmp 0x2e9b
movb $0x1, -0x11(%rbp)
testb $0x1, -0x11(%rbp)
jne 0x2ed3
jmp 0x2ec7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xb8(%rbp)
movl %eax, -0xbc(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x46f0
jmp 0x2ee3
movq -0x2a0(%rbp), %rdi
callq 0x46f0
movq -0x298(%rbp), %rax
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
movq -0x2a0(%rbp), %rdi
callq 0x46f0
movq -0xb8(%rbp), %rdi
callq 0x22f0
nopl (%rax,%rax)