// File: /workspace/github_cpp_makefile_star2_O2/temelmertcan[P]multgen/src/wallace.cpp
// Function: create_finaladder_inst(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>>>>>*&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int, 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>>>>>&, int&)
void create_finaladder_inst (std::queue<string>*& main_queue,
                             string final_stage_adder,
                             int out_size, int shift_amount,
                             std::queue<string>& verilog,
                             int& adder_size) {

  int final_offset = 0;
  int final_size = 0;
  bool flag = false;

  string final_in1 = " }";
  string final_in2 = " }";

  std::queue<string> fin1;
  std::queue<string> fin2;

  for (int j = 0; j < out_size; j++){

    if (flag || main_queue[j].size()>1) {
      flag = true;

      bool b = false;
      for (int i = j; main_queue[i].empty() && i<out_size; i++ )
        if (i==out_size-1)
          b=true;
      if(b)
        break;

      fin1.push (main_queue[j].empty() ? "1'b0" : main_queue[j].front());

      // final_in1 += (main_queue[j].empty() ? "1'b0" : main_queue[j].front());

      if (!main_queue[j].empty())
        main_queue[j].pop();

      fin2.push (main_queue[j].empty() ? "1'b0" : main_queue[j].front());
      //final_in2 += (main_queue[j].empty() ? "1'b0" : main_queue[j].front());
      if (!main_queue[j].empty())
        main_queue[j].pop();
      final_size++;

    } else {
      final_offset++;
      string cur = "assign result[" + to_string(j) + "] = "
        + main_queue[j].front() + ";";
      main_queue[j].pop();
      if (j>=shift_amount)
	verilog.push(cur);
    }
  }

  while (!fin1.empty()) {
    final_in1 = fin1.front() + final_in1;
    if (fin1.size() > 1)
      final_in1 = ", " + final_in1;
    else
      final_in1 = "{" + final_in1;
    fin1.pop();
  }

  while (!fin2.empty()) {
    final_in2 = fin2.front() + final_in2;
    if (fin2.size() > 1)
      final_in2 = ", " + final_in2;
    else
      final_in2 = "{" + final_in2;
    fin2.pop();
  }

  if (final_size > 0){
    string fin_inst = final_stage_adder + "_" + to_string (final_size)
      + " final_adder (" + final_in1 + ", " + final_in2;

    verilog.push
      ("logic ["
       + to_string(final_size)
       + ":0] adder_result;");

    fin_inst +=  ", adder_result );";

    verilog.push (fin_inst);

    if (shift_amount>final_offset)
      verilog.push ("assign result[" + to_string(out_size-1) + ":"
                  + to_string(shift_amount) + "] = adder_result[" +
                  to_string(out_size-1-final_offset) +":"+to_string(shift_amount-final_offset)+"];" );
    else
      verilog.push ("assign result[" + to_string(out_size-1) + ":"
		    + to_string(final_offset) + "] = adder_result[" +
		    to_string(out_size-1-final_offset) +":"+to_string(0)+"];" );
  }

  adder_size = final_size;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2d8, %rsp            # imm = 0x2D8
movq %r9, -0x148(%rbp)
movq %r8, -0x48(%rbp)
movl %ecx, -0x34(%rbp)
movl %edx, %ebx
movq %rsi, -0x140(%rbp)
movq %rdi, -0x40(%rbp)
leaq 0x7a20(%rip), %r14      # 0x33674
leaq -0x260(%rbp), %rdi
leaq -0x2b0(%rbp), %rdx
movq %r14, %rsi
callq 0x20b0
leaq -0x240(%rbp), %rdi
leaq -0x2b0(%rbp), %rdx
movq %r14, %rsi
callq 0x20b0
leaq -0x2b0(%rbp), %rdi
callq 0x11e0c
leaq -0x300(%rbp), %rdi
callq 0x11e0c
movslq %ebx, %r13
decl %ebx
movq %rbx, -0x50(%rbp)
movslq -0x34(%rbp), %rax
movq %rax, -0x150(%rbp)
xorl %ebx, %ebx
testl %r13d, %r13d
movl $0x0, %eax
cmovgl %r13d, %eax
movq %rax, -0x158(%rbp)
pushq $0x30
popq %rax
movq %rax, -0xf8(%rbp)
leaq -0xd0(%rbp), %r8
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
xorl %eax, %eax
cmpq -0x158(%rbp), %rbx
je 0x2bf45
movq -0x40(%rbp), %rcx
movq (%rcx), %rdi
testb $0x1, %al
jne 0x2bd1e
imulq $0x50, %rbx, %r14
addq %r14, %rdi
callq 0x1219a
cmpq $0x2, %rax
jb 0x2be58
movq -0x40(%rbp), %rax
movq (%rax), %rdi
leaq -0xd0(%rbp), %r8
movq -0xf8(%rbp), %rax
leaq (%rdi,%rax), %rcx
xorl %eax, %eax
movq %rbx, %rdx
cmpq %r13, %rdx
jge 0x2bd50
movq -0x20(%rcx), %rsi
cmpq %rsi, (%rcx)
jne 0x2bd50
cmpq %rdx, -0x50(%rbp)
sete %sil
orb %sil, %al
incq %rdx
addq $0x50, %rcx
jmp 0x2bd2e
testb $0x1, %al
jne 0x2bf45
movq %rbx, -0x160(%rbp)
imulq $0x50, %rbx, %rbx
movq 0x10(%rdi,%rbx), %r14
movq 0x30(%rdi,%rbx), %r15
cmpq %r14, %r15
je 0x2bd82
movq %r8, %rdi
movq %r14, %rsi
movq %r8, %r12
callq 0x2250
jmp 0x2bd98
movq %r8, %rdi
leaq 0x7238(%rip), %rsi      # 0x32fc4
leaq -0x36(%rbp), %rdx
movq %r8, %r12
callq 0x20b0
leaq -0x2b0(%rbp), %rdi
movq %r12, %rsi
callq 0x120e4
movq %r12, %rdi
callq 0x20f0
cmpq %r14, %r15
movq -0x40(%rbp), %r12
movq (%r12), %rdi
movq 0x10(%rdi,%rbx), %r14
movq 0x30(%rdi,%rbx), %r15
cmpq %r14, %r15
je 0x2bddf
addq %rbx, %rdi
callq 0x125d4
movq (%r12), %rax
movq 0x10(%rax,%rbx), %r14
movq 0x30(%rax,%rbx), %r15
cmpq %r14, %r15
je 0x2bdf8
leaq -0xd0(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x2250
jmp 0x2be12
leaq -0xd0(%rbp), %r12
movq %r12, %rdi
leaq 0x71bb(%rip), %rsi      # 0x32fc4
leaq -0x35(%rbp), %rdx
callq 0x20b0
leaq -0x300(%rbp), %rdi
movq %r12, %rsi
callq 0x120e4
movq %r12, %rdi
callq 0x20f0
cmpq %r14, %r15
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq 0x30(%rdi,%rbx), %rax
cmpq 0x10(%rdi,%rbx), %rax
je 0x2be47
addq %rbx, %rdi
callq 0x125d4
incl -0x30(%rbp)
movb $0x1, %al
movq -0x160(%rbp), %rbx
jmp 0x2bf2e
leaq -0xf0(%rbp), %r12
movq %r12, %rdi
movl %ebx, %esi
callq 0x11c73
leaq -0x70(%rbp), %r15
movq %r15, %rdi
leaq 0x782a(%rip), %rsi      # 0x336a1
movq %r12, %rdx
callq 0x11d49
leaq -0x90(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
leaq 0x63bf(%rip), %rdx      # 0x32252
callq 0x11ba1
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax,%r14), %rdx
leaq -0xb0(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x11d77
leaq -0xd0(%rbp), %rdi
movq %r15, %rsi
leaq 0x781a(%rip), %rdx      # 0x336e1
callq 0x11ba1
movq %r15, %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
callq 0x20f0
leaq -0x70(%rbp), %rdi
callq 0x20f0
leaq -0xf0(%rbp), %rdi
callq 0x20f0
movq -0x40(%rbp), %rax
addq (%rax), %r14
movq %r14, %rdi
callq 0x125d4
cmpq -0x150(%rbp), %rbx
jl 0x2bf1d
movq -0x48(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x19602
incl -0x2c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x20f0
xorl %eax, %eax
incq %rbx
addq $0x50, -0xf8(%rbp)
leaq -0xd0(%rbp), %r8
jmp 0x2bce2
leaq -0xd0(%rbp), %rbx
leaq -0x260(%rbp), %r15
leaq -0x2b0(%rbp), %r14
leaq 0x6695(%rip), %r12      # 0x325f6
leaq 0x6fd9(%rip), %r13      # 0x32f41
movq -0x2a0(%rbp), %rsi
cmpq %rsi, -0x280(%rbp)
je 0x2bfdf
movq %rbx, %rdi
movq %r15, %rdx
callq 0x11e2c
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x20f0
movq %r14, %rdi
callq 0x1219a
cmpq $0x2, %rax
jb 0x2bfb4
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x11cd3
jmp 0x2bfc2
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x11cd3
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x20f0
movq %r14, %rdi
callq 0x125d4
jmp 0x2bf68
leaq -0xd0(%rbp), %rbx
leaq -0x240(%rbp), %r15
leaq -0x300(%rbp), %r13
leaq 0x65fb(%rip), %r12      # 0x325f6
leaq 0x6f3f(%rip), %r14      # 0x32f41
movq -0x2f0(%rbp), %rsi
cmpq %rsi, -0x2d0(%rbp)
je 0x2c079
movq %rbx, %rdi
movq %r15, %rdx
callq 0x11e2c
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x20f0
movq %r13, %rdi
callq 0x1219a
cmpq $0x2, %rax
jb 0x2c04e
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x11cd3
jmp 0x2c05c
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x11cd3
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2210
movq %rbx, %rdi
callq 0x20f0
movq %r13, %rdi
callq 0x125d4
jmp 0x2c002
cmpl $0x0, -0x30(%rbp)
jle 0x2c4dc
leaq 0x70bc(%rip), %rdx      # 0x33146
leaq -0x138(%rbp), %rdi
movq -0x140(%rbp), %rsi
callq 0x11c3b
leaq -0x118(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x11c73
leaq -0xf0(%rbp), %rdi
leaq -0x138(%rbp), %rsi
leaq -0x118(%rbp), %rdx
callq 0x11bca
leaq 0x75e3(%rip), %rdx      # 0x336b0
leaq -0x70(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x11ba1
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x260(%rbp), %rdx
callq 0x11d77
leaq 0x64fb(%rip), %rdx      # 0x325f6
leaq -0xb0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x11ba1
leaq -0xd0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
leaq -0x240(%rbp), %rdx
callq 0x11d77
leaq -0xb0(%rbp), %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
callq 0x20f0
leaq -0x70(%rbp), %rdi
callq 0x20f0
leaq -0xf0(%rbp), %rdi
callq 0x20f0
leaq -0x118(%rbp), %rdi
callq 0x20f0
leaq -0x138(%rbp), %rdi
callq 0x20f0
leaq -0x70(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x11c73
leaq 0x5db2(%rip), %rsi      # 0x31f32
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x11d49
leaq 0x7528(%rip), %rdx      # 0x336bf
leaq -0xb0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x11ba1
leaq -0xb0(%rbp), %rsi
movq -0x48(%rbp), %rdi
callq 0x120e4
leaq -0xb0(%rbp), %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
callq 0x20f0
leaq -0x70(%rbp), %rdi
callq 0x20f0
leaq 0x74ef(%rip), %rsi      # 0x336d1
leaq -0xd0(%rbp), %rdi
callq 0x2340
leaq -0xd0(%rbp), %rsi
movq -0x48(%rbp), %rdi
callq 0x19602
movl -0x34(%rbp), %ebx
subl -0x2c(%rbp), %ebx
jle 0x2c329
leaq -0x1e0(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x11c73
leaq 0x7480(%rip), %rsi      # 0x336a1
leaq -0x200(%rbp), %rdi
leaq -0x1e0(%rbp), %rdx
callq 0x11d49
leaq 0x446f(%rip), %rdx      # 0x306aa
leaq -0x220(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x11ba1
leaq -0x1c0(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x11c73
leaq -0x118(%rbp), %rdi
leaq -0x220(%rbp), %rsi
leaq -0x1c0(%rbp), %rdx
callq 0x11bca
leaq 0x7465(%rip), %rdx      # 0x336e3
leaq -0x138(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x11ba1
movq -0x50(%rbp), %rsi
subl -0x2c(%rbp), %esi
leaq -0x1a0(%rbp), %rdi
callq 0x11c73
leaq -0xf0(%rbp), %rdi
leaq -0x138(%rbp), %rsi
leaq -0x1a0(%rbp), %rdx
callq 0x11bca
leaq 0x43e5(%rip), %rdx      # 0x306aa
leaq -0x70(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x11ba1
leaq -0x180(%rbp), %rdi
movl %ebx, %esi
callq 0x11c73
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x180(%rbp), %rdx
callq 0x11bca
leaq 0x674c(%rip), %rdx      # 0x32a4d
leaq -0xb0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x11ba1
leaq -0xb0(%rbp), %rsi
movq -0x48(%rbp), %rdi
callq 0x120e4
jmp 0x2c443
leaq -0x1e0(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x11c73
leaq 0x7361(%rip), %rsi      # 0x336a1
leaq -0x200(%rbp), %rdi
leaq -0x1e0(%rbp), %rdx
callq 0x11d49
leaq 0x4350(%rip), %rdx      # 0x306aa
leaq -0x220(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x11ba1
leaq -0x1c0(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x11c73
leaq -0x118(%rbp), %rdi
leaq -0x220(%rbp), %rsi
leaq -0x1c0(%rbp), %rdx
callq 0x11bca
leaq 0x7346(%rip), %rdx      # 0x336e3
leaq -0x138(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x11ba1
movq -0x50(%rbp), %rsi
subl -0x2c(%rbp), %esi
leaq -0x1a0(%rbp), %rdi
callq 0x11c73
leaq -0xf0(%rbp), %rdi
leaq -0x138(%rbp), %rsi
leaq -0x1a0(%rbp), %rdx
callq 0x11bca
leaq 0x42c6(%rip), %rdx      # 0x306aa
leaq -0x70(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x11ba1
leaq -0x180(%rbp), %rdi
xorl %esi, %esi
callq 0x11c73
leaq -0x90(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x180(%rbp), %rdx
callq 0x11bca
leaq 0x662d(%rip), %rdx      # 0x32a4d
leaq -0xb0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x11ba1
leaq -0xb0(%rbp), %rsi
movq -0x48(%rbp), %rdi
callq 0x120e4
leaq -0xb0(%rbp), %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
callq 0x20f0
leaq -0x180(%rbp), %rdi
callq 0x20f0
leaq -0x70(%rbp), %rdi
callq 0x20f0
leaq -0xf0(%rbp), %rdi
callq 0x20f0
leaq -0x1a0(%rbp), %rdi
callq 0x20f0
leaq -0x138(%rbp), %rdi
callq 0x20f0
leaq -0x118(%rbp), %rdi
callq 0x20f0
leaq -0x1c0(%rbp), %rdi
callq 0x20f0
leaq -0x220(%rbp), %rdi
callq 0x20f0
leaq -0x200(%rbp), %rdi
callq 0x20f0
leaq -0x1e0(%rbp), %rdi
callq 0x20f0
leaq -0xd0(%rbp), %rdi
callq 0x20f0
movq -0x148(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x300(%rbp), %rdi
callq 0x11f3e
leaq -0x2b0(%rbp), %rdi
callq 0x11f3e
leaq -0x240(%rbp), %rdi
callq 0x20f0
leaq -0x260(%rbp), %rdi
callq 0x20f0
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2c52c
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x20f0
jmp 0x2c542
jmp 0x2c53f
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x20f0
jmp 0x2c555
jmp 0x2c552
movq %rax, %rbx
leaq -0x180(%rbp), %rdi
callq 0x20f0
jmp 0x2c568
jmp 0x2c565
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x20f0
jmp 0x2c578
jmp 0x2c575
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x20f0
leaq -0x1a0(%rbp), %rdi
callq 0x20f0
leaq -0x138(%rbp), %rdi
callq 0x20f0
leaq -0x118(%rbp), %rdi
callq 0x20f0
leaq -0x1c0(%rbp), %rdi
callq 0x20f0
leaq -0x220(%rbp), %rdi
callq 0x20f0
leaq -0x200(%rbp), %rdi
callq 0x20f0
leaq -0x1e0(%rbp), %rdi
jmp 0x2c639
jmp 0x2c5d7
movq %rax, %rbx
jmp 0x2c584
jmp 0x2c5de
movq %rax, %rbx
jmp 0x2c590
jmp 0x2c5e5
movq %rax, %rbx
jmp 0x2c59c
jmp 0x2c5ec
movq %rax, %rbx
jmp 0x2c5a8
jmp 0x2c5f3
movq %rax, %rbx
jmp 0x2c5b4
jmp 0x2c5fa
movq %rax, %rbx
jmp 0x2c5c0
jmp 0x2c601
movq %rax, %rbx
jmp 0x2c5cc
jmp 0x2c6c2
jmp 0x2c6c2
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x20f0
jmp 0x2c624
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x20f0
jmp 0x2c635
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x20f0
jmp 0x2c6c5
jmp 0x2c6c2
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x20f0
jmp 0x2c659
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x20f0
jmp 0x2c66a
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x20f0
jmp 0x2c678
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x20f0
jmp 0x2c689
movq %rax, %rbx
leaq -0x118(%rbp), %rdi
callq 0x20f0
leaq -0x138(%rbp), %rdi
jmp 0x2c708
movq %rax, %rbx
jmp 0x2c695
jmp 0x2c738
movq %rax, %rbx
jmp 0x2c747
movq %rax, %rbx
jmp 0x2c753
movq %rax, %rbx
jmp 0x2c75f
jmp 0x2c6c2
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
jmp 0x2c708
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x20f0
jmp 0x2c6e2
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x20f0
jmp 0x2c6f3
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x20f0
jmp 0x2c701
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x20f0
jmp 0x2c73b
jmp 0x2c738
jmp 0x2c715
jmp 0x2c71a
movq %rax, %rbx
jmp 0x2c729
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x20f0
cmpq %r14, %r15
jmp 0x2c73b
jmp 0x2c738
jmp 0x2c738
jmp 0x2c738
jmp 0x2c738
jmp 0x2c738
movq %rax, %rbx
leaq -0x300(%rbp), %rdi
callq 0x11f3e
leaq -0x2b0(%rbp), %rdi
callq 0x11f3e
leaq -0x240(%rbp), %rdi
callq 0x20f0
leaq -0x260(%rbp), %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x2330