// File: /workspace/github_c_makefile_star2_O2/Gaurang18[P]Compiler-Project-BITS-Pilani/./symboltable.c
// Function: populateFunctionDefinitions
void populateFunctionDefinitions(FILE *fp, parsetree head, char* functionname){

    if(head==NULL)
        return;

    populateFunctionDefinitions(fp, head->child, functionname);

    


    if((strcmp(head->Lex->tk->value, functionname)==0) && head->parent->value == 7){
        parsetree iplist = head->right;
        char inputtype[1000] = {'\0'};
        char outputtype[1000] = {'\0'};
        switch(iplist->child->right->rule){
            {
                case 18: strcat(inputtype, "INTEGER");
                    break;
                case 19:strcat(inputtype, "REAL");
                    break;
                case 20:strcat(inputtype, "BOOLEAN");
                    break;
                case 21: 
                    //int range = head->parent->right->child->right->child->right->right->Lex->tk->value - head->parent->right->child->right->child->Lex->tk->value;
                    //char value[3]; 
                    //value[0] = range;
                    //value[1] = '\0';
                    {parsetree range = iplist->child->right->child->right;

                   int r1 = atoi(range->child->Lex->tk->value);
                    int r2 = atoi(range->child->right->right->Lex->tk->value);
                    int r = r2 -r1 + 1;
                    char size[3];
                    //sprintf(size,"%d",r);

                    // printf("range %d\n", r);

                    char type[100] = {'\0'};



                    switch(range->right->rule){
                        case 22: strcat(inputtype, "ARRAY(INTEGER, ");
                                 strcat(inputtype, size);
                                 strcat(inputtype, ")");
                                 
                                break;
                        case 23:strcat(inputtype, "ARRAY(REAL, ");
                                 strcat(inputtype, size);
                                 strcat(inputtype, ")");
                                 
                                break;
                        case 24:strcat(inputtype, "ARRAY(BOOLEAN, ");
                                 strcat(inputtype, size);
                                 strcat(inputtype, ")");
                                 
                                break;
                    }}
                    break;
            }
        }

       parsetree iplistprime = iplist->child->right->right;

        while(iplistprime->rule!=11){

            switch(iplistprime->child->right->rule){
            {
                case 18: strcat(inputtype, "; INTEGER");
                    break;
                case 19:strcat(inputtype, "; REAL");
                    break;
                case 20:strcat(inputtype, "; BOOLEAN");
                    break;
                case 21: 
                    //int range = head->parent->right->child->right->child->right->right->Lex->tk->value - head->parent->right->child->right->child->Lex->tk->value;
                    //char value[3]; 
                    //value[0] = range;
                    //value[1] = '\0';
                    {parsetree range = iplistprime->child->right->child->right;

                   int r1 = atoi(range->child->Lex->tk->value);
                    int r2 = atoi(range->child->right->right->Lex->tk->value);
                    int r = r2 -r1 + 1;
                    char size[3];
                    //sprintf(size,"%d",r);

                    // printf("range %d\n", r);

                    char type[100] = {'\0'};



                    switch(range->right->rule){
                        case 22: strcat(inputtype, "; ARRAY(INTEGER, ");
                                 strcat(inputtype, size);
                                 strcat(inputtype, ")");
                                 
                                break;
                        case 23:strcat(inputtype, "; ARRAY(REAL, ");
                                 strcat(inputtype, size);
                                 strcat(inputtype, ")");
                                 
                                break;
                        case 24:strcat(inputtype, "; ARRAY(BOOLEAN, ");
                                 strcat(inputtype, size);
                                 strcat(inputtype, ")");
                                 
                                break;
                    }}
                    break;
            }
        }

        iplistprime = iplistprime->child->right->right;

        }

        if(head->right->right->rule != 13){
            parsetree oplist = head->right->right->child->right;

            switch(oplist->child->right->rule)
            {
                
                        case 22: strcat(outputtype, "INTEGER");
                        break;
                        case 23:strcat(outputtype, "REAL");
                        break;
                        case 24:strcat(outputtype, "BOOLEAN");
                        break;
            }

        parsetree oplistprime = oplist->child->right->right;

        while(oplistprime->rule!=16){

            switch(oplistprime->child->right->rule)
            {           case 22: strcat(outputtype, "; INTEGER");
                        break;
                        case 23:strcat(outputtype, "; REAL");
                        break;
                        case 24:strcat(outputtype, "; BOOLEAN");
                        break;
                    }
                    

        oplistprime = oplistprime->child->right->right;

        }
    }

    hash_insert_func(head->Lex->tk->value,inputtype, outputtype);
    return;
}

 populateFunctionDefinitions(fp, head->right, functionname);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7e8, %rsp            # imm = 0x7E8
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
testq %rbx, %rbx
je 0x5791
movq 0x18(%rbx), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x544a
movq (%rbx), %r12
movq (%r12), %rdi
addq $0x1e, %rdi
movq %r14, %rsi
callq 0x2120
testl %eax, %eax
jne 0x54a0
movq 0x30(%rbx), %rax
cmpl $0x7, 0x8(%rax)
je 0x54a6
movq 0x28(%rbx), %rbx
jmp 0x5467
movq 0x28(%rbx), %r14
leaq -0x420(%rbp), %rdi
movl $0x3e8, %edx            # imm = 0x3E8
xorl %esi, %esi
callq 0x20f0
leaq -0x810(%rbp), %rdi
movl $0x3e8, %edx            # imm = 0x3E8
xorl %esi, %esi
callq 0x20f0
movq 0x18(%r14), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %ecx
addl $-0x12, %ecx
movabsq $0x52454745544e49, %rbx # imm = 0x52454745544E49
movabsq $0x4e41454c4f4f42, %r15 # imm = 0x4E41454C4F4F42
cmpl $0x3, %ecx
ja 0x5607
leaq 0x2c4e(%rip), %rdx      # 0x8150
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq -0x420(%rbp), %rdi
callq 0x20a0
movq %rbx, -0x420(%rbp,%rax)
jmp 0x5607
leaq -0x420(%rbp), %rdi
callq 0x20a0
movq %r15, -0x420(%rbp,%rax)
jmp 0x5607
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
cmpl $0x18, %eax
je 0x55c7
cmpl $0x17, %eax
je 0x5595
cmpl $0x16, %eax
jne 0x5607
leaq -0x420(%rbp), %rdi
callq 0x20a0
movups 0x3565(%rip), %xmm0     # 0x8ad7
jmp 0x55da
leaq -0x420(%rbp), %rdi
callq 0x20a0
movl $0x4c414552, -0x420(%rbp,%rax) # imm = 0x4C414552
movb $0x0, -0x41c(%rbp,%rax)
jmp 0x5607
leaq -0x420(%rbp), %rdi
callq 0x20a0
movabsq $0x4552285941525241, %rcx # imm = 0x4552285941525241
movq %rcx, -0x420(%rbp,%rax)
movabsq $0x202c4c41455228, %rcx # imm = 0x202C4C41455228
movq %rcx, -0x41b(%rbp,%rax)
jmp 0x55e2
leaq -0x420(%rbp), %rdi
callq 0x20a0
movups 0x351e(%rip), %xmm0     # 0x8af8
movups %xmm0, -0x420(%rbp,%rax)
leaq -0x420(%rbp), %rbx
leaq -0x2b(%rbp), %rsi
movq %rbx, %rdi
callq 0x21c0
movq %rbx, %rdi
callq 0x20a0
movw $0x29, -0x420(%rbp,%rax)
movq %r14, -0x38(%rbp)
leaq 0x18(%r14), %r13
leaq 0x2b4a(%rip), %r14      # 0x8160
leaq -0x420(%rbp), %rbx
movabsq $0x41454c4f4f42203b, %r15 # imm = 0x41454C4F4F42203B
movq (%r13), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %r13
cmpl $0xb, 0xc(%r13)
je 0x5768
movq 0x18(%r13), %rax
addq $0x18, %r13
movq 0x28(%rax), %rax
movl 0xc(%rax), %ecx
addl $-0x12, %ecx
cmpl $0x3, %ecx
ja 0x5627
movslq (%r14,%rcx,4), %rcx
addq %r14, %rcx
jmpq *%rcx
movq %rbx, %rdi
callq 0x20a0
movabsq $0x454745544e49203b, %rcx # imm = 0x454745544E49203B
movq %rcx, -0x420(%rbp,%rax)
movw $0x52, -0x418(%rbp,%rax)
jmp 0x5627
movq %rbx, %rdi
callq 0x20a0
movq %r15, -0x420(%rbp,%rax)
movw $0x4e, -0x418(%rbp,%rax)
jmp 0x5627
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
cmpl $0x18, %eax
je 0x5724
cmpl $0x17, %eax
je 0x56f6
cmpl $0x16, %eax
jne 0x5627
movq %rbx, %rdi
callq 0x20a0
movups 0x3404(%rip), %xmm0     # 0x8ad5
jmp 0x5733
movq %rbx, %rdi
callq 0x20a0
movl $0x4552203b, -0x420(%rbp,%rax) # imm = 0x4552203B
movl $0x4c4145, -0x41d(%rbp,%rax) # imm = 0x4C4145
jmp 0x5627
movq %rbx, %rdi
callq 0x20a0
movabsq $0x285941525241203b, %rcx # imm = 0x285941525241203B
movq %rcx, -0x420(%rbp,%rax)
movabsq $0x202c4c41455228, %rcx # imm = 0x202C4C41455228
movq %rcx, -0x419(%rbp,%rax)
jmp 0x5745
movq %rbx, %rdi
callq 0x20a0
movups 0x33c3(%rip), %xmm0     # 0x8af6
movups %xmm0, -0x420(%rbp,%rax)
movw $0x20, -0x410(%rbp,%rax)
movq %rbx, %rdi
leaq -0x2b(%rbp), %rsi
callq 0x21c0
movq %rbx, %rdi
callq 0x20a0
movw $0x29, -0x420(%rbp,%rax)
jmp 0x5627
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
cmpl $0xd, 0xc(%rax)
jne 0x57a3
movq (%r12), %rdi
addq $0x1e, %rdi
leaq -0x420(%rbp), %rsi
leaq -0x810(%rbp), %rdx
callq 0x4376
addq $0x7e8, %rsp            # imm = 0x7E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %r14
movl 0xc(%r14), %eax
cmpl $0x18, %eax
je 0x57ff
cmpl $0x17, %eax
je 0x57de
cmpl $0x16, %eax
jne 0x581d
leaq -0x810(%rbp), %rdi
callq 0x20a0
movabsq $0x52454745544e49, %rcx # imm = 0x52454745544E49
jmp 0x5815
leaq -0x810(%rbp), %rdi
callq 0x20a0
movl $0x4c414552, -0x810(%rbp,%rax) # imm = 0x4C414552
movb $0x0, -0x80c(%rbp,%rax)
jmp 0x581d
leaq -0x810(%rbp), %rdi
callq 0x20a0
movabsq $0x4e41454c4f4f42, %rcx # imm = 0x4E41454C4F4F42
movq %rcx, -0x810(%rbp,%rax)
leaq -0x810(%rbp), %rbx
movq 0x28(%r14), %rax
cmpl $0x10, 0xc(%rax)
je 0x5776
movq 0x18(%rax), %rax
movq 0x28(%rax), %r14
movl 0xc(%r14), %eax
cmpl $0x18, %eax
je 0x5893
cmpl $0x17, %eax
je 0x5873
cmpl $0x16, %eax
jne 0x5824
movq %rbx, %rdi
callq 0x20a0
movabsq $0x454745544e49203b, %rcx # imm = 0x454745544E49203B
movq %rcx, -0x810(%rbp,%rax)
movw $0x52, -0x808(%rbp,%rax)
jmp 0x5824
movq %rbx, %rdi
callq 0x20a0
movl $0x4552203b, -0x810(%rbp,%rax) # imm = 0x4552203B
movl $0x4c4145, -0x80d(%rbp,%rax) # imm = 0x4C4145
jmp 0x5824
movq %rbx, %rdi
callq 0x20a0
movq %r15, -0x810(%rbp,%rax)
movw $0x4e, -0x808(%rbp,%rax)
jmp 0x5824