// File: /workspace/github_c_makefile_star2_O0/UCLA-StarAI[P]TrimBN/src/fnf/compiler.c
// Function: fnf_to_sdd_manual
SddNode* fnf_to_sdd_manual(Fnf* fnf, SddManager* manager) {
  SddCompilerOptions* options = sdd_manager_options(manager);
  int verbose      = options->verbose;
  int period       = options->vtree_search_mode;
  BoolOp op        = fnf->op;
  SddSize count    = fnf->litset_count;
  LitSet** litsets = (LitSet**) malloc(count*sizeof(LitSet*));
  for (SddSize i=0; i<count; i++) litsets[i] = fnf->litsets + i;
  sort_litsets_by_lca(litsets,count,manager);

  if(verbose) { printf("\nclauses: %ld ",count); fflush(stdout); }
  SddNode* node = ONE(manager,op);
  for(int i=0; i<count; i++) {
    if(period > 0 && i > 0 && i%period==0) {
      // after every period clauses
      sdd_ref(node,manager);
      if(options->verbose) { printf("* "); fflush(stdout); }
      sdd_manager_minimize_limited(manager);
      sdd_deref(node,manager);
      sort_litsets_by_lca(litsets+i,count-i,manager);
    }

    SddNode* l = apply_litset(litsets[i],manager);
    node = sdd_apply(l,node,op,manager);
    if(verbose) { printf("%ld ",count-i-1); fflush(stdout); }
  }
  free(litsets);
  return node;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq 0x58(%rsp), %rdi
callq 0x77e0
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movl 0x58(%rax), %eax
movl %eax, 0x4c(%rsp)
movq 0x50(%rsp), %rax
movl 0x50(%rax), %eax
movl %eax, 0x48(%rsp)
movq 0x60(%rsp), %rax
movw 0x18(%rax), %ax
movw %ax, 0x46(%rsp)
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rdi
shlq $0x3, %rdi
callq 0x2190
movq %rax, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movq 0x28(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x29d9
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rdx
imulq $0x30, 0x28(%rsp), %rax
addq %rax, %rdx
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0x299d
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x58(%rsp), %rdx
callq 0x2ed0
cmpl $0x0, 0x4c(%rsp)
je 0x2a16
movq 0x38(%rsp), %rsi
leaq 0x21730(%rip), %rdi     # 0x24130
movb $0x0, %al
callq 0x20c0
movq 0x285b2(%rip), %rax     # 0x2afc0
movq (%rax), %rdi
callq 0x21a0
movzwl 0x46(%rsp), %eax
cmpl $0x0, %eax
jne 0x2a31
movq 0x58(%rsp), %rdi
callq 0x7530
movq %rax, 0x8(%rsp)
jmp 0x2a40
movq 0x58(%rsp), %rdi
callq 0x7540
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x20(%rsp)
movl $0x0, 0x1c(%rsp)
movslq 0x1c(%rsp), %rax
cmpq 0x38(%rsp), %rax
jae 0x2b83
cmpl $0x0, 0x48(%rsp)
jle 0x2afe
cmpl $0x0, 0x1c(%rsp)
jle 0x2afe
movl 0x1c(%rsp), %eax
cltd
idivl 0x48(%rsp)
cmpl $0x0, %edx
jne 0x2afe
movq 0x20(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0xa950
movq 0x50(%rsp), %rax
cmpl $0x0, 0x58(%rax)
je 0x2abd
leaq 0x21698(%rip), %rdi     # 0x2413f
movb $0x0, %al
callq 0x20c0
movq 0x2850b(%rip), %rax     # 0x2afc0
movq (%rax), %rdi
callq 0x21a0
movq 0x58(%rsp), %rdi
callq 0x7850
movq 0x20(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0xaa40
movq 0x30(%rsp), %rdi
movslq 0x1c(%rsp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq 0x38(%rsp), %rsi
movslq 0x1c(%rsp), %rax
subq %rax, %rsi
movq 0x58(%rsp), %rdx
callq 0x2ed0
movq 0x30(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x58(%rsp), %rsi
callq 0x2860
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
movw 0x46(%rsp), %ax
movq 0x58(%rsp), %rcx
movzwl %ax, %edx
callq 0xc9b0
movq %rax, 0x20(%rsp)
cmpl $0x0, 0x4c(%rsp)
je 0x2b71
movq 0x38(%rsp), %rsi
movslq 0x1c(%rsp), %rax
subq %rax, %rsi
subq $0x1, %rsi
leaq 0x215df(%rip), %rdi     # 0x2413a
movb $0x0, %al
callq 0x20c0
movq 0x28457(%rip), %rax     # 0x2afc0
movq (%rax), %rdi
callq 0x21a0
jmp 0x2b73
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x2a52
movq 0x30(%rsp), %rdi
callq 0x2030
movq 0x20(%rsp), %rax
addq $0x68, %rsp
retq
nopw (%rax,%rax)