// File: pawan231[P]MiniDataBase/include/display.h
// Function: display()
void display(){
	char *tab;
	tab=(char*)malloc(sizeof(char)*MAX_PATH);
	cout<<"enter table name to display\n";
	cin>>tab;
	int ret=search_table(tab);
	if(ret==0) {
		printf("%s doesn't exist\n\n",tab);
		return ;
	}
	else if(ret==1){
		//table exists

		table *temp;
		int count;
		int tot=0;
		temp=(table*)malloc(sizeof(table));
		printf("\n-----------------------------------------------\n");
		FILE *fp=open_file(tab,const_cast<char*>("r"));
		if(fp){
			fread(temp,1,sizeof(table),fp);
			count=temp->count;
			void *data2[MAX_ATTR];
			for(int i=0;i<count;i++){
				cout<<temp->col[i].col_name<<setw(20);
				if(temp->col[i].type==INT)
				{
					data2[i] =(int*) malloc(sizeof(int));
					if(data2[i]==NULL)
					{
						cout<<"NULL";
						return;
					}
					tot+=sizeof(int);
				}
				else if(temp->col[i].type==VARCHAR)
				{
					data2[i] = malloc(sizeof(char) * (MAX_NAME + 1));
					if(data2[i]==NULL)
					{
						cout<<"NULL";
						return;
					}
					tot+=(sizeof(char) * (MAX_NAME + 1));
				}
			}
			fclose(fp);
			cout<<"\n";
			printf("-----------------------------------------------\n");

			int c;
			char d[MAX_NAME];
			//cout<<"C........"<<c<<endl;
			for(int i=0;i<temp->rec_count;i++){
				FILE *fpr;
				char *str;
				str=(char*)malloc(sizeof(char)*MAX_PATH);
				sprintf(str,"table/%s/file%d.dat",tab,i);
				//cout<<str<<endl;
				fpr=fopen(str,"r");
				//cout<<*(int *)data1[0]<<" ";
				//fread(data2,temp->count,tot,fpr);
				//fread(data2,1,tot,fpr);
				for(int j=0;j<temp->count;j++){
					if(temp->col[j].type==INT){
						fread(&c,1,sizeof(int),fpr);
						cout<<c<<setw(20);
					}
					else if(temp->col[j].type==VARCHAR){
						fread(d,1,sizeof(char)*MAX_NAME,fpr);
						cout<<d<<setw(20);
					}
				}
				cout<<"\n\n";

				free(str);
				fclose(fpr);
			}
			printf("-----------------------------------------------\n");
					//fclose(fp);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x2260
movq %rax, -0x8(%rbp)
movq 0xbbb0(%rip), %rdi      # 0xffd0
leaq 0x705e(%rip), %rsi      # 0xb485
callq 0x2190
movq -0x8(%rbp), %rsi
movq 0xbba9(%rip), %rdi      # 0xffe0
callq 0x5f30
movq -0x8(%rbp), %rdi
callq 0x3b40
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x4465
movq -0x8(%rbp), %rsi
leaq 0x7236(%rip), %rdi      # 0xb68f
movb $0x0, %al
callq 0x2030
jmp 0x4835
cmpl $0x1, -0xc(%rbp)
jne 0x4833
movl $0x0, -0x20(%rbp)
movl $0x420, %edi            # imm = 0x420
callq 0x2260
movq %rax, -0x18(%rbp)
leaq 0x7017(%rip), %rdi      # 0xb4a2
movb $0x0, %al
callq 0x2030
movq -0x8(%rbp), %rdi
leaq 0x77dd(%rip), %rsi      # 0xbc7a
callq 0x30e0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x4831
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rcx
movl $0x1, %esi
movl $0x420, %edx            # imm = 0x420
callq 0x22d0
movq -0x18(%rbp), %rax
movl 0x3e0(%rax), %eax
movl %eax, -0x1c(%rbp)
movl $0x0, -0x124(%rbp)
movl -0x124(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x462d
movq -0x18(%rbp), %rsi
addq $0x7c, %rsi
movslq -0x124(%rbp), %rax
imulq $0x1c, %rax, %rax
addq %rax, %rsi
movq 0xbac5(%rip), %rdi      # 0xffd0
callq 0x2190
movq %rax, -0x190(%rbp)
movl $0x14, %edi
callq 0x62c0
movq -0x190(%rbp), %rdi
movl %eax, -0x128(%rbp)
movl -0x128(%rbp), %esi
callq 0x21f0
movq -0x18(%rbp), %rax
addq $0x7c, %rax
movslq -0x124(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $0x1, 0x14(%rax)
jne 0x45a8
movl $0x4, %edi
callq 0x2260
movq %rax, %rcx
movslq -0x124(%rbp), %rax
movq %rcx, -0x120(%rbp,%rax,8)
movslq -0x124(%rbp), %rax
cmpq $0x0, -0x120(%rbp,%rax,8)
jne 0x459b
movq 0xba46(%rip), %rdi      # 0xffd0
leaq 0x6f43(%rip), %rsi      # 0xb4d4
callq 0x2190
jmp 0x4835
movslq -0x20(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x20(%rbp)
jmp 0x4617
movq -0x18(%rbp), %rax
addq $0x7c, %rax
movslq -0x124(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $0x2, 0x14(%rax)
jne 0x4615
movl $0x33, %edi
callq 0x2260
movq %rax, %rcx
movslq -0x124(%rbp), %rax
movq %rcx, -0x120(%rbp,%rax,8)
movslq -0x124(%rbp), %rax
cmpq $0x0, -0x120(%rbp,%rax,8)
jne 0x460a
movq 0xb9d7(%rip), %rdi      # 0xffd0
leaq 0x6ed4(%rip), %rsi      # 0xb4d4
callq 0x2190
jmp 0x4835
movslq -0x20(%rbp), %rax
addq $0x33, %rax
movl %eax, -0x20(%rbp)
jmp 0x4617
jmp 0x4619
movl -0x124(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x124(%rbp)
jmp 0x44df
movq -0x28(%rbp), %rdi
callq 0x21a0
movq 0xb993(%rip), %rdi      # 0xffd0
leaq 0x7661(%rip), %rsi      # 0xbca5
callq 0x2190
leaq 0x6e53(%rip), %rdi      # 0xb4a3
movb $0x0, %al
callq 0x2030
movl $0x0, -0x164(%rbp)
movl -0x164(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x418(%rcx), %eax
jge 0x4823
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x2260
movq %rax, -0x178(%rbp)
movq -0x178(%rbp), %rdi
movq -0x8(%rbp), %rdx
movl -0x164(%rbp), %ecx
leaq 0x6ca4(%rip), %rsi      # 0xb344
movb $0x0, %al
callq 0x2040
movq -0x178(%rbp), %rdi
leaq 0x75c5(%rip), %rsi      # 0xbc7a
callq 0x2210
movq %rax, -0x170(%rbp)
movl $0x0, -0x17c(%rbp)
movl -0x17c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x3e0(%rcx), %eax
jge 0x47e4
movq -0x18(%rbp), %rax
addq $0x7c, %rax
movslq -0x17c(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $0x1, 0x14(%rax)
jne 0x4757
movq -0x170(%rbp), %rcx
leaq -0x12c(%rbp), %rdi
movl $0x1, %esi
movl $0x4, %edx
callq 0x22d0
movl -0x12c(%rbp), %esi
movq 0xb8a9(%rip), %rdi      # 0xffd0
callq 0x2330
movq %rax, -0x198(%rbp)
movl $0x14, %edi
callq 0x62c0
movq -0x198(%rbp), %rdi
movl %eax, -0x180(%rbp)
movl -0x180(%rbp), %esi
callq 0x21f0
jmp 0x47ce
movq -0x18(%rbp), %rax
addq $0x7c, %rax
movslq -0x17c(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
cmpl $0x2, 0x14(%rax)
jne 0x47cc
leaq -0x160(%rbp), %rdi
movq -0x170(%rbp), %rcx
movl $0x1, %esi
movl $0x32, %edx
callq 0x22d0
leaq -0x160(%rbp), %rsi
movq 0xb832(%rip), %rdi      # 0xffd0
callq 0x2190
movq %rax, -0x1a0(%rbp)
movl $0x14, %edi
callq 0x62c0
movq -0x1a0(%rbp), %rdi
movl %eax, -0x184(%rbp)
movl -0x184(%rbp), %esi
callq 0x21f0
jmp 0x47ce
jmp 0x47d0
movl -0x17c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x17c(%rbp)
jmp 0x46cb
movq 0xb7e5(%rip), %rdi      # 0xffd0
leaq 0x74b2(%rip), %rsi      # 0xbca4
callq 0x2190
movq -0x178(%rbp), %rdi
callq 0x2220
movq -0x170(%rbp), %rdi
callq 0x21a0
movl -0x164(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x164(%rbp)
jmp 0x4661
leaq 0x6c79(%rip), %rdi      # 0xb4a3
movb $0x0, %al
callq 0x2030
jmp 0x4833
jmp 0x4835
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
nop