// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x2250
movq %rax, %r12
movq 0x6502(%rip), %r15      # 0x8fd0
leaq 0x375c(%rip), %rsi      # 0x6231
pushq $0x1c
popq %rdx
movq %r15, %rdi
callq 0x21e0
movq 0x64f9(%rip), %rbx      # 0x8fe0
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $-0x3e9, %r14           # imm = 0xFC17
addq 0x10(%rbx,%rax), %r14
movl $0x3e8, %edx            # imm = 0x3E8
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2320
movq (%rbx), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x20(%rbx,%rax)
jne 0x2b37
cmpq $-0x3e9, %r14           # imm = 0xFC17
ja 0x2b37
movq 0xe8(%rbx,%rax), %rdi
movq 0x10(%rdi), %rax
cmpq 0x18(%rdi), %rax
jae 0x2d76
movq %r12, %rdi
callq 0x4079
testl %eax, %eax
je 0x2d57
movl $0x420, %edi            # imm = 0x420
callq 0x2250
movq %rax, %r14
leaq 0x3fbb(%rip), %rdi      # 0x6b16
callq 0x22d0
leaq 0x3d1a(%rip), %rsi      # 0x6881
movq %r12, %rdi
callq 0x3c5a
testq %rax, %rax
je 0x2d48
movq %rax, %rbx
movq %r12, 0x10(%rsp)
pushq $0x1
popq %rsi
movl $0x420, %edx            # imm = 0x420
movq %r14, %rdi
movq %rax, %rcx
callq 0x22b0
movslq 0x3e0(%r14), %r13
testq %r13, %r13
jle 0x2bd2
leaq 0x7c(%r14), %r12
movq %r12, %rdi
callq 0x20b0
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rax
movq $0x14, 0x10(%r15,%rax)
addq $0x1c, %r12
decq %r13
jne 0x2ba3
movq %rbx, %rdi
callq 0x2190
movq 0x63ef(%rip), %r15      # 0x8fd0
leaq 0x373a(%rip), %rsi      # 0x6322
pushq $0x1
popq %rdx
movq %r15, %rdi
callq 0x21e0
leaq 0x3f1d(%rip), %rdi      # 0x6b17
callq 0x22d0
cmpl $0x0, 0x418(%r14)
jle 0x2d3c
movq %r14, %rax
addq $0x90, %rax
movq %rax, 0x8(%rsp)
leaq 0x20(%rsp), %rbp
xorl %ebx, %ebx
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x2250
movq %rax, %r12
movq %rax, %rdi
leaq 0x3515(%rip), %rsi      # 0x614e
movq 0x10(%rsp), %rdx
movl %ebx, (%rsp)
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2040
movq %r12, 0x18(%rsp)
movq %r12, %rdi
leaq 0x3c28(%rip), %rsi      # 0x6881
callq 0x2200
movq %rax, %r13
cmpl $0x0, 0x3e0(%r14)
jle 0x2d06
movq 0x8(%rsp), %r12
xorl %ebx, %ebx
movl (%r12), %eax
cmpl $0x2, %eax
je 0x2cb3
cmpl $0x1, %eax
jne 0x2cef
leaq 0x4(%rsp), %rdi
pushq $0x1
popq %rsi
pushq $0x4
popq %rdx
movq %r13, %rcx
callq 0x22b0
movl 0x4(%rsp), %esi
movq %r15, %rdi
callq 0x2330
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
addq %rcx, %rax
addq $0x10, %rax
jmp 0x2ce8
movq %rbp, %rdi
pushq $0x1
popq %rsi
pushq $0x32
popq %rdx
movq %r13, %rcx
callq 0x22b0
movq %rbp, %rdi
callq 0x20b0
movq %r15, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rax
addq %r15, %rax
addq $0x10, %rax
movq $0x14, (%rax)
incq %rbx
movslq 0x3e0(%r14), %rax
addq $0x1c, %r12
cmpq %rax, %rbx
jl 0x2c76
movq %r15, %rdi
leaq 0x3611(%rip), %rsi      # 0x6321
pushq $0x2
popq %rdx
callq 0x21e0
movq 0x18(%rsp), %rdi
callq 0x2210
movq %r13, %rdi
callq 0x2190
movl (%rsp), %ebx
incl %ebx
cmpl 0x418(%r14), %ebx
jl 0x2c22
leaq 0x3dd4(%rip), %rdi      # 0x6b17
callq 0x22d0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3658(%rip), %rdi      # 0x63b6
movq %r12, %rsi
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2030
movq (%rdi), %rax
callq *0x48(%rax)
cmpl $-0x1, %eax
jne 0x2b37
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x2, %esi
callq 0x2310
jmp 0x2b37