// File: /workspace/github_c_makefile_star2_O2/reactive-systems[P]aiger-ltl-model-checker/aiger.c
// Function: aiger_reencode
void
aiger_reencode (aiger * public)
{
  unsigned *code, i, j, size_code, old, new, lhs, rhs0, rhs1, tmp;
  unsigned *stack, size_stack;
  IMPORT_private_FROM (public);

  assert (!aiger_error (public));

  aiger_symbol *symbol;
  aiger_type *type;
  aiger_and *and;

  if (aiger_is_reencoded (public))
    return;

  size_code = 2 * (public->maxvar + 1);
  if (size_code < 2)
    size_code = 2;

  NEWN (code, size_code);

  code[1] = 1;			/* not used actually */

  new = 2;

  for (i = 0; i < public->num_inputs; i++)
    {
      old = public->inputs[i].lit;

      code[old] = new;
      code[old + 1] = new + 1;

      new += 2;
    }

  for (i = 0; i < public->num_latches; i++)
    {
      old = public->latches[i].lit;

      code[old] = new;
      code[old + 1] = new + 1;

      new += 2;
    }

  stack = 0;
  size_stack = 0;

  for (i = 0; i < public->num_latches; i++)
    {
      old = public->latches[i].next;
      public->latches[i].next =
	aiger_reencode_lit (public, old, &new, code, &stack, &size_stack);

      old = public->latches[i].reset;
      public->latches[i].reset =
	aiger_reencode_lit (public, old, &new, code, &stack, &size_stack);
    }

  for (i = 0; i < public->num_outputs; i++)
    {
      old = public->outputs[i].lit;
      public->outputs[i].lit =
	aiger_reencode_lit (public, old, &new, code, &stack, &size_stack);
    }

  for (i = 0; i < public->num_bad; i++)
    {
      old = public->bad[i].lit;
      public->bad[i].lit =
	aiger_reencode_lit (public, old, &new, code, &stack, &size_stack);
    }

  for (i = 0; i < public->num_constraints; i++)
    {
      old = public->constraints[i].lit;
      public->constraints[i].lit =
	aiger_reencode_lit (public, old, &new, code, &stack, &size_stack);
    }

  for (i = 0; i < public->num_justice; i++)
    {
      for (j = 0; j < public->justice[i].size; j++)
	{
	  old = public->justice[i].lits[j];
	  public->justice[i].lits[j] =
	    aiger_reencode_lit (public, old, &new, code, &stack, &size_stack);
	}
    }

  for (i = 0; i < public->num_fairness; i++)
    {
      old = public->fairness[i].lit;
      public->fairness[i].lit =
	aiger_reencode_lit (public, old, &new, code, &stack, &size_stack);
    }

  DELETEN (stack, size_stack);

  j = 0;
  for (i = 0; i < public->num_ands; i++)
    {
      and = public->ands + i;
      lhs = code[and->lhs];
      if (!lhs)
	continue;

      rhs0 = code[and->rhs0];
      rhs1 = code[and->rhs1];

      and = public->ands + j++;

      if (rhs0 < rhs1)
	{
	  tmp = rhs1;
	  rhs1 = rhs0;
	  rhs0 = tmp;
	}

      assert (lhs > rhs0);
      assert (rhs0 >= rhs1);

      and->lhs = lhs;
      and->rhs0 = rhs0;
      and->rhs1 = rhs1;
    }
  public->num_ands = j;

  qsort (public->ands, j, sizeof (*and), cmp_lhs);

  assert (new);
  assert (public->maxvar >= aiger_lit2var (new - 1));
  public->maxvar = aiger_lit2var (new - 1);

  /* Reset types.
   */
  for (i = 1; i <= public->maxvar; i++)
    {
      type = private->types + i;
      type->input = 0;
      type->latch = 0;
      type->and = 0;
      type->idx = 0;
    }

  /* Fix types for ANDs.
   */
  for (i = 0; i < public->num_ands; i++)
    {
      and = public->ands + i;
      type = private->types + aiger_lit2var (and->lhs);
      type->and = 1;
      type->idx = i;
    }

  /* Fix types for inputs.
   */
  for (i = 0; i < public->num_inputs; i++)
    {
      symbol = public->inputs + i;
      assert (symbol->lit < size_code);
      symbol->lit = code[symbol->lit];
      type = private->types + aiger_lit2var (symbol->lit);
      type->input = 1;
      type->idx = i;
    }

  /* Fix types for latches.
   */
  for (i = 0; i < public->num_latches; i++)
    {
      symbol = public->latches + i;
      symbol->lit = code[symbol->lit];
      type = private->types + aiger_lit2var (symbol->lit);
      type->latch = 1;
      type->idx = i;
    }

  DELETEN (code, size_code);

#ifndef NDEBUG
  for (i = 0; i <= public->maxvar; i++)
    {
      type = private->types + i;
      assert (!(type->input && type->latch));
      assert (!(type->input && type->and));
      assert (!(type->latch && type->and));
    }
#endif
  assert (aiger_is_reencoded (public));
  assert (!aiger_check (public));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpq $0x0, 0xd0(%rdi)
jne 0x3e4a
movq %rdi, %r15
callq 0x378b
testl %eax, %eax
jne 0x3dbf
movl (%r15), %eax
leal 0x2(,%rax,2), %eax
testl %eax, %eax
pushq $0x2
popq %r12
cmovel %r12d, %eax
movq %rax, -0x58(%rbp)
leaq (,%rax,4), %rbx
movq 0xb8(%r15), %rdi
movq %rbx, %rsi
callq *0xc0(%r15)
xorl %r14d, %r14d
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, -0x50(%rbp)
movq %rbx, %rdx
movq %rax, %rbx
callq 0x1100
movl $0x1, 0x4(%rbx)
xorl %eax, %eax
movl 0x4(%r15), %ecx
cmpq %rcx, %rax
jae 0x398a
movq 0x28(%r15), %rcx
movl (%rcx,%r14), %ecx
movl %r12d, (%rbx,%rcx,4)
leal 0x1(%r12), %edx
incl %ecx
movl %edx, (%rbx,%rcx,4)
addl $0x2, %r12d
incq %rax
addq $0x20, %r14
jmp 0x395e
xorl %eax, %eax
xorl %ecx, %ecx
movl 0x8(%r15), %edx
cmpq %rdx, %rcx
jae 0x39b9
movq 0x30(%r15), %rdx
movl (%rdx,%rax), %edx
movl %r12d, (%rbx,%rdx,4)
leal 0x1(%r12), %esi
incl %edx
movl %esi, (%rbx,%rdx,4)
addl $0x2, %r12d
incq %rcx
addq $0x20, %rax
jmp 0x398e
movq %rbx, -0x38(%rbp)
leaq -0x40(%rbp), %rax
andq $0x0, (%rax)
leaq -0x30(%rbp), %rax
andl $0x0, (%rax)
leaq -0x2c(%rbp), %rax
movl %r12d, (%rax)
xorl %r12d, %r12d
xorl %ecx, %ecx
movq -0x38(%rbp), %r13
movl %edx, %eax
cmpq %rax, %rcx
jae 0x3a4a
movq 0x30(%r15), %rax
movl 0x4(%rax,%r12), %esi
movq %r15, %rdi
leaq -0x2c(%rbp), %rdx
movq %rcx, -0x48(%rbp)
movq %r13, %rcx
leaq -0x40(%rbp), %r14
movq %r14, %r8
leaq -0x30(%rbp), %rbx
movq %rbx, %r9
callq 0x3ee5
movq 0x30(%r15), %rcx
movl %eax, 0x4(%rcx,%r12)
movl 0x8(%rcx,%r12), %esi
movq %r15, %rdi
leaq -0x2c(%rbp), %rdx
movq %r13, %rcx
movq %r14, %r8
movq %rbx, %r9
callq 0x3ee5
movq 0x30(%r15), %rcx
movl %eax, 0x8(%rcx,%r12)
movq -0x48(%rbp), %rcx
incq %rcx
movl 0x8(%r15), %edx
addq $0x20, %r12
jmp 0x39dc
xorl %r14d, %r14d
leaq -0x40(%rbp), %r12
leaq -0x30(%rbp), %r13
xorl %ebx, %ebx
movl 0xc(%r15), %eax
cmpq %rax, %rbx
jae 0x3a8f
movq 0x38(%r15), %rax
movl (%rax,%r14), %esi
movq %r15, %rdi
leaq -0x2c(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq %r12, %r8
movq %r13, %r9
callq 0x3ee5
movq 0x38(%r15), %rcx
movl %eax, (%rcx,%r14)
incq %rbx
addq $0x20, %r14
jmp 0x3a57
xorl %r14d, %r14d
leaq -0x40(%rbp), %r12
leaq -0x30(%rbp), %r13
xorl %ebx, %ebx
movl 0x14(%r15), %eax
cmpq %rax, %rbx
jae 0x3ad4
movq 0x40(%r15), %rax
movl (%rax,%r14), %esi
movq %r15, %rdi
leaq -0x2c(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq %r12, %r8
movq %r13, %r9
callq 0x3ee5
movq 0x40(%r15), %rcx
movl %eax, (%rcx,%r14)
incq %rbx
addq $0x20, %r14
jmp 0x3a9c
xorl %r14d, %r14d
leaq -0x40(%rbp), %r12
leaq -0x30(%rbp), %r13
xorl %ebx, %ebx
movl 0x18(%r15), %eax
cmpq %rax, %rbx
jae 0x3b19
movq 0x48(%r15), %rax
movl (%rax,%r14), %esi
movq %r15, %rdi
leaq -0x2c(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq %r12, %r8
movq %r13, %r9
callq 0x3ee5
movq 0x48(%r15), %rcx
movl %eax, (%rcx,%r14)
incq %rbx
addq $0x20, %r14
jmp 0x3ae1
xorl %edx, %edx
leaq -0x30(%rbp), %r14
movl 0x1c(%r15), %eax
cmpq %rax, %rdx
jae 0x3b84
movq %r15, %r13
movq 0x50(%r15), %rcx
movq %rdx, -0x48(%rbp)
movq %rdx, %r15
shlq $0x5, %r15
xorl %ebx, %ebx
movl 0xc(%rcx,%r15), %eax
cmpq %rax, %rbx
jae 0x3b78
addq %r15, %rcx
movq 0x10(%rcx), %rax
movl (%rax,%rbx,4), %esi
movq %r13, %rdi
leaq -0x2c(%rbp), %rdx
movq -0x38(%rbp), %rcx
leaq -0x40(%rbp), %r8
movq %r14, %r9
callq 0x3ee5
movq 0x50(%r13), %rcx
movq 0x10(%rcx,%r15), %rdx
movl %eax, (%rdx,%rbx,4)
incq %rbx
jmp 0x3b3c
movq -0x48(%rbp), %rdx
incq %rdx
movq %r13, %r15
jmp 0x3b1f
xorl %r14d, %r14d
leaq -0x40(%rbp), %r12
leaq -0x30(%rbp), %r13
xorl %ebx, %ebx
movl 0x20(%r15), %eax
cmpq %rax, %rbx
jae 0x3bc9
movq 0x58(%r15), %rax
movl (%rax,%r14), %esi
movq %r15, %rdi
leaq -0x2c(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq %r12, %r8
movq %r13, %r9
callq 0x3ee5
movq 0x58(%r15), %rcx
movl %eax, (%rcx,%r14)
incq %rbx
addq $0x20, %r14
jmp 0x3b91
movl -0x30(%rbp), %edx
shlq $0x2, %rdx
movq 0xb8(%r15), %rdi
movq -0x40(%rbp), %rsi
callq *0xc8(%r15)
movl 0x10(%r15), %eax
imulq $0xc, %rax, %rax
xorl %ecx, %ecx
xorl %edx, %edx
movq -0x38(%rbp), %rbx
movl %edx, %esi
cmpq %rcx, %rax
je 0x3c50
movq 0x60(%r15), %rdi
movl (%rdi,%rcx), %r8d
movl (%rbx,%r8,4), %r8d
testl %r8d, %r8d
je 0x3c4a
movl 0x4(%rdi,%rcx), %r9d
movl 0x8(%rdi,%rcx), %r10d
movl (%rbx,%r9,4), %r11d
movl (%rbx,%r10,4), %r9d
cmpl %r9d, %r11d
movl %r9d, %r10d
cmoval %r11d, %r10d
cmpl %r10d, %r8d
jbe 0x3e2b
cmpl %r9d, %r11d
cmovbl %r11d, %r9d
imulq $0xc, %rsi, %rsi
incl %edx
movl %r8d, (%rdi,%rsi)
movl %r10d, 0x4(%rdi,%rsi)
movl %r9d, 0x8(%rdi,%rsi)
addq $0xc, %rcx
jmp 0x3bf2
movl %edx, 0x10(%r15)
movq 0x60(%r15), %rdi
leaq 0x945(%rip), %rcx       # 0x45a4
pushq $0xc
popq %rdx
callq 0x1090
movl -0x2c(%rbp), %eax
testl %eax, %eax
je 0x3e69
decl %eax
shrl %eax
cmpl %eax, (%r15)
movq -0x58(%rbp), %rdi
jb 0x3e88
movl %eax, (%r15)
pushq $0x1
popq %rcx
cmpl %eax, %ecx
ja 0x3ca3
movq 0x70(%r15), %rax
movl %ecx, %edx
andb $-0x8, (%rax,%rdx,8)
andl $0x0, 0x4(%rax,%rdx,8)
incl %ecx
movl (%r15), %eax
jmp 0x3c89
xorl %eax, %eax
xorl %ecx, %ecx
movl 0x10(%r15), %edx
cmpq %rdx, %rcx
jae 0x3cce
movq 0x60(%r15), %rdx
movq 0x70(%r15), %rsi
movl (%rdx,%rax), %edx
shrl %edx
orb $0x4, (%rsi,%rdx,8)
movl %ecx, 0x4(%rsi,%rdx,8)
incq %rcx
addq $0xc, %rax
jmp 0x3ca7
xorl %eax, %eax
xorl %ecx, %ecx
movl 0x4(%r15), %edx
cmpq %rdx, %rcx
jae 0x3d07
movq 0x28(%r15), %rdx
movl (%rdx,%rax), %esi
cmpl %edi, %esi
jae 0x3dce
movl (%rbx,%rsi,4), %esi
movl %esi, (%rdx,%rax)
movq 0x70(%r15), %rdx
shrl %esi
orb $0x1, (%rdx,%rsi,8)
movl %ecx, 0x4(%rdx,%rsi,8)
incq %rcx
addq $0x20, %rax
jmp 0x3cd2
xorl %eax, %eax
xorl %ecx, %ecx
movl 0x8(%r15), %edx
cmpq %rdx, %rcx
jae 0x3d38
movq 0x30(%r15), %rdx
movl (%rdx,%rax), %esi
movl (%rbx,%rsi,4), %esi
movl %esi, (%rdx,%rax)
movq 0x70(%r15), %rdx
shrl %esi
orb $0x2, (%rdx,%rsi,8)
movl %ecx, 0x4(%rdx,%rsi,8)
incq %rcx
addq $0x20, %rax
jmp 0x3d0b
movq 0xb8(%r15), %rdi
movq %rbx, %rsi
movq -0x50(%rbp), %rdx
callq *0xc8(%r15)
movl (%r15), %eax
movq 0x70(%r15), %rcx
xorl %edx, %edx
cmpl %eax, %edx
ja 0x3d9e
movl %edx, %esi
movb (%rcx,%rsi,8), %sil
notb %sil
testb $0x3, %sil
je 0x3ded
testb $0x5, %sil
je 0x3e0c
incl %edx
testb $0x6, %sil
jne 0x3d56
leaq 0x48e7(%rip), %rdi      # 0x866d
leaq 0x4566(%rip), %rsi      # 0x82f3
leaq 0x4835(%rip), %rcx      # 0x85c9
movl $0x681, %edx            # imm = 0x681
callq 0x10f0
movq %r15, %rdi
callq 0x378b
testl %eax, %eax
je 0x3ea7
movq %r15, %rdi
callq 0x2d8d
testq %rax, %rax
jne 0x3ec6
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4846(%rip), %rdi      # 0x861b
leaq 0x4517(%rip), %rsi      # 0x82f3
leaq 0x47e6(%rip), %rcx      # 0x85c9
movl $0x667, %edx            # imm = 0x667
callq 0x10f0
leaq 0x483f(%rip), %rdi      # 0x8633
leaq 0x44f8(%rip), %rsi      # 0x82f3
leaq 0x47c7(%rip), %rcx      # 0x85c9
movl $0x67f, %edx            # imm = 0x67F
callq 0x10f0
leaq 0x483e(%rip), %rdi      # 0x8651
leaq 0x44d9(%rip), %rsi      # 0x82f3
leaq 0x47a8(%rip), %rcx      # 0x85c9
movl $0x680, %edx            # imm = 0x680
callq 0x10f0
leaq 0x47b4(%rip), %rdi      # 0x85e6
leaq 0x44ba(%rip), %rsi      # 0x82f3
leaq 0x4789(%rip), %rcx      # 0x85c9
movl $0x63e, %edx            # imm = 0x63E
callq 0x10f0
leaq 0x44f0(%rip), %rdi      # 0x8341
leaq 0x449b(%rip), %rsi      # 0x82f3
leaq 0x476a(%rip), %rcx      # 0x85c9
movl $0x5cd, %edx            # imm = 0x5CD
callq 0x10f0
leaq 0x4fe3(%rip), %rdi      # 0x8e53
leaq 0x447c(%rip), %rsi      # 0x82f3
leaq 0x474b(%rip), %rcx      # 0x85c9
movl $0x649, %edx            # imm = 0x649
callq 0x10f0
leaq 0x4762(%rip), %rdi      # 0x85f1
leaq 0x445d(%rip), %rsi      # 0x82f3
leaq 0x472c(%rip), %rcx      # 0x85c9
movl $0x64a, %edx            # imm = 0x64A
callq 0x10f0
leaq 0x47db(%rip), %rdi      # 0x8689
leaq 0x443e(%rip), %rsi      # 0x82f3
leaq 0x470d(%rip), %rcx      # 0x85c9
movl $0x684, %edx            # imm = 0x684
callq 0x10f0
leaq 0x47d8(%rip), %rdi      # 0x86a5
leaq 0x441f(%rip), %rsi      # 0x82f3
leaq 0x46ee(%rip), %rcx      # 0x85c9
movl $0x685, %edx            # imm = 0x685
callq 0x10f0