// File: /workspace/github_c_makefile_star2_O0/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
subq $0x950, %rsp            # imm = 0x950
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x80e3
jmp 0x8795
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x18(%rbp), %rdx
callq 0x80c0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
movq -0x18(%rbp), %rsi
callq 0x20f0
cmpl $0x0, %eax
jne 0x8780
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
cmpl $0x7, 0x8(%rax)
jne 0x8780
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x20(%rbp)
leaq -0x410(%rbp), %rdi
xorl %esi, %esi
movl %esi, -0x934(%rbp)
movl $0x3e8, %edx            # imm = 0x3E8
movq %rdx, -0x930(%rbp)
callq 0x20c0
movl -0x934(%rbp), %esi
movq -0x930(%rbp), %rdx
leaq -0x800(%rbp), %rdi
callq 0x20c0
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
addl $-0x12, %eax
movl %eax, %ecx
movq %rcx, -0x928(%rbp)
subl $0x3, %eax
ja 0x838b
movq -0x928(%rbp), %rax
leaq 0x40ab(%rip), %rcx      # 0xc24c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x410(%rbp), %rdi
leaq 0x4a4f(%rip), %rsi      # 0xcc07
callq 0x2190
jmp 0x838b
leaq -0x410(%rbp), %rdi
leaq 0x4a41(%rip), %rsi      # 0xcc11
callq 0x2190
jmp 0x838b
leaq -0x410(%rbp), %rdi
leaq 0x4a30(%rip), %rsi      # 0xcc18
callq 0x2190
jmp 0x838b
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x808(%rbp)
movq -0x808(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
callq 0x2170
movl %eax, -0x80c(%rbp)
movq -0x808(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
callq 0x2170
movl %eax, -0x810(%rbp)
movl -0x810(%rbp), %eax
movl -0x80c(%rbp), %ecx
subl %ecx, %eax
incl %eax
movl %eax, -0x814(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x830(%rbp)
movaps %xmm0, -0x840(%rbp)
movaps %xmm0, -0x850(%rbp)
movaps %xmm0, -0x860(%rbp)
movaps %xmm0, -0x870(%rbp)
movaps %xmm0, -0x880(%rbp)
movl $0x0, -0x820(%rbp)
movq -0x808(%rbp), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
movl %eax, -0x938(%rbp)
subl $0x16, %eax
je 0x82da
jmp 0x82bd
movl -0x938(%rbp), %eax
subl $0x17, %eax
je 0x8315
jmp 0x82ca
movl -0x938(%rbp), %eax
subl $0x18, %eax
je 0x8350
jmp 0x8389
leaq -0x410(%rbp), %rdi
leaq 0x493a(%rip), %rsi      # 0xcc22
callq 0x2190
leaq -0x410(%rbp), %rdi
leaq -0x817(%rbp), %rsi
callq 0x2190
leaq -0x410(%rbp), %rdi
leaq 0x4f7e(%rip), %rsi      # 0xd28c
callq 0x2190
jmp 0x8389
leaq -0x410(%rbp), %rdi
leaq 0x4911(%rip), %rsi      # 0xcc34
callq 0x2190
leaq -0x410(%rbp), %rdi
leaq -0x817(%rbp), %rsi
callq 0x2190
leaq -0x410(%rbp), %rdi
leaq 0x4f43(%rip), %rsi      # 0xd28c
callq 0x2190
jmp 0x8389
leaq -0x410(%rbp), %rdi
leaq 0x48e5(%rip), %rsi      # 0xcc43
callq 0x2190
leaq -0x410(%rbp), %rdi
leaq -0x817(%rbp), %rsi
callq 0x2190
leaq -0x410(%rbp), %rdi
leaq 0x4f08(%rip), %rsi      # 0xd28c
callq 0x2190
jmp 0x838b
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x888(%rbp)
movq -0x888(%rbp), %rax
cmpl $0xb, 0xc(%rax)
je 0x85f4
movq -0x888(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
addl $-0x12, %eax
movl %eax, %ecx
movq %rcx, -0x940(%rbp)
subl $0x3, %eax
ja 0x85d5
movq -0x940(%rbp), %rax
leaq 0x3e74(%rip), %rcx      # 0xc25c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x410(%rbp), %rdi
leaq 0x4806(%rip), %rsi      # 0xcc05
callq 0x2190
jmp 0x85d5
leaq -0x410(%rbp), %rdi
leaq 0x47f8(%rip), %rsi      # 0xcc0f
callq 0x2190
jmp 0x85d5
leaq -0x410(%rbp), %rdi
leaq 0x47e7(%rip), %rsi      # 0xcc16
callq 0x2190
jmp 0x85d5
movq -0x888(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x890(%rbp)
movq -0x890(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
callq 0x2170
movl %eax, -0x894(%rbp)
movq -0x890(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
callq 0x2170
movl %eax, -0x898(%rbp)
movl -0x898(%rbp), %eax
movl -0x894(%rbp), %ecx
subl %ecx, %eax
incl %eax
movl %eax, -0x89c(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x8c0(%rbp)
movaps %xmm0, -0x8d0(%rbp)
movaps %xmm0, -0x8e0(%rbp)
movaps %xmm0, -0x8f0(%rbp)
movaps %xmm0, -0x900(%rbp)
movaps %xmm0, -0x910(%rbp)
movl $0x0, -0x8b0(%rbp)
movq -0x890(%rbp), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
movl %eax, -0x944(%rbp)
subl $0x16, %eax
je 0x8524
jmp 0x8507
movl -0x944(%rbp), %eax
subl $0x17, %eax
je 0x855f
jmp 0x8514
movl -0x944(%rbp), %eax
subl $0x18, %eax
je 0x859a
jmp 0x85d3
leaq -0x410(%rbp), %rdi
leaq 0x46ee(%rip), %rsi      # 0xcc20
callq 0x2190
leaq -0x410(%rbp), %rdi
leaq -0x89f(%rbp), %rsi
callq 0x2190
leaq -0x410(%rbp), %rdi
leaq 0x4d34(%rip), %rsi      # 0xd28c
callq 0x2190
jmp 0x85d3
leaq -0x410(%rbp), %rdi
leaq 0x46c5(%rip), %rsi      # 0xcc32
callq 0x2190
leaq -0x410(%rbp), %rdi
leaq -0x89f(%rbp), %rsi
callq 0x2190
leaq -0x410(%rbp), %rdi
leaq 0x4cf9(%rip), %rsi      # 0xd28c
callq 0x2190
jmp 0x85d3
leaq -0x410(%rbp), %rdi
leaq 0x4699(%rip), %rsi      # 0xcc41
callq 0x2190
leaq -0x410(%rbp), %rdi
leaq -0x89f(%rbp), %rsi
callq 0x2190
leaq -0x410(%rbp), %rdi
leaq 0x4cbe(%rip), %rsi      # 0xd28c
callq 0x2190
jmp 0x85d5
movq -0x888(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x888(%rbp)
jmp 0x83a2
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
cmpl $0xd, 0xc(%rax)
je 0x875d
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x918(%rbp)
movq -0x918(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
movl %eax, -0x948(%rbp)
subl $0x16, %eax
je 0x865e
jmp 0x8644
movl -0x948(%rbp), %eax
subl $0x17, %eax
je 0x8673
jmp 0x8651
movl -0x948(%rbp), %eax
subl $0x18, %eax
je 0x8688
jmp 0x869b
leaq -0x800(%rbp), %rdi
leaq 0x459b(%rip), %rsi      # 0xcc07
callq 0x2190
jmp 0x869b
leaq -0x800(%rbp), %rdi
leaq 0x4590(%rip), %rsi      # 0xcc11
callq 0x2190
jmp 0x869b
leaq -0x800(%rbp), %rdi
leaq 0x4582(%rip), %rsi      # 0xcc18
callq 0x2190
movq -0x918(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x920(%rbp)
movq -0x920(%rbp), %rax
cmpl $0x10, 0xc(%rax)
je 0x875b
movq -0x920(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
movl %eax, -0x94c(%rbp)
subl $0x16, %eax
je 0x86ff
jmp 0x86e5
movl -0x94c(%rbp), %eax
subl $0x17, %eax
je 0x8714
jmp 0x86f2
movl -0x94c(%rbp), %eax
subl $0x18, %eax
je 0x8729
jmp 0x873c
leaq -0x800(%rbp), %rdi
leaq 0x44f8(%rip), %rsi      # 0xcc05
callq 0x2190
jmp 0x873c
leaq -0x800(%rbp), %rdi
leaq 0x44ed(%rip), %rsi      # 0xcc0f
callq 0x2190
jmp 0x873c
leaq -0x800(%rbp), %rdi
leaq 0x44df(%rip), %rsi      # 0xcc16
callq 0x2190
movq -0x920(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x920(%rbp)
jmp 0x86b5
jmp 0x875d
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
leaq -0x410(%rbp), %rsi
leaq -0x800(%rbp), %rdx
callq 0x63e0
jmp 0x8795
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x18(%rbp), %rdx
callq 0x80c0
addq $0x950, %rsp            # imm = 0x950
popq %rbp
retq
nop