// File: /workspace/github_c_makefile_star2_O0/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
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x64a0
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6370
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x6270
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x6c2f
movl $0x0, -0x4(%rbp)
jmp 0x6f0d
jmp 0x6c31
movq 0x1c5e0(%rip), %rax     # 0x23218
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq $0x0, 0x50(%rax)
je 0x6c5a
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x6c31
movq -0x38(%rbp), %rcx
movq 0x1c5b3(%rip), %rax     # 0x23218
movslq -0x2c(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movslq -0x30(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x50(%rax)
movl $0x0, -0x3c(%rbp)
movq 0x1c591(%rip), %rax     # 0x23218
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rdi
addq $0x37, %rdi
leaq 0x5f61(%rip), %rsi      # 0xcc07
callq 0x20f0
cmpl $0x0, %eax
jne 0x6cb7
movl $0x2, -0x3c(%rbp)
movq 0x1c55a(%rip), %rax     # 0x23218
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rdi
addq $0x37, %rdi
leaq 0x5f34(%rip), %rsi      # 0xcc11
callq 0x20f0
cmpl $0x0, %eax
jne 0x6cee
movl $0x4, -0x3c(%rbp)
movq 0x1c523(%rip), %rax     # 0x23218
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rdi
addq $0x37, %rdi
leaq 0x5b22(%rip), %rsi      # 0xc836
callq 0x20f0
cmpl $0x0, %eax
jne 0x6d41
movq 0x1c4f3(%rip), %rax     # 0x23218
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rdi
callq 0x2080
movl %eax, -0x3c(%rbp)
movq 0x1c4d0(%rip), %rax     # 0x23218
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rdi
addq $0x37, %rdi
leaq 0x5eb1(%rip), %rsi      # 0xcc18
callq 0x20f0
cmpl $0x0, %eax
jne 0x6d78
movl $0x1, -0x3c(%rbp)
movq 0x1c499(%rip), %rax     # 0x23218
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rdi
addq $0x37, %rdi
leaq 0x5641(%rip), %rsi      # 0xc3df
movl $0x5, %edx
callq 0x2040
cmpl $0x0, %eax
jne 0x6eb2
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x32, %edx
callq 0x20c0
leaq -0x70(%rbp), %rdi
movq 0x1c44c(%rip), %rax     # 0x23218
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rsi
addq $0x37, %rsi
callq 0x2050
movl $0x0, -0x74(%rbp)
movq $0x0, -0x80(%rbp)
leaq -0x70(%rbp), %rdi
leaq 0x56d7(%rip), %rsi      # 0xc4da
callq 0x2160
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0x6ea8
xorl %eax, %eax
movl %eax, %edi
leaq 0x56a8(%rip), %rsi      # 0xc4ca
callq 0x2160
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
leaq 0x5dd1(%rip), %rsi      # 0xcc07
callq 0x20f0
cmpl $0x0, %eax
jne 0x6e47
movl $0x2, -0x3c(%rbp)
movq -0x80(%rbp), %rdi
leaq 0x5dbf(%rip), %rsi      # 0xcc11
callq 0x20f0
cmpl $0x0, %eax
jne 0x6e63
movl $0x4, -0x3c(%rbp)
movq -0x80(%rbp), %rdi
leaq 0x5daa(%rip), %rsi      # 0xcc18
callq 0x20f0
cmpl $0x0, %eax
jne 0x6e7f
movl $0x1, -0x3c(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq 0x6402(%rip), %rsi      # 0xd28c
callq 0x2160
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0x6ea6
movq -0x80(%rbp), %rdi
callq 0x2170
movl %eax, -0x74(%rbp)
jmp 0x6ea8
movl -0x3c(%rbp), %eax
imull -0x74(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %ecx
movq 0x1c35c(%rip), %rax     # 0x23218
movslq -0x2c(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movslq -0x30(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq 0x50(%rax), %rax
movl %ecx, 0x4c(%rax)
movl 0x1c33b(%rip), %ecx     # 0x23214
movq 0x1c338(%rip), %rax     # 0x23218
movslq -0x2c(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movslq -0x30(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq 0x50(%rax), %rax
movl %ecx, 0x48(%rax)
movl -0x3c(%rbp), %eax
addl 0x1c314(%rip), %eax     # 0x23214
movl %eax, 0x1c30e(%rip)     # 0x23214
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)