// File: /workspace/github_c_makefile_star2_O0/Gaurang18[P]Compiler-Project-BITS-Pilani/./codegen.c
// Function: declarevariables
void declarevariables(parsetree head, FILE* fp)
{
    int i;
    char datasection[] = "section .data\n\tnumberin_form:\tdb \"%d\",0\n\n\tnumberout_form:\tdb \"%d\",10,0\n";
    fprintf(fp, "%s", datasection);
    fprintf(fp,"section .bss\n");
   
    char* functionname = "driver";
    int j = get_func_hash_value(functionname);
    for(i=0;i<SIZE;i++){
        pNode* it  = ht->functable[j]->table[i]->next;
        if(it !=NULL && strcmp(it->name,"")!= 0){
        	char* yp = "ARRAY";
        	if(strncmp(it->type,yp,5)!=0)
            fprintf(fp,"\t%s:\t resd %d\n",it->name,1);
        	else{

        		char* type = it->type;
        		char *token = NULL;
            		token = strtok(it->type, "(");
            		if(token!=NULL){
                		token = strtok(NULL, ",");
                		token = strtok(NULL, ")");
                		if(token!=NULL)
                		strcpy(type, token);
            			}

            	int range = atoi(type);
            	fprintf(fp,"\t%s:\t resd %d\n",it->name,range);


        	}
        }


    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x60(%rbp), %rdi
leaq 0x40d2(%rip), %rsi      # 0xdcb0
movl $0x48, %edx
callq 0x2120
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rdx
leaq 0x35a4(%rip), %rsi      # 0xd19b
movb $0x0, %al
callq 0x2100
movq -0x10(%rbp), %rdi
leaq 0x3595(%rip), %rsi      # 0xd19e
movb $0x0, %al
callq 0x2100
leaq 0x2748(%rip), %rax      # 0xc35f
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x64a0
movl %eax, -0x6c(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x14, -0x14(%rbp)
jge 0x9d8d
movq 0x195d9(%rip), %rax     # 0x23218
movslq -0x6c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x9d7d
movq -0x78(%rbp), %rdi
leaq 0x3a5e(%rip), %rsi      # 0xd6cb
callq 0x20f0
cmpl $0x0, %eax
je 0x9d7d
leaq 0x275d(%rip), %rax      # 0xc3df
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rdi
addq $0x37, %rdi
movq -0x80(%rbp), %rsi
movl $0x5, %edx
callq 0x2040
cmpl $0x0, %eax
je 0x9cc1
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rdx
leaq 0x34fc(%rip), %rsi      # 0xd1ac
movl $0x1, %ecx
movb $0x0, %al
callq 0x2100
jmp 0x9d7b
movq -0x78(%rbp), %rax
addq $0x37, %rax
movq %rax, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
movq -0x78(%rbp), %rdi
addq $0x37, %rdi
leaq 0x27f0(%rip), %rsi      # 0xc4da
callq 0x2160
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0x9d4d
xorl %eax, %eax
movl %eax, %edi
leaq 0x27bf(%rip), %rsi      # 0xc4ca
callq 0x2160
movq %rax, -0x90(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq 0x356a(%rip), %rsi      # 0xd28c
callq 0x2160
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
je 0x9d4b
movq -0x88(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x2050
jmp 0x9d4d
movq -0x88(%rbp), %rdi
callq 0x2170
movl %eax, -0x94(%rbp)
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rdx
movl -0x94(%rbp), %ecx
leaq 0x3438(%rip), %rsi      # 0xd1ac
movb $0x0, %al
callq 0x2100
jmp 0x9d7d
jmp 0x9d7f
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x9c2e
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)