// File: /workspace/github_cpp_makefile_star2_O2/temelmertcan[P]multgen/src/adders.cpp
// Function: create_lf_adder(int, bool, std::queue<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::deque<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>&)
void create_lf_adder (int size, bool carryin, std::queue<string>& verilog){

  int index = 0;

  string* g = new string[size];
  string* p = new string[size];

  string* gtmp = new string[size];
  string* ptmp = new string[size];


  ppx_preprocess(size,  carryin, index, "LF", gtmp, ptmp, verilog);
  pgtmp_to_pg(size, gtmp, g);
  pgtmp_to_pg(size, ptmp, p);

  verilog.push("\n// Ladner-Fischer Adder \n");

  int stage=0;

  // lf midsteps
  for (int diff = 1; diff < size; diff *= 2){
    verilog.push("");
    verilog.push("// LF stage " + to_string(++stage));

    for (int i=diff; i < size; i+=diff*2){

      for (int j = 0; j<diff && (i+j)<size; j++){
        string new_p = "p_" + to_string(stage)+ "_" + to_string(i+j);
        string new_g = "g_" + to_string(stage)+ "_" + to_string(i+j);

        verilog.push ("wire logic "+ new_p + ";");
        verilog.push ("wire logic "+ new_g + ";");

        verilog.push ("assign "+ new_p + " = " + p[i+j] + " & " + p[i-1] + ";");
        verilog.push ("assign "+ new_g + " = (" + p[i+j] + " & " + g[i-1] + ") | " + g[i+j] + ";");

        gtmp[i+j] =  new_g;
        ptmp[i+j] =  new_p;
      }
    }
    pgtmp_to_pg(size, gtmp, g);
    pgtmp_to_pg(size, ptmp, p);
  }

  verilog.push("");
  verilog.push("// LF postprocess ");

  ppx_postprocess (size, index, g, p, verilog);

  delete[] p;
  delete[] g;

  delete[] ptmp;
  delete[] gtmp;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rdx, %r12
movl %esi, -0x40(%rbp)
movl %edi, %r13d
movslq %edi, %rbx
movq %rbx, %r15
shlq $0x5, %r15
leaq 0x8(%r15), %rax
testl %ebx, %ebx
pushq $-0x1
popq %r14
cmovnsq %rax, %r14
movq %r14, %rdi
callq 0x2030
leaq 0x8(%rax), %rcx
movq %rcx, -0x98(%rbp)
movq %rbx, (%rax)
movq %rbx, -0x30(%rbp)
testl %ebx, %ebx
je 0x1609b
addq $0x18, %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
addq $0x20, %rax
addq $-0x20, %r15
jne 0x16085
movq -0x98(%rbp), %rax
movq %rax, -0x88(%rbp)
movq %r14, %rdi
callq 0x2030
movq %rax, %r15
addq $0x8, %rax
movq %rax, -0x90(%rbp)
movq -0x30(%rbp), %rax
movq %rax, (%r15)
testl %eax, %eax
je 0x160ec
leaq 0x18(%r15), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
addq $0x20, %rax
addq $-0x20, %rcx
jne 0x160d6
movq -0x90(%rbp), %rax
movq %rax, -0x118(%rbp)
movq %r14, %rdi
callq 0x2030
leaq 0x8(%rax), %rcx
movq %rcx, -0xf0(%rbp)
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
testl %ecx, %ecx
je 0x1613a
addq $0x18, %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
addq $0x20, %rax
addq $-0x20, %rcx
jne 0x16124
movq -0xf0(%rbp), %rax
movq %rax, -0x80(%rbp)
movq %r14, %rdi
callq 0x2030
leaq 0x8(%rax), %rcx
movq %rcx, -0xe8(%rbp)
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
testl %ecx, %ecx
je 0x16185
addq $0x18, %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
addq $0x20, %rax
addq $-0x20, %rcx
jne 0x1616f
movq -0xe8(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq 0x1b545(%rip), %rsi     # 0x316dc
leaq -0x210(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x20b0
movq %r12, (%rsp)
movzbl -0x40(%rbp), %esi
leaq -0x210(%rbp), %rcx
leaq -0x80(%rbp), %r8
leaq -0x78(%rbp), %r9
movl %r13d, %edi
callq 0x13d7c
leaq -0x210(%rbp), %rdi
callq 0x20f0
leaq -0x80(%rbp), %rsi
leaq -0x88(%rbp), %rdx
movl %r13d, %edi
callq 0x14ae8
leaq -0x78(%rbp), %rsi
leaq -0x118(%rbp), %rdx
movl %r13d, %edi
callq 0x14ae8
leaq 0x1ca89(%rip), %rsi     # 0x32c88
leaq -0x68(%rbp), %rdi
leaq -0xb8(%rbp), %rdx
callq 0x20b0
movq %r15, -0x140(%rbp)
movl %r13d, -0x34(%rbp)
leaq -0x68(%rbp), %rsi
movq %r12, %rdi
callq 0x120e4
leaq -0x68(%rbp), %rdi
callq 0x20f0
pushq $0x1
popq %rbx
movq $0x0, -0x70(%rbp)
leaq -0x1b0(%rbp), %r13
movl -0x34(%rbp), %r15d
movq %r12, -0x48(%rbp)
cmpl %r15d, %ebx
jge 0x16813
leaq -0x68(%rbp), %r15
movq %r15, %rdi
leaq 0x1d371(%rip), %rsi     # 0x335d1
leaq -0xb8(%rbp), %rdx
callq 0x20b0
movq %r12, %rdi
movq %r15, %rsi
callq 0x120e4
movq %r15, %rdi
callq 0x20f0
movq -0x70(%rbp), %rsi
incl %esi
leaq -0xb8(%rbp), %r14
movq %r14, %rdi
movq %rsi, -0x70(%rbp)
callq 0x11c73
movq %r15, %rdi
leaq 0x1ca01(%rip), %rsi     # 0x32ca3
movq %r14, %rdx
callq 0x11d49
movq %r12, %rdi
movq %r15, %rsi
callq 0x120e4
movq %r15, %rdi
callq 0x20f0
leaq -0xb8(%rbp), %rdi
callq 0x20f0
testl %ebx, %ebx
movl $0x0, %ecx
cmovgl %ebx, %ecx
leal (%rbx,%rbx), %eax
movslq %ebx, %rdx
movl %eax, -0xbc(%rbp)
movslq %eax, %rsi
shlq $0x5, %rcx
movq %rcx, -0x170(%rbp)
movq %rdx, %rcx
shlq $0x5, %rcx
movq -0x90(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x110(%rbp)
movq %rsi, -0x150(%rbp)
shlq $0x5, %rsi
movq %rsi, -0x148(%rbp)
movq -0x98(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x108(%rbp)
movq -0xf0(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x100(%rbp)
addq -0xe8(%rbp), %rcx
movq %rcx, -0xf8(%rbp)
cmpq -0x30(%rbp), %rdx
jge 0x167dc
movq %rdx, %rax
shlq $0x5, %rax
movq -0x90(%rbp), %rcx
addq %rax, %rcx
addq $-0x20, %rcx
movq %rcx, -0x168(%rbp)
movq -0x98(%rbp), %rcx
addq %rcx, %rax
addq $-0x20, %rax
movq %rax, -0x160(%rbp)
movq %rdx, -0x40(%rbp)
xorl %r12d, %r12d
movq %rdx, -0x158(%rbp)
cmpq %r12, -0x170(%rbp)
je 0x167a9
movq -0x40(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0x167a9
leaq -0xe0(%rbp), %rbx
movq %rbx, %rdi
movq -0x70(%rbp), %rsi
callq 0x11c73
movq %r13, %rdi
leaq 0x1c1f1(%rip), %rsi     # 0x325b9
movq %rbx, %rdx
callq 0x11d49
leaq -0xb8(%rbp), %rdi
movq %r13, %rsi
leaq 0x1cd65(%rip), %rdx     # 0x33146
callq 0x11ba1
leaq -0x138(%rbp), %r15
movq %r15, %rdi
movq -0x40(%rbp), %rsi
callq 0x11c73
leaq -0x68(%rbp), %rdi
leaq -0xb8(%rbp), %rbx
movq %rbx, %rsi
movq %r15, %rdx
callq 0x11bca
movq %r15, %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x20f0
movq %r13, %rdi
callq 0x20f0
leaq -0xe0(%rbp), %rbx
movq %rbx, %rdi
callq 0x20f0
movq %r15, %rdi
movq -0x70(%rbp), %rsi
callq 0x11c73
movq %rbx, %rdi
leaq 0x1c826(%rip), %rsi     # 0x32c72
movq %r15, %rdx
callq 0x11d49
movq %r13, %rdi
movq %rbx, %rsi
leaq 0x1cce5(%rip), %rdx     # 0x33146
callq 0x11ba1
leaq -0x190(%rbp), %rbx
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
callq 0x11c73
leaq -0xb8(%rbp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x11bca
movq %rbx, %rdi
callq 0x20f0
movq %r13, %rdi
callq 0x20f0
leaq -0xe0(%rbp), %rbx
movq %rbx, %rdi
callq 0x20f0
leaq -0x138(%rbp), %rdi
callq 0x20f0
movq %rbx, %rdi
leaq 0x1c799(%rip), %rsi     # 0x32c59
leaq -0x68(%rbp), %rdx
callq 0x11cd3
movq %r13, %rdi
movq %rbx, %rsi
leaq 0x1d20b(%rip), %rdx     # 0x336e1
callq 0x11ba1
movq -0x48(%rbp), %rdi
movq %r13, %rsi
callq 0x120e4
movq %r13, %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x20f0
movq %rbx, %rdi
leaq 0x1c758(%rip), %rsi     # 0x32c59
leaq -0xb8(%rbp), %rdx
callq 0x11cd3
movq %r13, %rdi
movq %rbx, %rsi
leaq 0x1d1c7(%rip), %rdx     # 0x336e1
callq 0x11ba1
movq -0x48(%rbp), %rdi
movq %r13, %rsi
callq 0x120e4
movq %r13, %rdi
callq 0x20f0
leaq -0xe0(%rbp), %rdi
callq 0x20f0
leaq -0x1d0(%rbp), %rbx
movq %rbx, %rdi
leaq 0x1c05f(%rip), %rsi     # 0x325af
leaq -0x68(%rbp), %rdx
callq 0x11cd3
leaq -0x1f0(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
leaq 0x1bce6(%rip), %rdx     # 0x32253
callq 0x11ba1
movq -0x110(%rbp), %rax
leaq (%rax,%r12), %rbx
leaq -0x190(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x11d77
leaq -0x138(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
leaq 0x1cbdf(%rip), %rdx     # 0x33185
callq 0x11ba1
leaq -0xe0(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq -0x168(%rbp), %rdx
callq 0x11d77
movq %r13, %rdi
movq %r14, %rsi
leaq 0x1d110(%rip), %rdx     # 0x336e1
callq 0x11ba1
movq -0x48(%rbp), %rdi
movq %r13, %rsi
callq 0x120e4
movq %r13, %rdi
callq 0x20f0
leaq -0xe0(%rbp), %rdi
callq 0x20f0
leaq -0x138(%rbp), %rdi
callq 0x20f0
leaq -0x190(%rbp), %rdi
callq 0x20f0
leaq -0x1f0(%rbp), %rdi
callq 0x20f0
leaq -0x1d0(%rbp), %rdi
callq 0x20f0
leaq -0x230(%rbp), %r14
movq %r14, %rdi
leaq 0x1bf78(%rip), %rsi     # 0x325af
leaq -0xb8(%rbp), %rdx
callq 0x11cd3
leaq -0x250(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
leaq 0x1be50(%rip), %rdx     # 0x324a7
callq 0x11ba1
leaq -0x1d0(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x11d77
leaq -0x1f0(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x1cb00(%rip), %rdx     # 0x33185
callq 0x11ba1
leaq -0x190(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq -0x160(%rbp), %rdx
callq 0x11d77
leaq -0x138(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x1c9b1(%rip), %rdx     # 0x33068
callq 0x11ba1
movq -0x108(%rbp), %rax
leaq (%rax,%r12), %rdx
leaq -0xe0(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x11d77
movq %r13, %rdi
movq %r14, %rsi
leaq 0x1cffb(%rip), %rdx     # 0x336e1
callq 0x11ba1
movq -0x48(%rbp), %rdi
movq %r13, %rsi
callq 0x120e4
movq %r13, %rdi
callq 0x20f0
leaq -0xe0(%rbp), %rdi
callq 0x20f0
leaq -0x138(%rbp), %rdi
callq 0x20f0
leaq -0x190(%rbp), %rdi
callq 0x20f0
leaq -0x1f0(%rbp), %rdi
callq 0x20f0
leaq -0x1d0(%rbp), %rdi
callq 0x20f0
leaq -0x250(%rbp), %rdi
callq 0x20f0
leaq -0x230(%rbp), %rdi
callq 0x20f0
movq -0x100(%rbp), %rax
leaq (%rax,%r12), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x2130
leaq -0x68(%rbp), %rbx
movq -0xf8(%rbp), %rax
leaq (%rax,%r12), %rdi
movq %rbx, %rsi
callq 0x2130
leaq -0xb8(%rbp), %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x20f0
addq $0x20, %r12
incq -0x40(%rbp)
movq -0x158(%rbp), %rdx
jmp 0x16390
addq -0x150(%rbp), %rdx
movq -0x148(%rbp), %rax
addq %rax, -0x110(%rbp)
addq %rax, -0x108(%rbp)
addq %rax, -0x100(%rbp)
addq %rax, -0xf8(%rbp)
movq -0x48(%rbp), %r12
jmp 0x16347
movl -0x34(%rbp), %r15d
movl %r15d, %edi
leaq -0x80(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x14ae8
movl %r15d, %edi
leaq -0x78(%rbp), %rsi
leaq -0x118(%rbp), %rdx
callq 0x14ae8
movl -0xbc(%rbp), %eax
movl %eax, %ebx
jmp 0x16249
leaq 0x1cdb7(%rip), %rsi     # 0x335d1
leaq -0x68(%rbp), %rdi
leaq -0xb8(%rbp), %rdx
callq 0x20b0
movq -0x140(%rbp), %r15
leaq -0x68(%rbp), %rsi
movq %r12, %rdi
callq 0x120e4
movl -0x34(%rbp), %ebx
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq 0x1c460(%rip), %rsi     # 0x32cb0
leaq -0x68(%rbp), %rdi
leaq -0xb8(%rbp), %rdx
callq 0x20b0
leaq -0x68(%rbp), %rsi
movq %r12, %rdi
callq 0x120e4
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq -0x88(%rbp), %rdx
movl %ebx, %edi
movq %r12, %r8
callq 0x146e9
movq (%r15), %rbx
testq %rbx, %rbx
je 0x168a8
shlq $0x5, %rbx
movq %r15, %r14
addq $-0x18, %r14
leaq (%r14,%rbx), %rdi
callq 0x20f0
addq $-0x20, %rbx
jne 0x16899
movq %r15, %rdi
callq 0x2230
movq -0x88(%rbp), %r14
testq %r14, %r14
je 0x168e8
leaq -0x8(%r14), %rbx
movq -0x8(%r14), %r15
testq %r15, %r15
je 0x168e0
addq $-0x20, %r14
shlq $0x5, %r15
leaq (%r14,%r15), %rdi
callq 0x20f0
addq $-0x20, %r15
jne 0x168d1
movq %rbx, %rdi
callq 0x2230
movq -0x78(%rbp), %r14
testq %r14, %r14
je 0x1691d
leaq -0x8(%r14), %rbx
movq -0x8(%r14), %r15
testq %r15, %r15
je 0x16915
addq $-0x20, %r14
shlq $0x5, %r15
leaq (%r14,%r15), %rdi
callq 0x20f0
addq $-0x20, %r15
jne 0x16906
movq %rbx, %rdi
callq 0x2230
movq -0x80(%rbp), %r14
testq %r14, %r14
je 0x16952
leaq -0x8(%r14), %rbx
movq -0x8(%r14), %r15
testq %r15, %r15
je 0x1694a
addq $-0x20, %r14
shlq $0x5, %r15
leaq (%r14,%r15), %rdi
callq 0x20f0
addq $-0x20, %r15
jne 0x1693b
movq %rbx, %rdi
callq 0x2230
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x16adf
jmp 0x16994
jmp 0x16adf
jmp 0x16994
jmp 0x16adf
jmp 0x16994
movq %rax, %rbx
leaq -0x210(%rbp), %rdi
jmp 0x16b74
jmp 0x16994
movq %rax, %rbx
jmp 0x169a8
jmp 0x16adf
movq %rax, %rbx
jmp 0x16b79
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq -0xb8(%rbp), %rdi
jmp 0x16b74
movq %rax, %rbx
jmp 0x16a26
movq %rax, %rbx
jmp 0x16a0e
movq %rax, %rbx
jmp 0x169f6
movq %rax, %rbx
jmp 0x16a76
movq %rax, %rbx
jmp 0x16a5e
jmp 0x16b61
movq %rax, %rbx
jmp 0x16a32
movq %rax, %rbx
jmp 0x16a1a
movq %rax, %rbx
jmp 0x16a02
movq %rax, %rbx
leaq -0x1b0(%rbp), %rdi
callq 0x20f0
leaq -0xe0(%rbp), %rdi
callq 0x20f0
leaq -0x138(%rbp), %rdi
callq 0x20f0
leaq -0x190(%rbp), %rdi
callq 0x20f0
leaq -0x1f0(%rbp), %rdi
callq 0x20f0
leaq -0x1d0(%rbp), %rdi
callq 0x20f0
leaq -0x250(%rbp), %rdi
callq 0x20f0
leaq -0x230(%rbp), %rdi
jmp 0x16b40
movq %rax, %rbx
jmp 0x16a6a
movq %rax, %rbx
leaq -0x1b0(%rbp), %rdi
callq 0x20f0
leaq -0xe0(%rbp), %rdi
callq 0x20f0
leaq -0x138(%rbp), %rdi
callq 0x20f0
leaq -0x190(%rbp), %rdi
callq 0x20f0
jmp 0x16af1
movq %rax, %rbx
jmp 0x16a3e
jmp 0x16ab3
movq %rax, %rbx
leaq -0x138(%rbp), %rdi
callq 0x20f0
jmp 0x16acf
movq %rax, %rbx
jmp 0x16afd
movq %rax, %rbx
jmp 0x16b2d
movq %rax, %rbx
jmp 0x16b15
jmp 0x16b61
movq %rax, %rbx
leaq -0x1b0(%rbp), %rdi
callq 0x20f0
jmp 0x16b39
movq %rax, %rbx
jmp 0x16b58
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x20f0
jmp 0x16b4c
jmp 0x16b36
movq %rax, %rbx
jmp 0x16b70
jmp 0x16b61
movq %rax, %rbx
jmp 0x16b21
movq %rax, %rbx
leaq -0x1f0(%rbp), %rdi
callq 0x20f0
leaq -0x1d0(%rbp), %rdi
jmp 0x16b40
movq %rax, %rbx
leaq -0x190(%rbp), %rdi
callq 0x20f0
leaq -0x1b0(%rbp), %rdi
callq 0x20f0
leaq -0xe0(%rbp), %rdi
callq 0x20f0
leaq -0x138(%rbp), %rdi
jmp 0x16b6b
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
callq 0x20f0
jmp 0x16b64
jmp 0x16b61
movq %rax, %rbx
leaq -0x1b0(%rbp), %rdi
callq 0x20f0
leaq -0xe0(%rbp), %rdi
jmp 0x16b74
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x20f0
leaq -0x68(%rbp), %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x2330