// File: /workspace/github_c_makefile_star2_O3/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:
testq %rsi, %rsi
je 0x5e56
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
movq 0x18(%rbx), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x59d7
movq (%rbx), %r12
movq (%r12), %rdi
addq $0x1e, %rdi
movq %r14, %rsi
callq 0x2120
testl %eax, %eax
jne 0x5a2d
movq 0x30(%rbx), %rax
cmpl $0x7, 0x8(%rax)
je 0x5a3b
movq 0x28(%rbx), %rbx
testq %rbx, %rbx
jne 0x59fd
jmp 0x5e45
movq 0x28(%rbx), %r15
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(%r15), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %ecx
addl $-0x12, %ecx
cmpl $0x3, %ecx
ja 0x5b91
leaq 0x36cd(%rip), %rdx      # 0x9150
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq -0x420(%rbp), %rdi
callq 0x20a0
movabsq $0x52454745544e49, %rcx # imm = 0x52454745544E49
jmp 0x5aba
leaq -0x420(%rbp), %rdi
callq 0x20a0
movabsq $0x4e41454c4f4f42, %rcx # imm = 0x4E41454C4F4F42
movq %rcx, -0x420(%rbp,%rax)
jmp 0x5b91
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
cmpl $0x18, %eax
je 0x5b51
cmpl $0x17, %eax
je 0x5b1f
cmpl $0x16, %eax
jne 0x5b91
leaq -0x420(%rbp), %rdi
callq 0x20a0
movups 0x3fdb(%rip), %xmm0     # 0x9ad7
jmp 0x5b64
leaq -0x420(%rbp), %rdi
callq 0x20a0
movl $0x4c414552, -0x420(%rbp,%rax) # imm = 0x4C414552
movb $0x0, -0x41c(%rbp,%rax)
jmp 0x5b91
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 0x5b6c
leaq -0x420(%rbp), %rdi
callq 0x20a0
movups 0x3f94(%rip), %xmm0     # 0x9af8
movups %xmm0, -0x420(%rbp,%rax)
leaq -0x420(%rbp), %rbx
leaq -0x2b(%rbp), %rsi
movq %rbx, %rdi
callq 0x21b0
movq %rbx, %rdi
callq 0x20a0
movw $0x29, -0x420(%rbp,%rax)
movq 0x18(%r15), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %r13
cmpl $0xb, 0xc(%r13)
je 0x5cff
leaq 0x35b1(%rip), %r14      # 0x9160
leaq -0x420(%rbp), %rbx
movq 0x18(%r13), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %ecx
addl $-0x12, %ecx
cmpl $0x3, %ecx
ja 0x5ce8
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 0x5ce8
movq %rbx, %rdi
callq 0x20a0
movabsq $0x41454c4f4f42203b, %rcx # imm = 0x41454C4F4F42203B
movq %rcx, -0x420(%rbp,%rax)
movw $0x4e, -0x418(%rbp,%rax)
jmp 0x5ce8
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
cmpl $0x18, %eax
je 0x5ca9
cmpl $0x17, %eax
je 0x5c7b
cmpl $0x16, %eax
jne 0x5ce8
movq %rbx, %rdi
callq 0x20a0
movups 0x3e7c(%rip), %xmm0     # 0x9ad5
jmp 0x5cb8
movq %rbx, %rdi
callq 0x20a0
movl $0x4552203b, -0x420(%rbp,%rax) # imm = 0x4552203B
movl $0x4c4145, -0x41d(%rbp,%rax) # imm = 0x4C4145
jmp 0x5ce8
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 0x5cca
movq %rbx, %rdi
callq 0x20a0
movups 0x3e3e(%rip), %xmm0     # 0x9af6
movups %xmm0, -0x420(%rbp,%rax)
movw $0x20, -0x410(%rbp,%rax)
movq %rbx, %rdi
leaq -0x2b(%rbp), %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x20a0
movw $0x29, -0x420(%rbp,%rax)
movq 0x18(%r13), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %r13
cmpl $0xb, 0xc(%r13)
jne 0x5bb6
movq 0x28(%r15), %rax
cmpl $0xd, 0xc(%rax)
je 0x5e2a
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rbx
movl 0xc(%rbx), %eax
cmpl $0x18, %eax
je 0x5d68
cmpl $0x17, %eax
je 0x5d47
cmpl $0x16, %eax
jne 0x5d86
leaq -0x810(%rbp), %rdi
callq 0x20a0
movabsq $0x52454745544e49, %rcx # imm = 0x52454745544E49
jmp 0x5d7e
leaq -0x810(%rbp), %rdi
callq 0x20a0
movl $0x4c414552, -0x810(%rbp,%rax) # imm = 0x4C414552
movb $0x0, -0x80c(%rbp,%rax)
jmp 0x5d86
leaq -0x810(%rbp), %rdi
callq 0x20a0
movabsq $0x4e41454c4f4f42, %rcx # imm = 0x4E41454C4F4F42
movq %rcx, -0x810(%rbp,%rax)
movq 0x28(%rbx), %rax
cmpl $0x10, 0xc(%rax)
je 0x5e2a
leaq -0x810(%rbp), %rbx
movabsq $0x41454c4f4f42203b, %r14 # imm = 0x41454C4F4F42203B
movabsq $0x454745544e49203b, %r15 # imm = 0x454745544E49203B
movq 0x18(%rax), %rax
movq 0x28(%rax), %r13
movl 0xc(%r13), %eax
cmpl $0x18, %eax
je 0x5e06
cmpl $0x17, %eax
je 0x5de6
cmpl $0x16, %eax
jne 0x5e20
movq %rbx, %rdi
callq 0x20a0
movq %r15, -0x810(%rbp,%rax)
movw $0x52, -0x808(%rbp,%rax)
jmp 0x5e20
movq %rbx, %rdi
callq 0x20a0
movl $0x4552203b, -0x810(%rbp,%rax) # imm = 0x4552203B
movl $0x4c4145, -0x80d(%rbp,%rax) # imm = 0x4C4145
jmp 0x5e20
movq %rbx, %rdi
callq 0x20a0
movq %r14, -0x810(%rbp,%rax)
movw $0x4e, -0x808(%rbp,%rax)
movq 0x28(%r13), %rax
cmpl $0x10, 0xc(%rax)
jne 0x5daf
movq (%r12), %rdi
addq $0x1e, %rdi
leaq -0x420(%rbp), %rsi
leaq -0x810(%rbp), %rdx
callq 0x4703
addq $0x7e8, %rsp            # imm = 0x7E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq