// File: /workspace/github_cpp_makefile_star2_O3/Sooryakiran[P]dotV/src/verilog.cpp
// Function: Chip::declare(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
void Chip::declare(wire e, int type){
    /*------------------------------------------------------------------------------------------

    This function is used to populate the Chip ports when declared.
    example :   declare("my_input", CHIP_INPUTS);
                declare("my_output", CHIP_OUTPUT); 
                declare("my_output_reg", CHIP_OUTPUT_REG);
    

    Param : c (wire), a port/wire name.
    Param : type (int), port type, 0 for CHIP_INPUTS, 1 for CHIP_OUTPUTS, 2 for CHIP_INPUT_REG 
            and 3 for CHIP_OUTPUT_REG.
    Returns : None
    ------------------------------------------------------------------------------------------*/
   
    string pre = "";
    if(this->n_bits > 1){
        pre = "[" + to_string(this->n_bits -1) + ": 0] ";
    } 
    
    if(type == CHIP_INPUTS){
        this->input_names.push_back(pre + e);
        this->is_input_reg.push_back(false);
    }
    else if(type == CHIP_OUTPUTS){
        this->output_names.push_back(pre + e);
        this->is_output_reg.push_back(false);
    }
    else if(type == CHIP_INPUTS_REG){
        this->input_names.push_back(pre + e);
        this->is_input_reg.push_back(true);
    }
    else if(type == CHIP_OUTPUTS_REG){
        this->output_names.push_back(pre + e);
        this->is_output_reg.push_back(true);
    }
    else{
        throw invalid_argument( "Invalid type for port." );
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %edx, %r15d
movq %rsi, %r12
movq %rdi, %rbx
leaq -0x58(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x2e05d(%rip), %rdx     # 0x36131
leaq -0x68(%rbp), %rdi
movq %rdx, %rsi
callq 0x7200
movl 0x190(%rbx), %eax
cmpl $0x2, %eax
jl 0x82ad
movq %r12, -0x90(%rbp)
leal -0x1(%rax), %r12d
movl $0x1, %r13d
cmpl $0xb, %eax
jb 0x814f
movl $0x4, %r13d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r12d, %ecx
cmpl $0x63, %ecx
jbe 0x8146
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x814c
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x814f
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r13d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x8113
addl $-0x3, %r13d
jmp 0x814f
addl $-0x2, %r13d
jmp 0x814f
decl %r13d
movl %r12d, %r14d
shrl $0x1f, %r14d
leal (%r14,%r13), %esi
leaq -0x78(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x88(%rbp), %rdi
movl $0x2d, %edx
callq 0x75e0
movl %r14d, %edi
leaq -0x88(%rbp), %r14
addq (%r14), %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0x76b0
leaq 0x2e021(%rip), %rcx     # 0x361b3
movl $0x1, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x75b0
leaq -0xa0(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x81d2
movq %rdx, -0xb0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xa0(%rbp)
jmp 0x81da
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq -0xb0(%rbp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x2de51(%rip), %rsi     # 0x36050
callq 0x7910
leaq -0x38(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x8228
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x8230
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
leaq -0x48(%rbp), %r14
movq %rdx, 0x8(%r14)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x68(%rbp), %rdi
movq %r14, %rsi
callq 0x7610
movq (%r14), %rdi
cmpq %r13, %rdi
je 0x826b
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movq -0xb0(%rbp), %rdi
cmpq %r12, %rdi
je 0x8286
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x7510
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
leaq -0x58(%rbp), %r14
movq -0x90(%rbp), %r12
je 0x82ad
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x7510
cmpl $0x3, %r15d
ja 0x8409
movl %r15d, %eax
leaq 0x2dd3f(%rip), %rcx     # 0x36000
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movq %r12, %rdx
callq 0x7930
leaq 0xe0(%rbx), %rdi
leaq -0x48(%rbp), %rsi
callq 0x71b0
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8303
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movl $0xf8, %ecx
jmp 0x83d2
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movq %r12, %rdx
callq 0x7930
leaq 0xe0(%rbx), %rdi
leaq -0x48(%rbp), %rsi
callq 0x71b0
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8346
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movb $0x1, %al
movl $0xf8, %ecx
jmp 0x83d4
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movq %r12, %rdx
callq 0x7930
leaq 0x120(%rbx), %rdi
leaq -0x48(%rbp), %rsi
callq 0x71b0
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x838b
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movb $0x1, %al
movl $0x138, %ecx            # imm = 0x138
jmp 0x83d4
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movq %r12, %rdx
callq 0x7930
leaq 0x120(%rbx), %rdi
leaq -0x48(%rbp), %rsi
callq 0x71b0
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x83cd
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movl $0x138, %ecx            # imm = 0x138
xorl %eax, %eax
addq %rcx, %rbx
movzbl %al, %esi
movq %rbx, %rdi
callq 0x7620
movq -0x68(%rbp), %rdi
cmpq %r14, %rdi
je 0x83f7
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x7510
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x7290
movq %rax, %r14
leaq 0x2dc39(%rip), %rsi     # 0x36056
movq %rax, %rdi
callq 0x78f0
movq 0x34bb4(%rip), %rsi     # 0x3cfe0
movq 0x34b9d(%rip), %rdx     # 0x3cfd0
movq %r14, %rdi
callq 0x7820
movq %rax, %rbx
movq %r14, %rdi
callq 0x7390
jmp 0x84b2
jmp 0x844e
jmp 0x844e
jmp 0x844e
movq %rax, %rbx
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x84b2
movq -0x38(%rbp), %rsi
jmp 0x84a3
jmp 0x84af
jmp 0x84af
jmp 0x84af
jmp 0x84af
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
cmpq %r12, %rdi
je 0x848f
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x7510
jmp 0x848f
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x84b2
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x7510
jmp 0x84b2
jmp 0x84af
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x84cb
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x7510
movq %rbx, %rdi
callq 0x7870
nop