// 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, int)
void Chip::declare(wire e, int type, int width){
    /*------------------------------------------------------------------------------------------

    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.
    Param : width (int), Bit width of port. If no width is specified, it is assumed to be of the
            parent Chip's width.
    Returns : None
    ------------------------------------------------------------------------------------------*/ 
    
    string pre = "";
    if(width>1){
        pre = "[" + to_string(width -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 %ecx, %r14d
movl %edx, %r15d
movq %rsi, %r13
movq %rdi, %rbx
leaq -0x58(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x2dc2d(%rip), %rdx     # 0x36131
leaq -0x68(%rbp), %rdi
movq %rdx, %rsi
callq 0x7200
cmpl $0x2, %r14d
jl 0x86d9
movq %r13, -0x90(%rbp)
leal -0x1(%r14), %r12d
movl $0x1, %r13d
cmpl $0xb, %r14d
jb 0x857b
movl $0x4, %r13d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r12d, %ecx
cmpl $0x63, %ecx
jbe 0x8572
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x8578
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x857b
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r13d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x853f
addl $-0x3, %r13d
jmp 0x857b
addl $-0x2, %r13d
jmp 0x857b
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 0x2dbf5(%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 0x85fe
movq %rdx, -0xb0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xa0(%rbp)
jmp 0x8606
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 0x2da25(%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 0x8654
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x865c
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 0x8697
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movq -0xb0(%rbp), %rdi
cmpq %r12, %rdi
movq -0x90(%rbp), %r13
je 0x86b9
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x7510
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
leaq -0x58(%rbp), %r12
je 0x86d9
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x7510
cmpl $0x3, %r15d
ja 0x8835
movl %r15d, %eax
leaq 0x2d923(%rip), %rcx     # 0x36010
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 0x872f
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movl $0xf8, %ecx
jmp 0x87fe
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 0x8772
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movb $0x1, %al
movl $0xf8, %ecx
jmp 0x8800
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 0x87b7
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movb $0x1, %al
movl $0x138, %ecx            # imm = 0x138
jmp 0x8800
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 0x87f9
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 0x8823
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 0x2d80d(%rip), %rsi     # 0x36056
movq %rax, %rdi
callq 0x78f0
movq 0x34788(%rip), %rsi     # 0x3cfe0
movq 0x34771(%rip), %rdx     # 0x3cfd0
movq %r14, %rdi
callq 0x7820
movq %rax, %rbx
movq %r14, %rdi
callq 0x7390
jmp 0x88de
jmp 0x887a
jmp 0x887a
jmp 0x887a
movq %rax, %rbx
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x88de
movq -0x38(%rbp), %rsi
jmp 0x88cf
jmp 0x88db
jmp 0x88db
jmp 0x88db
jmp 0x88db
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
cmpq %r12, %rdi
je 0x88bb
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x7510
jmp 0x88bb
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x88de
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x7510
jmp 0x88de
jmp 0x88db
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x88f7
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x7510
movq %rbx, %rdi
callq 0x7870
nop