// File: /workspace/github_cpp_makefile_star2_O1/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, %r13
movq %rdi, %rbx
leaq -0x58(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x2eecc(%rip), %rdx     # 0x37131
leaq -0x68(%rbp), %rdi
movq %rdx, %rsi
callq 0x7200
movl 0x190(%rbx), %r14d
cmpl $0x2, %r14d
jl 0x8447
movq %r13, -0x90(%rbp)
decl %r14d
movl %r14d, %r12d
negl %r12d
cmovsl %r14d, %r12d
movl $0x1, %r13d
cmpl $0xa, %r12d
jb 0x82ec
movl $0x4, %r13d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r12d, %ecx
cmpl $0x63, %ecx
jbe 0x82e3
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x82e9
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x82ec
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r13d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x82b0
addl $-0x3, %r13d
jmp 0x82ec
addl $-0x2, %r13d
jmp 0x82ec
decl %r13d
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 0x2ee87(%rip), %rcx     # 0x371b3
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 0x836c
movq %rdx, -0xb0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xa0(%rbp)
jmp 0x8374
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 0x2ecb7(%rip), %rsi     # 0x37050
callq 0x7910
leaq -0x38(%rbp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x83c2
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x83ca
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 0x8405
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movq -0xb0(%rbp), %rdi
cmpq %r12, %rdi
movq -0x90(%rbp), %r13
je 0x8427
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x7510
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
leaq -0x58(%rbp), %r12
je 0x8447
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x7510
cmpl $0x3, %r15d
ja 0x85a3
movl %r15d, %eax
leaq 0x2eba5(%rip), %rcx     # 0x37000
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movq %r13, %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 0x849d
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movl $0xf8, %ecx
jmp 0x856c
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movq %r13, %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 0x84e0
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movb $0x1, %al
movl $0xf8, %ecx
jmp 0x856e
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movq %r13, %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 0x8525
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movb $0x1, %al
movl $0x138, %ecx            # imm = 0x138
jmp 0x856e
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movq %r13, %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 0x8567
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 %r12, %rdi
je 0x8591
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 0x2ea9f(%rip), %rsi     # 0x37056
movq %rax, %rdi
callq 0x78f0
movq 0x35a1a(%rip), %rsi     # 0x3dfe0
movq 0x35a03(%rip), %rdx     # 0x3dfd0
movq %r14, %rdi
callq 0x7820
movq %rax, %rbx
movq %r14, %rdi
callq 0x7390
jmp 0x864c
jmp 0x85e8
jmp 0x85e8
jmp 0x85e8
movq %rax, %rbx
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x864c
movq -0x38(%rbp), %rsi
jmp 0x863d
jmp 0x8649
jmp 0x8649
jmp 0x8649
jmp 0x8649
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
cmpq %r12, %rdi
je 0x8629
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x7510
jmp 0x8629
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x864c
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x7510
jmp 0x864c
jmp 0x8649
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x8665
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x7510
movq %rbx, %rdi
callq 0x7870
nop