// File: Sooryakiran[P]dotV/src/main.cpp
// Function: main
int main(int argc, char * argv[]){
    /*------------------------------------------------------------------------------------------
    Input Validation
    ------------------------------------------------------------------------------------------*/
    if(argc != 5){
        invalid_args(argv[0]);
        return 0;
    }

    if(strcmp(argv[1], "-n") || strcmp(argv[3], "-k")){
        invalid_args(argv[0]);
        return 0;
    }

    string n_str = argv[2];
    string k_str = argv[4];
    int n, k;
    try{
        n = stoi(n_str);
        k = stoi(k_str);
    }
    catch(exception e){
        invalid_args(argv[0]);
        return 0;
    }

    /*------------------------------------------------------------------------------------------
    Create instances of the chips.
    ------------------------------------------------------------------------------------------*/
    WALLACE_TREE_MULTIPLIER_PIPELINED wtm("Sample Adder",
                                         {"input_1", "input_2", "clk"},
                                         "outputs",
                                         n, k);


    /*------------------------------------------------------------------------------------------
    Generate Verilog and write it to file. File save location ./generated_codes/
    ------------------------------------------------------------------------------------------*/
    generate_file("generated_codes/wtm_" + to_string(n) + "_bits_k_" + to_string(k) + ".v", wtm.generate_verilog());
   
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4a0, %rsp            # imm = 0x4A0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x5, -0x8(%rbp)
je 0x5737
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x56a0
movl $0x0, -0x4(%rbp)
jmp 0x5f48
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x2958(%rip), %rsi      # 0x809e
callq 0x5290
cmpl $0x0, %eax
jne 0x5769
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x2942(%rip), %rsi      # 0x80a1
callq 0x5290
cmpl $0x0, %eax
je 0x5781
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x56a0
movl $0x0, -0x4(%rbp)
jmp 0x5f48
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x3f8(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x3f0(%rbp)
callq 0x5330
movq -0x3f8(%rbp), %rsi
movq -0x3f0(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x5f70
jmp 0x57b9
leaq -0x31(%rbp), %rdi
callq 0x5220
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x408(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0x400(%rbp)
callq 0x5330
movq -0x408(%rbp), %rsi
movq -0x400(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x5f70
jmp 0x57fa
leaq -0x69(%rbp), %rdi
callq 0x5220
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
movl $0xa, %edx
callq 0x6020
movl %eax, -0x40c(%rbp)
jmp 0x581d
movl -0x40c(%rbp), %eax
movl %eax, -0x70(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x68(%rbp), %rdi
movl $0xa, %edx
callq 0x6020
movl %eax, -0x410(%rbp)
jmp 0x5840
movl -0x410(%rbp), %eax
movl %eax, -0x74(%rbp)
jmp 0x592c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x5220
jmp 0x5f54
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x5220
jmp 0x5f3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x5f34
movq -0x40(%rbp), %rdi
movq %rdi, -0x418(%rbp)
callq 0x5270
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0x6060
movq -0x418(%rbp), %rdi
callq 0x50a0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x56a0
jmp 0x58d4
movl $0x0, -0x4(%rbp)
movl $0x1, -0x84(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x5370
callq 0x5300
jmp 0x5911
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x5370
callq 0x5300
jmp 0x5927
jmp 0x5f20
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5f34
jmp 0x5f34
leaq -0x241(%rbp), %rdi
movq %rdi, -0x420(%rbp)
callq 0x5330
movq -0x420(%rbp), %rdx
leaq 0x2757(%rip), %rsi      # 0x80a4
leaq -0x240(%rbp), %rdi
callq 0x5f70
jmp 0x595b
movb $0x1, -0x2dc(%rbp)
leaq -0x2d0(%rbp), %rax
movq %rax, -0x430(%rbp)
movq %rax, -0x2d8(%rbp)
leaq -0x2d9(%rbp), %rdi
movq %rdi, -0x428(%rbp)
callq 0x5330
movq -0x430(%rbp), %rdi
movq -0x428(%rbp), %rdx
leaq 0x2712(%rip), %rsi      # 0x80b1
callq 0x5f70
jmp 0x59a6
leaq -0x2b0(%rbp), %rax
movq %rax, -0x440(%rbp)
movq %rax, -0x2d8(%rbp)
leaq -0x2da(%rbp), %rdi
movq %rdi, -0x438(%rbp)
callq 0x5330
movq -0x440(%rbp), %rdi
movq -0x438(%rbp), %rdx
leaq 0x26d6(%rip), %rsi      # 0x80b9
callq 0x5f70
jmp 0x59ea
leaq -0x290(%rbp), %rax
movq %rax, -0x450(%rbp)
movq %rax, -0x2d8(%rbp)
leaq -0x2db(%rbp), %rdi
movq %rdi, -0x448(%rbp)
callq 0x5330
movq -0x450(%rbp), %rdi
movq -0x448(%rbp), %rdx
leaq 0x269a(%rip), %rsi      # 0x80c1
callq 0x5f70
jmp 0x5a2e
movb $0x0, -0x2dc(%rbp)
leaq -0x2d0(%rbp), %rax
movq %rax, -0x270(%rbp)
movq $0x3, -0x268(%rbp)
leaq -0x2dd(%rbp), %rdi
movq %rdi, -0x458(%rbp)
callq 0x6090
movq -0x458(%rbp), %rcx
movq -0x270(%rbp), %rsi
movq -0x268(%rbp), %rdx
leaq -0x260(%rbp), %rdi
callq 0x60b0
jmp 0x5a84
leaq -0x301(%rbp), %rdi
movq %rdi, -0x460(%rbp)
callq 0x5330
movq -0x460(%rbp), %rdx
leaq 0x2620(%rip), %rsi      # 0x80c5
leaq -0x300(%rbp), %rdi
callq 0x5f70
jmp 0x5ab3
movl -0x70(%rbp), %r8d
movl -0x74(%rbp), %r9d
leaq -0x220(%rbp), %rdi
leaq -0x240(%rbp), %rsi
leaq -0x260(%rbp), %rdx
leaq -0x300(%rbp), %rcx
callq 0x51c0
jmp 0x5ade
leaq -0x300(%rbp), %rdi
callq 0x5120
leaq -0x301(%rbp), %rdi
callq 0x5220
leaq -0x260(%rbp), %rdi
callq 0x6130
leaq -0x2dd(%rbp), %rdi
callq 0x6190
leaq -0x2d0(%rbp), %rax
movq %rax, -0x470(%rbp)
addq $0x60, %rax
movq %rax, -0x468(%rbp)
movq -0x468(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x478(%rbp)
callq 0x5120
movq -0x470(%rbp), %rcx
movq -0x478(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x468(%rbp)
jne 0x5b27
leaq -0x2db(%rbp), %rdi
callq 0x5220
leaq -0x2da(%rbp), %rdi
callq 0x5220
leaq -0x2d9(%rbp), %rdi
callq 0x5220
leaq -0x240(%rbp), %rdi
callq 0x5120
leaq -0x241(%rbp), %rdi
callq 0x5220
movl -0x70(%rbp), %esi
leaq -0x3a8(%rbp), %rdi
callq 0x6320
jmp 0x5ba5
leaq 0x2521(%rip), %rsi      # 0x80cd
leaq -0x388(%rbp), %rdi
leaq -0x3a8(%rbp), %rdx
callq 0x62d0
jmp 0x5bc1
leaq 0x251a(%rip), %rdx      # 0x80e2
leaq -0x368(%rbp), %rdi
leaq -0x388(%rbp), %rsi
callq 0x61b0
jmp 0x5bdd
movl -0x74(%rbp), %esi
leaq -0x3c8(%rbp), %rdi
callq 0x6320
jmp 0x5bee
leaq -0x348(%rbp), %rdi
leaq -0x368(%rbp), %rsi
leaq -0x3c8(%rbp), %rdx
callq 0x6200
jmp 0x5c0a
leaq 0x24da(%rip), %rdx      # 0x80eb
leaq -0x328(%rbp), %rdi
leaq -0x348(%rbp), %rsi
callq 0x61b0
jmp 0x5c26
leaq -0x3e8(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x5060
jmp 0x5c3b
leaq -0x328(%rbp), %rdi
leaq -0x3e8(%rbp), %rsi
callq 0x54e0
jmp 0x5c50
leaq -0x3e8(%rbp), %rdi
callq 0x5120
leaq -0x328(%rbp), %rdi
callq 0x5120
leaq -0x348(%rbp), %rdi
callq 0x5120
leaq -0x3c8(%rbp), %rdi
callq 0x5120
leaq -0x368(%rbp), %rdi
callq 0x5120
leaq -0x388(%rbp), %rdi
callq 0x5120
leaq -0x3a8(%rbp), %rdi
callq 0x5120
movl $0x1, -0x4(%rbp)
movl $0x1, -0x84(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x6440
jmp 0x5f20
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5e36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5dc6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5dba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5dae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5d56
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5d3e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x300(%rbp), %rdi
callq 0x5120
leaq -0x301(%rbp), %rdi
callq 0x5220
leaq -0x260(%rbp), %rdi
callq 0x6130
leaq -0x2dd(%rbp), %rdi
callq 0x6190
leaq -0x2d0(%rbp), %rax
movq %rax, -0x488(%rbp)
addq $0x60, %rax
movq %rax, -0x480(%rbp)
movq -0x480(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x490(%rbp)
callq 0x5120
movq -0x488(%rbp), %rcx
movq -0x490(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x480(%rbp)
jne 0x5d7b
jmp 0x5dae
leaq -0x2db(%rbp), %rdi
callq 0x5220
leaq -0x2da(%rbp), %rdi
callq 0x5220
leaq -0x2d9(%rbp), %rdi
callq 0x5220
testb $0x1, -0x2dc(%rbp)
jne 0x5ddd
jmp 0x5e2a
movq -0x2d8(%rbp), %rax
leaq -0x2d0(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x498(%rbp)
je 0x5e28
movq -0x498(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x4a0(%rbp)
callq 0x5120
movq -0x4a0(%rbp), %rax
leaq -0x2d0(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x498(%rbp)
jne 0x5df7
jmp 0x5e2a
leaq -0x240(%rbp), %rdi
callq 0x5120
leaq -0x241(%rbp), %rdi
callq 0x5220
jmp 0x5f34
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5f12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5f06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5efa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5eee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5ee2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5ed6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5eca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x3e8(%rbp), %rdi
callq 0x5120
leaq -0x328(%rbp), %rdi
callq 0x5120
leaq -0x348(%rbp), %rdi
callq 0x5120
leaq -0x3c8(%rbp), %rdi
callq 0x5120
leaq -0x368(%rbp), %rdi
callq 0x5120
leaq -0x388(%rbp), %rdi
callq 0x5120
leaq -0x3a8(%rbp), %rdi
callq 0x5120
leaq -0x220(%rbp), %rdi
callq 0x6440
jmp 0x5f34
leaq -0x68(%rbp), %rdi
callq 0x5120
leaq -0x30(%rbp), %rdi
callq 0x5120
jmp 0x5f48
leaq -0x68(%rbp), %rdi
callq 0x5120
leaq -0x30(%rbp), %rdi
callq 0x5120
jmp 0x5f54
movl -0x4(%rbp), %eax
addq $0x4a0, %rsp            # imm = 0x4A0
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x5320
movq %rax, %rdi
callq 0x6080
nopw %cs:(%rax,%rax)
nop