// File: /workspace/github_c_makefile_star2_O1/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 0x5f2c
movq 0x18(%rbx), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x5ab1
movq (%rbx), %r12
movq (%r12), %rdi
addq $0x1e, %rdi
movq %r14, %rsi
callq 0x2120
testl %eax, %eax
jne 0x5b07
movq 0x30(%rbx), %rax
cmpl $0x7, 0x8(%rax)
je 0x5b0d
movq 0x28(%rbx), %rbx
jmp 0x5ace
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 0x5c63
leaq 0x35fb(%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 0x5b8c
leaq -0x420(%rbp), %rdi
callq 0x20a0
movabsq $0x4e41454c4f4f42, %rcx # imm = 0x4E41454C4F4F42
movq %rcx, -0x420(%rbp,%rax)
jmp 0x5c63
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
cmpl $0x18, %eax
je 0x5c23
cmpl $0x17, %eax
je 0x5bf1
cmpl $0x16, %eax
jne 0x5c63
leaq -0x420(%rbp), %rdi
callq 0x20a0
movups 0x3f09(%rip), %xmm0     # 0x9ad7
jmp 0x5c36
leaq -0x420(%rbp), %rdi
callq 0x20a0
movl $0x4c414552, -0x420(%rbp,%rax) # imm = 0x4C414552
movb $0x0, -0x41c(%rbp,%rax)
jmp 0x5c63
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 0x5c3e
leaq -0x420(%rbp), %rdi
callq 0x20a0
movups 0x3ec2(%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 0x5dd1
leaq 0x34df(%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 0x5dba
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 0x5dba
movq %rbx, %rdi
callq 0x20a0
movabsq $0x41454c4f4f42203b, %rcx # imm = 0x41454C4F4F42203B
movq %rcx, -0x420(%rbp,%rax)
movw $0x4e, -0x418(%rbp,%rax)
jmp 0x5dba
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
cmpl $0x18, %eax
je 0x5d7b
cmpl $0x17, %eax
je 0x5d4d
cmpl $0x16, %eax
jne 0x5dba
movq %rbx, %rdi
callq 0x20a0
movups 0x3daa(%rip), %xmm0     # 0x9ad5
jmp 0x5d8a
movq %rbx, %rdi
callq 0x20a0
movl $0x4552203b, -0x420(%rbp,%rax) # imm = 0x4552203B
movl $0x4c4145, -0x41d(%rbp,%rax) # imm = 0x4C4145
jmp 0x5dba
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 0x5d9c
movq %rbx, %rdi
callq 0x20a0
movups 0x3d6c(%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 0x5c88
movq 0x28(%r15), %rax
cmpl $0xd, 0xc(%rax)
je 0x5f11
movq 0x18(%rax), %rax
movq 0x28(%rax), %rbx
movq 0x18(%rbx), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
cmpl $0x18, %eax
je 0x5e3a
cmpl $0x17, %eax
je 0x5e19
cmpl $0x16, %eax
jne 0x5e58
leaq -0x810(%rbp), %rdi
callq 0x20a0
movabsq $0x52454745544e49, %rcx # imm = 0x52454745544E49
jmp 0x5e50
leaq -0x810(%rbp), %rdi
callq 0x20a0
movl $0x4c414552, -0x810(%rbp,%rax) # imm = 0x4C414552
movb $0x0, -0x80c(%rbp,%rax)
jmp 0x5e58
leaq -0x810(%rbp), %rdi
callq 0x20a0
movabsq $0x4e41454c4f4f42, %rcx # imm = 0x4E41454C4F4F42
movq %rcx, -0x810(%rbp,%rax)
movq 0x18(%rbx), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %r14
cmpl $0x10, 0xc(%r14)
je 0x5f11
leaq -0x810(%rbp), %rbx
movabsq $0x41454c4f4f42203b, %r15 # imm = 0x41454C4F4F42203B
movabsq $0x454745544e49203b, %r13 # imm = 0x454745544E49203B
movq 0x18(%r14), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
cmpl $0x18, %eax
je 0x5ee0
cmpl $0x17, %eax
je 0x5ec0
cmpl $0x16, %eax
jne 0x5efa
movq %rbx, %rdi
callq 0x20a0
movq %r13, -0x810(%rbp,%rax)
movw $0x52, -0x808(%rbp,%rax)
jmp 0x5efa
movq %rbx, %rdi
callq 0x20a0
movl $0x4552203b, -0x810(%rbp,%rax) # imm = 0x4552203B
movl $0x4c4145, -0x80d(%rbp,%rax) # imm = 0x4C4145
jmp 0x5efa
movq %rbx, %rdi
callq 0x20a0
movq %r15, -0x810(%rbp,%rax)
movw $0x4e, -0x808(%rbp,%rax)
movq 0x18(%r14), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %r14
cmpl $0x10, 0xc(%r14)
jne 0x5e8a
movq (%r12), %rdi
addq $0x1e, %rdi
leaq -0x420(%rbp), %rsi
leaq -0x810(%rbp), %rdx
callq 0x47d0
addq $0x7e8, %rsp            # imm = 0x7E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq