// File: /workspace/github_cpp_makefile_star2_O2/temelmertcan[P]multgen/src/multgen.cpp
// Function: create_adder(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, 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 create_adder (string final_stage_adder,
                  bool carryin, int adder_size,
                  queue<string>& verilog){

  if (final_stage_adder.compare ("RP") == 0)
    create_rp_adder (adder_size, carryin, verilog);
  else if (final_stage_adder.compare ("HC") == 0)
    create_hc_adder (adder_size, carryin, verilog);
  else if (final_stage_adder.compare ("LF") == 0)
    create_lf_adder (adder_size, carryin, verilog);
  else if (final_stage_adder.compare ("KS") == 0)
    create_ks_adder (adder_size, carryin, verilog);
  else if (final_stage_adder.compare ("BK") == 0)
    create_bk_adder (adder_size, carryin, verilog);
   else if (final_stage_adder.compare ("JSkCond") == 0)
     create_JSkCond_adder (adder_size, carryin, verilog);
  else{
    cout << "Bad Final Stage Adder Selection!" << endl;
    return 1;
  }

  string module_name = final_stage_adder+"_"+to_string(adder_size)+ (carryin?"_carry":"");
  
  verilog.push ("module "+module_name+"_spec (");
  verilog.push("indent");
  verilog.push("indent");
  if(carryin)
    verilog.push ("input logic carryin,");
  verilog.push ("input logic [" + to_string(adder_size-1) + ":0] IN1,");
  verilog.push ("input logic [" + to_string(adder_size-1) +  ":0] IN2,");
  verilog.push ("output logic adder_correct,");
  verilog.push ("output logic ["  + to_string(adder_size) +  ":0] spec_res);");
  verilog.push("outdent");
  verilog.push("");
  verilog.push((string)"assign spec_res = IN1 + IN2" + (string)(carryin?" + carryin;":";"));
  verilog.push("wire ["  + to_string(adder_size) +  ":0] adder_res;");
  verilog.push(module_name + " adder("+(carryin?"carryin, ":"")+"IN1, IN2, adder_res);");
  verilog.push("assign adder_correct = ((spec_res == adder_res) ? 1 : 0);");
  verilog.push("");
  verilog.push("outdent");
  verilog.push ("endmodule");
  verilog.push("");

  verilog.push ("\n");

  cout << endl;
  cout << "Adder Module (" << module_name << ") is created." << endl;
  cout << "   Inputs: IN1[" << adder_size-1 << ":0], IN2[" << adder_size-1 << ":0]" << (carryin?", carryin":"")<< endl;
  cout << "   Output: result[" <<adder_size << ":0]" << endl;
  cout << "   Function: result=IN1 + IN2" << (carryin?" + carryin":"") << endl;

  return 0;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rcx, %r15
movl %edx, %r14d
movl %esi, %ebx
movq %rdi, %r12
leaq 0x2ca4a(%rip), %rsi     # 0x3131e
callq 0x2090
movzbl %bl, %r13d
testl %eax, %eax
je 0x4967
leaq 0x2cded(%rip), %rsi     # 0x316d9
movq %r12, %rdi
callq 0x2090
testl %eax, %eax
je 0x4977
leaq 0x2cddd(%rip), %rsi     # 0x316dc
movq %r12, %rdi
callq 0x2090
testl %eax, %eax
je 0x4987
leaq 0x2cdcd(%rip), %rsi     # 0x316df
movq %r12, %rdi
callq 0x2090
testl %eax, %eax
je 0x4997
leaq 0x2cdbd(%rip), %rsi     # 0x316e2
movq %r12, %rdi
callq 0x2090
testl %eax, %eax
je 0x49a7
leaq 0x2cdad(%rip), %rsi     # 0x316e5
movq %r12, %rdi
callq 0x2090
testl %eax, %eax
je 0x49b7
movq 0x3a67d(%rip), %rdi     # 0x3efc8
leaq 0x2d32e(%rip), %rsi     # 0x31c80
callq 0x21c0
movq %rax, %rdi
callq 0x2110
pushq $0x1
popq %rax
jmp 0x501d
movl %r14d, %edi
movl %r13d, %esi
movq %r15, %rdx
callq 0x13258
jmp 0x49c5
movl %r14d, %edi
movl %r13d, %esi
movq %r15, %rdx
callq 0x14b2e
jmp 0x49c5
movl %r14d, %edi
movl %r13d, %esi
movq %r15, %rdx
callq 0x1602e
jmp 0x49c5
movl %r14d, %edi
movl %r13d, %esi
movq %r15, %rdx
callq 0x16b81
jmp 0x49c5
movl %r14d, %edi
movl %r13d, %esi
movq %r15, %rdx
callq 0x17653
jmp 0x49c5
movl %r14d, %edi
movl %r13d, %esi
movq %r15, %rdx
callq 0x18907
leaq 0x2e77a(%rip), %rdx     # 0x33146
leaq -0x68(%rbp), %rdi
movq %r12, %rsi
callq 0x11c3b
leaq -0x90(%rbp), %rdi
movl %r14d, %esi
callq 0x11c73
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x11bca
leaq 0x2d29f(%rip), %rax     # 0x31ca1
leaq 0x2ebc8(%rip), %rdx     # 0x335d1
testb %bl, %bl
cmovneq %rax, %rdx
leaq -0xb0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x11ba1
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
callq 0x20f0
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq 0x2d264(%rip), %rsi     # 0x31ca8
leaq -0x68(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
callq 0x11cd3
leaq 0x2d255(%rip), %rdx     # 0x31cb0
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x11ba1
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq 0x2d22b(%rip), %rsi     # 0x31cb8
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x20b0
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq 0x2d202(%rip), %rsi     # 0x31cb8
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x20b0
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
testb %bl, %bl
je 0x4b05
leaq 0x2d1dc(%rip), %rsi     # 0x31cbf
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x20b0
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leal -0x1(%r14), %r12d
leaq -0x90(%rbp), %rdi
movl %r12d, %esi
callq 0x11c73
leaq 0x2d1b5(%rip), %rsi     # 0x31cd4
leaq -0x68(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0x11d49
leaq 0x2d1ac(%rip), %rdx     # 0x31ce2
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x11ba1
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
movl %r12d, %esi
callq 0x11c73
leaq 0x2d151(%rip), %rsi     # 0x31cd4
leaq -0x68(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0x11d49
leaq 0x2d151(%rip), %rdx     # 0x31ceb
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x11ba1
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
callq 0x20f0
leaq 0x2d11c(%rip), %rsi     # 0x31cf4
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x20b0
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
movl %r14d, %esi
callq 0x11c73
leaq 0x2d100(%rip), %rsi     # 0x31d10
leaq -0x68(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0x11d49
leaq 0x2d0f8(%rip), %rdx     # 0x31d1f
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x11ba1
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
callq 0x20f0
leaq 0x2d0c9(%rip), %rsi     # 0x31d2e
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x20b0
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq 0x2e943(%rip), %r13     # 0x335d1
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
movq %r13, %rsi
callq 0x20b0
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq 0x2d07c(%rip), %rsi     # 0x31d36
leaq -0x68(%rbp), %rdi
leaq -0x6a(%rbp), %rdx
callq 0x20b0
leaq 0x2d084(%rip), %rax     # 0x31d52
leaq 0x2ea0c(%rip), %rsi     # 0x336e1
testb %bl, %bl
cmovneq %rax, %rsi
leaq -0x90(%rbp), %rdi
leaq -0x69(%rbp), %rdx
callq 0x20b0
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x11bca
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
callq 0x20f0
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
movl %r14d, %esi
callq 0x11c73
leaq 0x2d01f(%rip), %rsi     # 0x31d5e
leaq -0x68(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0x11d49
leaq 0x2d00f(%rip), %rdx     # 0x31d65
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x11ba1
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
callq 0x20f0
leaq 0x2cfe0(%rip), %rdx     # 0x31d74
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x11c3b
leaq 0x2cfce(%rip), %rax     # 0x31d7c
testb %bl, %bl
cmovneq %rax, %r13
leaq -0x68(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movq %r13, %rdx
callq 0x11ba1
leaq 0x2cfb8(%rip), %rdx     # 0x31d86
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x11ba1
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq -0x90(%rbp), %rdi
callq 0x20f0
leaq 0x2cf90(%rip), %rsi     # 0x31d9c
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x20b0
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq 0x2e79c(%rip), %rsi     # 0x335d1
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x20b0
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq 0x2ced0(%rip), %rsi     # 0x31d2e
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x20b0
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq 0x2cf4f(%rip), %rsi     # 0x31dd6
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x20b0
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq 0x2e721(%rip), %r13     # 0x335d1
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
movq %r13, %rsi
callq 0x20b0
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
leaq 0x2b99b(%rip), %rsi     # 0x30877
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x20b0
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x120e4
leaq -0x48(%rbp), %rdi
callq 0x20f0
movq 0x3a0c3(%rip), %rdi     # 0x3efc8
callq 0x2110
movq 0x3a0b7(%rip), %rdi     # 0x3efc8
leaq 0x2cec8(%rip), %rsi     # 0x31de0
callq 0x21c0
leaq -0xb0(%rbp), %rsi
movq %rax, %rdi
callq 0x2190
leaq 0x2cebc(%rip), %rsi     # 0x31def
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
callq 0x2110
movq 0x3a07e(%rip), %rdi     # 0x3efc8
leaq 0x2ceac(%rip), %rsi     # 0x31dfd
callq 0x21c0
movq %rax, %rdi
movl %r12d, %esi
callq 0x2320
leaq 0x2cea5(%rip), %rsi     # 0x31e0d
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
movl %r12d, %esi
callq 0x2320
leaq 0x2ce95(%rip), %rsi     # 0x31e17
movq %rax, %rdi
callq 0x21c0
leaq 0x2ce8a(%rip), %rsi     # 0x31e1b
testb %bl, %bl
cmoveq %r13, %rsi
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
callq 0x2110
movq 0x3a01a(%rip), %rdi     # 0x3efc8
leaq 0x2ce70(%rip), %rsi     # 0x31e25
callq 0x21c0
movq %rax, %rdi
movl %r14d, %esi
callq 0x2320
leaq 0x2ce4b(%rip), %rsi     # 0x31e17
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
callq 0x2110
movq 0x39fe5(%rip), %rdi     # 0x3efc8
leaq 0x2ce4e(%rip), %rsi     # 0x31e38
callq 0x21c0
leaq 0x2ce60(%rip), %rcx     # 0x31e56
testb %bl, %bl
cmovneq %rcx, %r13
movq %rax, %rdi
movq %r13, %rsi
callq 0x21c0
movq %rax, %rdi
callq 0x2110
leaq -0xb0(%rbp), %rdi
callq 0x20f0
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5102
jmp 0x5153
jmp 0x5102
jmp 0x5153
jmp 0x5102
jmp 0x5153
jmp 0x5102
jmp 0x5153
jmp 0x5102
jmp 0x5153
jmp 0x5102
jmp 0x5153
jmp 0x5102
jmp 0x5153
jmp 0x50d4
jmp 0x50e2
jmp 0x50f0
jmp 0x5153
jmp 0x50d4
jmp 0x50e2
jmp 0x50f0
jmp 0x5153
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x20f0
jmp 0x509c
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
jmp 0x5114
jmp 0x511b
jmp 0x5153
jmp 0x5102
jmp 0x5153
jmp 0x5102
jmp 0x5153
jmp 0x50d4
jmp 0x50e2
jmp 0x50f0
jmp 0x5153
jmp 0x5102
jmp 0x5153
jmp 0x50d4
jmp 0x50e2
jmp 0x50f0
jmp 0x5153
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x20f0
jmp 0x50e5
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x20f0
jmp 0x50f3
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
jmp 0x5122
jmp 0x5153
jmp 0x5102
jmp 0x5153
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
jmp 0x5122
jmp 0x5153
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x20f0
jmp 0x511e
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x20f0
jmp 0x5156
jmp 0x5153
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x20f0
jmp 0x513c
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x20f0
jmp 0x514d
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
jmp 0x515d
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x2330