// File: /workspace/github_c_makefile_star2_O1/Gaurang18[P]Compiler-Project-BITS-Pilani/./tokensymboltable.h
// Function: hashinsert
int hashinsert(char* key,char* type,char* functionname,char* ifnumvalue)
{
    int j = get_func_hash_value(functionname);
    int h = hash(key);
    struct tokNode* it = create_node(key,type,functionname,ifnumvalue);
    if (it == NULL){
        return 0;
    }
    while(ht->functable[j]->table[h]->next != NULL){
        h++;
    }
    ht->functable[j]->table[h]->next = it;
    int width =0;
       if(strcmp(ht->functable[j]->table[h]->next->type,"INTEGER") ==0){
        width = 2;
       }
       if(strcmp(ht->functable[j]->table[h]->next->type,"REAL") ==0){
        width = 4;
       }
       if(strcmp(ht->functable[j]->table[h]->next->type,"STRING") ==0){
        width = strlen(ht->functable[j]->table[h]->next->name);
       }
       if(strcmp(ht->functable[j]->table[h]->next->type,"BOOLEAN") ==0){
           width = 1;
       }
       if(strncmp(ht->functable[j]->table[h]->next->type,"ARRAY",5) ==0){
        char type[50];
        memset(type, '\0', sizeof(type));
        strcpy(type, ht->functable[j]->table[h]->next->type);
        int range = 0;
        
                char *token = NULL;
                    token = strtok(type, "(");
                    if(token!=NULL){
                        token = strtok(NULL, ",");

                        if(strcmp(token, "INTEGER")==0)
                            width = 2;
                        if(strcmp(token, "REAL")==0)
                            width = 4;
                        if(strcmp(token, "BOOLEAN")==0)
                            width = 1;


                        token = strtok(NULL, ")");
                        if(token!=NULL){
                            range = atoi(token);

                        }}

                
                // assert(0);

        width = width*range;
       }
        ht->functable[j]->table[h]->next->width = width;
        
        ht->functable[j]->table[h]->next->offset = offset; 
        offset += width;
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
movq %rdx, %rdi
callq 0x489a
movl %eax, -0x30(%rbp)
movq %r13, %rdi
callq 0x20a0
xorl %r14d, %r14d
testq %rax, %rax
je 0x4d49
xorl %ecx, %ecx
movsbl (%r13,%rcx), %edx
addl %edx, %r14d
incq %rcx
cmpq %rcx, %rax
jne 0x4d16
movslq %r14d, %rax
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x23, %rcx
addl %edx, %ecx
shll $0x2, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
movslq %eax, %r14
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x46bc
testq %rax, %rax
je 0x4e32
movq 0x1b15e(%rip), %rdi     # 0x1fec8
movslq -0x30(%rbp), %rsi
movq (%rdi,%rsi,8), %rcx
shlq $0x3, %r14
movq (%rcx,%r14), %rdx
addq $0x8, %r14
cmpq $0x0, 0x50(%rdx)
jne 0x4d76
movq %rax, 0x50(%rdx)
movq %rsi, -0x30(%rbp)
movq %rdi, -0x38(%rbp)
movq (%rdi,%rsi,8), %rax
movq -0x8(%rax,%r14), %rax
movq 0x50(%rax), %r12
leaq 0x37(%r12), %r15
leaq 0x4d12(%rip), %rsi      # 0x9abc
movq %r15, %rdi
callq 0x2120
xorl %r13d, %r13d
testl %eax, %eax
sete %r13b
addl %r13d, %r13d
leaq 0x4d01(%rip), %rsi      # 0x9ac6
movq %r15, %rdi
callq 0x2120
testl %eax, %eax
movl $0x4, %ebx
cmovnel %r13d, %ebx
leaq 0x491f(%rip), %rsi      # 0x96fe
movq %r15, %rdi
callq 0x2120
testl %eax, %eax
jne 0x4df6
movq %r12, %rdi
callq 0x20a0
movq %rax, %rbx
leaq 0x4cd0(%rip), %rsi      # 0x9acd
movq %r15, %rdi
callq 0x2120
testl %eax, %eax
movl $0x1, %r12d
cmovel %r12d, %ebx
leaq 0x44ef(%rip), %rsi      # 0x9307
movl $0x5, %edx
movq %r15, %rdi
callq 0x2050
testl %eax, %eax
je 0x4e3a
movq -0x30(%rbp), %r13
jmp 0x4f18
xorl %r12d, %r12d
jmp 0x4f40
xorps %xmm0, %xmm0
leaq -0x70(%rbp), %r15
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
movw $0x0, 0x30(%r15)
movq -0x30(%rbp), %r13
movq -0x38(%rbp), %rax
movq (%rax,%r13,8), %rax
movq -0x8(%rax,%r14), %rax
movq 0x50(%rax), %rsi
addq $0x37, %rsi
movq %r15, %rdi
callq 0x2060
leaq 0x454f(%rip), %rsi      # 0x93cd
movq %r15, %rdi
callq 0x2180
testq %rax, %rax
je 0x4f13
leaq 0x452b(%rip), %rsi      # 0x93c1
xorl %edi, %edi
callq 0x2180
movq %rax, %r13
leaq 0x4c15(%rip), %rsi      # 0x9abc
movq %rax, %rdi
callq 0x2120
testl %eax, %eax
movl $0x2, %eax
cmovel %eax, %ebx
leaq 0x4c06(%rip), %rsi      # 0x9ac6
movq %r13, %rdi
callq 0x2120
testl %eax, %eax
movl $0x4, %r15d
cmovnel %ebx, %r15d
leaq 0x4bf2(%rip), %rsi      # 0x9acd
movq %r13, %rdi
callq 0x2120
testl %eax, %eax
movl $0x1, %ebx
cmovnel %r15d, %ebx
leaq 0x5249(%rip), %rsi      # 0xa13e
xorl %edi, %edi
callq 0x2180
testq %rax, %rax
je 0x4f0f
movq %rax, %rdi
callq 0x2190
movq -0x30(%rbp), %r13
jmp 0x4f15
movq -0x30(%rbp), %r13
xorl %eax, %eax
imull %eax, %ebx
movq 0x1afa9(%rip), %rax     # 0x1fec8
movq (%rax,%r13,8), %rax
movq -0x8(%rax,%r14), %rax
movq 0x50(%rax), %rax
movl %ebx, 0x4c(%rax)
movl 0x1af8f(%rip), %ecx     # 0x1fec4
movl %ecx, 0x48(%rax)
addl %ebx, %ecx
movl %ecx, 0x1af84(%rip)     # 0x1fec4
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq