// 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, 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, %r12d
movl %edx, %r15d
movq %rsi, %r13
movq %rdi, %rbx
leaq -0x58(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x2ea94(%rip), %rdx     # 0x37131
leaq -0x68(%rbp), %rdi
movq %rdx, %rsi
callq 0x7200
cmpl $0x2, %r12d
jl 0x8879
movq %r13, -0x90(%rbp)
decl %r12d
movl %r12d, %r13d
negl %r13d
cmovsl %r12d, %r13d
movl $0x1, %r14d
cmpl $0xa, %r13d
jb 0x871d
movl $0x4, %r14d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r13d, %ecx
cmpl $0x63, %ecx
jbe 0x8714
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x871a
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x871d
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r14d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x86e1
addl $-0x3, %r14d
jmp 0x871d
addl $-0x2, %r14d
jmp 0x871d
decl %r14d
shrl $0x1f, %r12d
leal (%r14,%r12), %esi
leaq -0x78(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x88(%rbp), %rdi
movl $0x2d, %edx
callq 0x75e0
movl %r12d, %edi
leaq -0x88(%rbp), %r12
addq (%r12), %rdi
movl %r14d, %esi
movl %r13d, %edx
callq 0x76b0
leaq 0x2ea55(%rip), %rcx     # 0x371b3
movl $0x1, %r8d
movq %r12, %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 0x879e
movq %rdx, -0xb0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xa0(%rbp)
jmp 0x87a6
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 0x2e885(%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 0x87f4
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x87fc
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 0x8837
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movq -0xb0(%rbp), %rdi
cmpq %r12, %rdi
leaq -0x58(%rbp), %r14
movq -0x90(%rbp), %r13
je 0x885d
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x7510
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x8879
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x7510
cmpl $0x3, %r15d
ja 0x89d5
movl %r15d, %eax
leaq 0x2e783(%rip), %rcx     # 0x37010
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 0x88cf
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movl $0xf8, %ecx
jmp 0x899e
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 0x8912
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movb $0x1, %al
movl $0xf8, %ecx
jmp 0x89a0
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 0x8957
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x7510
movb $0x1, %al
movl $0x138, %ecx            # imm = 0x138
jmp 0x89a0
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 0x8999
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 0x89c3
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 0x2e66d(%rip), %rsi     # 0x37056
movq %rax, %rdi
callq 0x78f0
movq 0x355e8(%rip), %rsi     # 0x3dfe0
movq 0x355d1(%rip), %rdx     # 0x3dfd0
movq %r14, %rdi
callq 0x7820
movq %rax, %rbx
movq %r14, %rdi
callq 0x7390
jmp 0x8a7e
jmp 0x8a1a
jmp 0x8a1a
jmp 0x8a1a
movq %rax, %rbx
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8a7e
movq -0x38(%rbp), %rsi
jmp 0x8a6f
jmp 0x8a7b
jmp 0x8a7b
jmp 0x8a7b
jmp 0x8a7b
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
cmpq %r12, %rdi
je 0x8a5b
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x7510
jmp 0x8a5b
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x8a7e
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x7510
jmp 0x8a7e
jmp 0x8a7b
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x8a97
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x7510
movq %rbx, %rdi
callq 0x7870
nop