// File: wwdatabase[P]database/./smmana/sm.h
// Function: SM_Manager::create_table(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, int*, int*, int*, int, int)
RC SM_Manager::create_table(const char* tablename,string attrname[],int attrtype[],int len[],int isnull[],int attrnum,int prim_key)//create two files
{
	table_entry tb;
	strcpy(tb.tablename,tablename);
	tb.prikeyNum = prim_key;
	tb.attrNum = attrnum;
	int record_size = attrnum/8+1;
	for(int i = 0;i < attrnum;i++)
	{
		switch(attrtype[i])
		{
			case ATTRINT :
				record_size+=4;
				tb.attrName.push_back(attrname[i]);
				tb.attrType.push_back(ATTRINT);
				tb.attrLength.push_back(4);
				tb.isNull.push_back(isnull[i]);
				break;
			case ATTRFLOAT:
				record_size+=4;
				tb.attrName.push_back(attrname[i]);
				tb.attrType.push_back(ATTRFLOAT);
				tb.attrLength.push_back(4);
				tb.isNull.push_back(isnull[i]);
				break;
			case ATTRSTRING:
				record_size+=len[i];
				tb.attrName.push_back(attrname[i]);
				tb.attrType.push_back(ATTRSTRING);
				tb.attrLength.push_back(len[i]);
				tb.isNull.push_back(isnull[i]);
				break;
			default:
				printf("Blackman question mark?\n");
				break;
		}
	}
	tb.recordSize = record_size;
	databases[current_db_index].table.push_back(tb);
	string create_location(databases[current_db_index].dbname);
	create_location  = create_location+"/"+tb.tablename;
	record_manager->createFile(create_location.c_str(),record_size,tb.attrType,tb.attrLength,tb.isNull,tb.prikeyNum);
	create_location  = create_location + ".www";
	//freopen(create_location.c_str(),"w",stdout);
	ofstream file1(create_location.c_str());
	file1 << tb.tablename << endl << tb.attrNum << " " << tb.prikeyNum<<" " <<tb.recordSize<< endl;
	//printf("%s\n%d %d\n",tb.tablename,tb.attrNum,tb.prikeyNum);
	for(int i = 0;i < tb.attrNum;i++)
	{
		file1 << tb.attrName[i] <<" "<<tb.attrType[i] <<" "<<tb.attrLength[i]<<" "<<tb.isNull[i]<< endl;
		//printf("%s %d %d %d\n",tb.attrName[i].c_str(),tb.attrType[i],tb.attrLength[i],tb.isNull[i]);
	}
	file1.close();
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4d0, %rsp            # imm = 0x4D0
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x408(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x6cc0
leaq -0x100(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x21f0
movl 0x18(%rbp), %eax
movl %eax, -0x94(%rbp)
movl 0x10(%rbp), %eax
movl %eax, -0x98(%rbp)
movl 0x10(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
addl $0x1, %eax
movl %eax, -0x104(%rbp)
movl $0x0, -0x108(%rbp)
movl -0x108(%rbp), %eax
cmpl 0x10(%rbp), %eax
jge 0x4728
movq -0x20(%rbp), %rax
movslq -0x108(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40c(%rbp)
subl $0x1, %eax
je 0x454f
jmp 0x452a
movl -0x40c(%rbp), %eax
subl $0x2, %eax
je 0x45ec
jmp 0x453b
movl -0x40c(%rbp), %eax
subl $0x3, %eax
je 0x4672
jmp 0x4700
movl -0x104(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x104(%rbp)
leaq -0x90(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x108(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
callq 0x6780
jmp 0x457e
leaq -0x78(%rbp), %rdi
movl $0x1, -0x118(%rbp)
leaq -0x118(%rbp), %rsi
callq 0x68b0
jmp 0x459a
leaq -0x60(%rbp), %rdi
movl $0x4, -0x11c(%rbp)
leaq -0x11c(%rbp), %rsi
callq 0x68b0
jmp 0x45b6
leaq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rax
movslq -0x108(%rbp), %rcx
leaq (%rax,%rcx,4), %rsi
callq 0x6d20
jmp 0x45d0
jmp 0x4712
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x4c87
movl -0x104(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x104(%rbp)
leaq -0x90(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x108(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
callq 0x6780
jmp 0x461b
leaq -0x78(%rbp), %rdi
movl $0x2, -0x120(%rbp)
leaq -0x120(%rbp), %rsi
callq 0x68b0
jmp 0x4637
leaq -0x60(%rbp), %rdi
movl $0x4, -0x124(%rbp)
leaq -0x124(%rbp), %rsi
callq 0x68b0
jmp 0x4653
leaq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rax
movslq -0x108(%rbp), %rcx
leaq (%rax,%rcx,4), %rsi
callq 0x6d20
jmp 0x466d
jmp 0x4712
movq -0x28(%rbp), %rax
movslq -0x108(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movl -0x104(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x104(%rbp)
leaq -0x90(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x108(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
callq 0x6780
jmp 0x46ae
leaq -0x78(%rbp), %rdi
movl $0x3, -0x128(%rbp)
leaq -0x128(%rbp), %rsi
callq 0x68b0
jmp 0x46ca
leaq -0x60(%rbp), %rdi
movq -0x28(%rbp), %rax
movslq -0x108(%rbp), %rcx
leaq (%rax,%rcx,4), %rsi
callq 0x6d20
jmp 0x46e4
leaq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rax
movslq -0x108(%rbp), %rcx
leaq (%rax,%rcx,4), %rsi
callq 0x6d20
jmp 0x46fe
jmp 0x4712
leaq 0xabb1(%rip), %rdi      # 0xf2b8
xorl %eax, %eax
callq 0x2040
jmp 0x4710
jmp 0x4712
jmp 0x4714
movl -0x108(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x108(%rbp)
jmp 0x4500
movq -0x408(%rbp), %rdi
movl -0x104(%rbp), %eax
movl %eax, -0x9c(%rbp)
movslq 0x18(%rdi), %rsi
callq 0x6c50
movq %rax, %rdi
addq $0x100, %rdi            # imm = 0x100
leaq -0x100(%rbp), %rsi
callq 0x6d90
jmp 0x475c
movq -0x408(%rbp), %rdi
movslq 0x18(%rdi), %rsi
callq 0x6c50
movq %rax, -0x420(%rbp)
leaq -0x149(%rbp), %rdi
movq %rdi, -0x418(%rbp)
callq 0x23d0
movq -0x420(%rbp), %rsi
movq -0x418(%rbp), %rdx
leaq -0x148(%rbp), %rdi
callq 0x61e0
jmp 0x47a2
leaq -0x149(%rbp), %rdi
callq 0x2260
leaq 0xab1c(%rip), %rdx      # 0xf2d1
leaq -0x190(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x6e50
jmp 0x47ca
leaq -0x170(%rbp), %rdi
leaq -0x190(%rbp), %rsi
leaq -0x100(%rbp), %rdx
callq 0x6e00
jmp 0x47e6
leaq -0x148(%rbp), %rdi
movq %rdi, -0x440(%rbp)
leaq -0x170(%rbp), %rsi
movq %rsi, -0x448(%rbp)
callq 0x22b0
movq -0x448(%rbp), %rdi
callq 0x2130
leaq -0x190(%rbp), %rdi
callq 0x2130
movq -0x408(%rbp), %rax
movq -0x440(%rbp), %rdi
movq 0x20(%rax), %rax
movq %rax, -0x438(%rbp)
callq 0x20b0
movq %rax, -0x430(%rbp)
movl -0x104(%rbp), %eax
movl %eax, -0x424(%rbp)
leaq -0x78(%rbp), %rsi
leaq -0x1a8(%rbp), %rdi
callq 0x6ed0
jmp 0x4862
leaq -0x60(%rbp), %rsi
leaq -0x1c0(%rbp), %rdi
callq 0x6ed0
jmp 0x4874
leaq -0x48(%rbp), %rsi
leaq -0x1d8(%rbp), %rdi
callq 0x6ed0
jmp 0x4886
movl -0x424(%rbp), %edx
movq -0x430(%rbp), %rsi
movq -0x438(%rbp), %rdi
movl -0x94(%rbp), %ecx
movq %rsp, %rax
movl %ecx, (%rax)
leaq -0x1a8(%rbp), %rcx
leaq -0x1c0(%rbp), %r8
leaq -0x1d8(%rbp), %r9
callq 0x3300
jmp 0x48c1
leaq -0x1d8(%rbp), %rdi
callq 0x5f90
leaq -0x1c0(%rbp), %rdi
callq 0x5f90
leaq -0x1a8(%rbp), %rdi
callq 0x5f90
leaq 0xa9e7(%rip), %rdx      # 0xf2d3
leaq -0x1f8(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x6e50
jmp 0x4901
leaq -0x148(%rbp), %rdi
movq %rdi, -0x450(%rbp)
leaq -0x1f8(%rbp), %rsi
movq %rsi, -0x458(%rbp)
callq 0x22b0
movq -0x458(%rbp), %rdi
callq 0x2130
movq -0x450(%rbp), %rdi
callq 0x20b0
movq %rax, %rsi
leaq -0x3f8(%rbp), %rdi
movl $0x10, %edx
callq 0x2270
jmp 0x4950
leaq -0x3f8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x2200
movq %rax, -0x460(%rbp)
jmp 0x496c
movq -0x460(%rbp), %rdi
movq 0x1164e(%rip), %rsi     # 0x15fc8
callq 0x2240
movq %rax, -0x468(%rbp)
jmp 0x4988
movq -0x468(%rbp), %rdi
movl -0x98(%rbp), %esi
callq 0x23b0
movq %rax, -0x470(%rbp)
jmp 0x49a3
movq -0x470(%rbp), %rdi
leaq 0xa68f(%rip), %rsi      # 0xf040
callq 0x2200
movq %rax, -0x478(%rbp)
jmp 0x49bf
movq -0x478(%rbp), %rdi
movl -0x94(%rbp), %esi
callq 0x23b0
movq %rax, -0x480(%rbp)
jmp 0x49da
movq -0x480(%rbp), %rdi
leaq 0xa658(%rip), %rsi      # 0xf040
callq 0x2200
movq %rax, -0x488(%rbp)
jmp 0x49f6
movq -0x488(%rbp), %rdi
movl -0x9c(%rbp), %esi
callq 0x23b0
movq %rax, -0x490(%rbp)
jmp 0x4a11
movq -0x490(%rbp), %rdi
movq 0x115a9(%rip), %rsi     # 0x15fc8
callq 0x2240
jmp 0x4a26
movl $0x0, -0x3fc(%rbp)
movl -0x3fc(%rbp), %eax
cmpl -0x98(%rbp), %eax
jge 0x4c3e
leaq -0x90(%rbp), %rdi
movslq -0x3fc(%rbp), %rsi
callq 0x6fc0
movq %rax, %rsi
leaq -0x3f8(%rbp), %rdi
callq 0x21e0
movq %rax, -0x498(%rbp)
jmp 0x4a6d
movq -0x498(%rbp), %rdi
leaq 0xa5c5(%rip), %rsi      # 0xf040
callq 0x2200
movq %rax, -0x4a0(%rbp)
jmp 0x4a89
leaq -0x78(%rbp), %rdi
movslq -0x3fc(%rbp), %rsi
callq 0x6670
movq -0x4a0(%rbp), %rdi
movl (%rax), %esi
callq 0x23b0
movq %rax, -0x4a8(%rbp)
jmp 0x4ab0
movq -0x4a8(%rbp), %rdi
leaq 0xa582(%rip), %rsi      # 0xf040
callq 0x2200
movq %rax, -0x4b0(%rbp)
jmp 0x4acc
leaq -0x60(%rbp), %rdi
movslq -0x3fc(%rbp), %rsi
callq 0x6670
movq -0x4b0(%rbp), %rdi
movl (%rax), %esi
callq 0x23b0
movq %rax, -0x4b8(%rbp)
jmp 0x4af3
movq -0x4b8(%rbp), %rdi
leaq 0xa53f(%rip), %rsi      # 0xf040
callq 0x2200
movq %rax, -0x4c0(%rbp)
jmp 0x4b0f
leaq -0x48(%rbp), %rdi
movslq -0x3fc(%rbp), %rsi
callq 0x6670
movq -0x4c0(%rbp), %rdi
movl (%rax), %esi
callq 0x23b0
movq %rax, -0x4c8(%rbp)
jmp 0x4b36
movq -0x4c8(%rbp), %rdi
movq 0x11484(%rip), %rsi     # 0x15fc8
callq 0x2240
jmp 0x4b4b
jmp 0x4b4d
movl -0x3fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3fc(%rbp)
jmp 0x4a30
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
leaq -0x149(%rbp), %rdi
callq 0x2260
jmp 0x4c87
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x4c7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x2130
jmp 0x4c7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x4c10
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
jmp 0x4c04
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x5f90
leaq -0x1c0(%rbp), %rdi
callq 0x5f90
leaq -0x1a8(%rbp), %rdi
callq 0x5f90
jmp 0x4c7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x110(%rbp)
movl %eax, -0x114(%rbp)
leaq -0x3f8(%rbp), %rdi
callq 0x2340
jmp 0x4c7b
leaq -0x3f8(%rbp), %rdi
callq 0x2310
jmp 0x4c4c
leaq -0x3f8(%rbp), %rdi
callq 0x2340
leaq -0x148(%rbp), %rdi
callq 0x2130
leaq -0x100(%rbp), %rdi
callq 0x6fe0
xorl %eax, %eax
addq $0x4d0, %rsp            # imm = 0x4D0
popq %rbp
retq
leaq -0x148(%rbp), %rdi
callq 0x2130
leaq -0x100(%rbp), %rdi
callq 0x6fe0
movq -0x110(%rbp), %rdi
callq 0x23c0
nop