// File: Alcaro[P]bridges/arlib/staticmap.cpp
// Function: staticmap::create()
void staticmap::create()
{
	mmap = nullptr;
	uint8_t buf[off_r_objsize + 512];
	
	writeu_le64(buf+off_header, off_r_objsize+t_meta);
	writeu_le64(buf+off_r_sig, sig_active);
	writeu_le64(buf+off_r_hm_ptr, 512); // hashmap pointer
	writeu_le64(buf+off_r_hm_load, 0); // number of used hashmap slots
	writeu_le64(buf+off_r_entries, 0); // number of object members
	for (int i=5;i<=9;i++) writeu_le64(buf+off_r_freespace(i), 0); // no freespaces of size 32 to 512
	for (int i=10;i<=15;i++) writeu_le64(buf+off_r_freespace(i), 1<<i); // have freespaces of size 1024 to 32768
	for (int i=16;i<=63;i++) writeu_le64(buf+off_r_freespace(i), 1); // no freespaces of size 65536 to 9223372036854775808
	
	writeu_le64(buf+512, 512+t_meta); // hashmap header
	for (int i=2;i<=63;i++) writeu_le64(buf+512+i*8, 0); // fill the hashmap
	f.pwrite(0, buf);
	
	f.resize(65536, mmap, map_writable);
	
	for (int i=10;i<=15;i++)
		wr64(1<<i, (1<<i)+t_free, 0, off_r_freespace(i)); // header, next_obj, prev_ptr
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x520, %rsp            # imm = 0x520
movq %rdi, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
movq %rdi, -0x4e0(%rbp)
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x35440
leaq -0x4b0(%rbp), %rax
movq %rax, -0x8(%rbp)
movq $0x202, -0x10(%rbp)     # imm = 0x202
movq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x4b0(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x18(%rbp)
movabsq $0x170616d736c7261, %rax # imm = 0x170616D736C7261
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x4b0(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x28(%rbp)
movq $0x200, -0x30(%rbp)     # imm = 0x200
movq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x4b0(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x4b0(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, (%rax)
movl $0x5, -0x4b4(%rbp)
cmpl $0x9, -0x4b4(%rbp)
jg 0x32d9b
leaq -0x4b0(%rbp), %rax
movq %rax, -0x4e8(%rbp)
movslq -0x4b4(%rbp), %rdi
callq 0x336d0
movq %rax, %rcx
movq -0x4e8(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
movq -0x60(%rbp), %rcx
movq %rcx, (%rax)
movl -0x4b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4b4(%rbp)
jmp 0x32d3b
movl $0xa, -0x4b8(%rbp)
cmpl $0xf, -0x4b8(%rbp)
jg 0x32e1e
leaq -0x4b0(%rbp), %rax
movq %rax, -0x4f8(%rbp)
movslq -0x4b8(%rbp), %rdi
callq 0x336d0
movq %rax, %rcx
movq -0x4f8(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x4f0(%rbp)
movl -0x4b8(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movq -0x4f0(%rbp), %rcx
cltq
movq %rcx, -0x68(%rbp)
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
movq -0x70(%rbp), %rcx
movq %rcx, (%rax)
movl -0x4b8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4b8(%rbp)
jmp 0x32da5
movl $0x10, -0x4bc(%rbp)
cmpl $0x3f, -0x4bc(%rbp)
jg 0x32e88
leaq -0x4b0(%rbp), %rax
movq %rax, -0x500(%rbp)
movslq -0x4bc(%rbp), %rdi
callq 0x336d0
movq %rax, %rcx
movq -0x500(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq $0x1, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, (%rax)
movl -0x4bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4bc(%rbp)
jmp 0x32e28
leaq -0x4b0(%rbp), %rax
addq $0x200, %rax            # imm = 0x200
movq %rax, -0x88(%rbp)
movq $0x202, -0x90(%rbp) # imm = 0x202
movq -0x90(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rax
movq -0x90(%rbp), %rcx
movq %rcx, (%rax)
movl $0x2, -0x4c0(%rbp)
cmpl $0x3f, -0x4c0(%rbp)
jg 0x32f37
leaq -0x4b0(%rbp), %rax
addq $0x200, %rax            # imm = 0x200
movl -0x4c0(%rbp), %ecx
shll $0x3, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq $0x0, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rax
movq -0xa0(%rbp), %rcx
movq %rcx, (%rax)
movl -0x4c0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c0(%rbp)
jmp 0x32ed0
movq -0x4e0(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x508(%rbp)
leaq -0x4d0(%rbp), %rdi
leaq -0x4b0(%rbp), %rsi
callq 0x354d0
movq -0x508(%rbp), %rdi
movq -0x4d0(%rbp), %rdx
movq -0x4c8(%rbp), %rcx
xorl %eax, %eax
movl %eax, %esi
callq 0x35470
movq -0x4e0(%rbp), %rax
movq %rax, %rdi
addq $0x4, %rdi
movq %rax, %rdx
addq $0x8, %rdx
movb 0x18(%rax), %al
movl $0x10000, %esi          # imm = 0x10000
andb $0x1, %al
movzbl %al, %ecx
callq 0x35500
movl $0xa, -0x4d4(%rbp)
cmpl $0xf, -0x4d4(%rbp)
jg 0x33020
movl -0x4d4(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
cltq
movq %rax, -0x518(%rbp)
movl -0x4d4(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
cltq
addq $0x0, %rax
movq %rax, -0x510(%rbp)
movslq -0x4d4(%rbp), %rdi
callq 0x336d0
movq -0x4e0(%rbp), %rdi
movq -0x518(%rbp), %rsi
movq -0x510(%rbp), %rdx
movq %rax, %r8
xorl %ecx, %ecx
callq 0x35540
movl -0x4d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4d4(%rbp)
jmp 0x32fab
addq $0x520, %rsp            # imm = 0x520
popq %rbp
retq
nopl (%rax)