LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/strtoken.cpp
// Function: strtoken(char const*, char const*, char)
bool strtoken(const char * haystack, const char * needle, char separator)
{
	//token lists are annoyingly complex to parse
	//I suspect 'people using fixed-size buffers, then extension list grows and app explodes'
	// isn't the only reason GL_EXTENSIONS string was deprecated from OpenGL
	size_t nlen = strlen(needle);
	
	while (true)
	{
		const char * found = strstr(haystack, needle);
		if (!found) break;
		
		if ((found==haystack || found[-1]==separator) && // ensure the match is the start of a word
				(found[nlen]==separator || found[nlen]=='\0')) // ensure the match is the end of a word
		{
			return true;
		}
		
		haystack = strchr(found, separator); // try again, could've found GL_foobar_limited when looking for GL_foobar
		if (!haystack) return false;
	}
	return false;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r12
movq %rsi, %rdi
callq 0x30f0
movq %rax, %r15
movq %r12, %rdi
movq %r14, %rsi
callq 0x30b0
testq %rax, %rax
je 0x1704d
cmpq %r12, %rax
je 0x1702d
cmpb %bl, -0x1(%rax)
jne 0x1703b
movb (%rax,%r15), %dl
movb $0x1, %cl
cmpb %bl, %dl
je 0x1704f
testb %dl, %dl
je 0x1704f
movq %rax, %rdi
movl %ebx, %esi
callq 0x30e0
movq %rax, %r12
testq %rax, %rax
jne 0x17013
xorl %ecx, %ecx
movl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/test.cpp
// Function: tostringhex_dbg(arrayview<unsigned char> const&)
string tostringhex_dbg(const arrayview<uint8_t>& item)
{
	string ret;
	for (size_t outer=0;outer<item.size();outer+=16)
	{
		ret += tostringhex<8>(outer)+"  ";
		for (size_t inner=0;inner<16;inner++)
		{
			if (inner == 8) ret += " ";
			if (outer+inner >= item.size()) ret += "   ";
			else ret += tostringhex<2>(item[outer+inner])+" ";
		}
		ret += " ";
		for (size_t inner=0;inner<16;inner++)
		{
			if (outer+inner >= item.size()) ret += " ";
			else
			{
				char c = item[outer+inner];
				if (c >= 0x20 && c <= 0x7e) ret += c;
				else ret += '.';
			}
		}
		ret += "\n";
	}
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movb $0xf, 0xf(%rdi)
movb $0x0, (%rdi)
xorl %r15d, %r15d
leaq 0x18(%rsp), %r12
leaq 0x8(%rsp), %r13
cmpq 0x8(%r14), %r15
jae 0x171cb
movq %r12, %rdi
movq %r15, %rsi
callq 0x171dd
movq %r13, %rdi
movq %r12, %rsi
leaq 0x119d1(%rip), %rdx     # 0x28a7b
callq 0x418a
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x4296
movq %r13, %rdi
callq 0x56b4
movq %r12, %rdi
callq 0x56b4
xorl %ebp, %ebp
cmpq $0x8, %rbp
je 0x170e1
cmpq $0x10, %rbp
jne 0x170f0
jmp 0x1715a
movq %rbx, %rdi
leaq 0x11991(%rip), %rsi     # 0x28a7c
callq 0x426a
leaq (%r15,%rbp), %rax
cmpq 0x8(%r14), %rax
jae 0x17143
movq (%r14), %rax
addq %r15, %rax
movzbl (%rbp,%rax), %esi
movq %r12, %rdi
callq 0x5fb3
movq %r13, %rdi
movq %r12, %rsi
leaq 0x11962(%rip), %rdx     # 0x28a7c
callq 0x418a
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x4296
movq %r13, %rdi
callq 0x56b4
movq %r12, %rdi
callq 0x56b4
jmp 0x17152
movq %rbx, %rdi
leaq 0x1192d(%rip), %rsi     # 0x28a7a
callq 0x426a
incq %rbp
jmp 0x170d3
movq %rbx, %rdi
leaq 0x11918(%rip), %rsi     # 0x28a7c
callq 0x426a
movq %r15, %rbp
pushq $0x10
popq %r13
subq $0x1, %r13
jb 0x171b3
cmpq 0x8(%r14), %rbp
jae 0x17192
movq (%r14), %rax
movb (%rax,%rbp), %al
leal -0x20(%rax), %ecx
cmpb $0x5e, %cl
ja 0x171a3
movzbl %al, %esi
movq %rbx, %rdi
jmp 0x171a9
movq %rbx, %rdi
leaq 0x118e0(%rip), %rsi     # 0x28a7c
callq 0x426a
jmp 0x171ae
movq %rbx, %rdi
pushq $0x2e
popq %rsi
callq 0x4354
incq %rbp
jmp 0x17170
movq %rbx, %rdi
leaq 0x1172a(%rip), %rsi     # 0x288e7
callq 0x426a
addq $0x10, %r15
jmp 0x17083
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/thread/pthread-thr.cpp
// Function: thread_create(function<void ()>&&, priority_t)
void thread_create(function<void()>&& start, priority_t pri)
{
	pthread_attr_t attr;
	if (pthread_attr_init(&attr) < 0) abort();
	
	sched_param sched;
	if (pthread_attr_getschedparam(&attr, &sched) >= 0)
	{
		static const int8_t prios[] = { 0, -10, 10, 19 };
		sched.sched_priority = prios[pri];
		pthread_attr_setschedparam(&attr, &sched);
	}
	
	thread_create_inner(std::move(start), &attr);
	pthread_attr_destroy(&attr);
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x48, %rsp
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3450
testl %eax, %eax
js 0x17319
leaq 0x10(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x3710
testl %eax, %eax
js 0x172c6
movl %ebp, %eax
leaq 0x11c57(%rip), %rcx     # 0x28f08
movsbl (%rax,%rcx), %eax
leaq 0x4(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x3160
pushq $0x18
popq %rdi
callq 0x11544
movups (%rbx), %xmm0
movups %xmm0, (%rax)
movq 0x10(%rbx), %rcx
movq %rcx, 0x10(%rax)
andq $0x0, 0x10(%rbx)
leaq 0x84(%rip), %rdx        # 0x1736c
leaq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rax, %rcx
callq 0x36b0
testl %eax, %eax
jne 0x17319
movq 0x8(%rsp), %rdi
callq 0x3220
leaq 0x10(%rsp), %rdi
callq 0x3630
addq $0x48, %rsp
popq %rbx
popq %rbp
retq
callq 0x3180
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/thread/pthread-thr.cpp
// Function: mutex_rec::mutex_rec()
mutex_rec::mutex_rec() : mutex(noinit())
{
	pthread_mutexattr_t attr;
	pthread_mutexattr_init(&attr);
	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
	pthread_mutex_init(&mut, &attr);
	pthread_mutexattr_destroy(&attr);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x4(%rsp), %r14
movq %r14, %rdi
callq 0x3060
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x3540
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3560
movq %r14, %rdi
callq 0x3550
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/zip.cpp
// Function: zip::getendofcdr(arrayview<unsigned char>)
zip::endofcdr* zip::getendofcdr(arrayview<uint8_t> data)
{
	//must be somewhere in zip::, they're private
	static_assert(sizeof(zip::locfhead)==30);
	static_assert(sizeof(zip::centdirrec)==46);
	static_assert(sizeof(zip::endofcdr)==22);
	
	for (size_t commentlen=0;commentlen<65536;commentlen++)
	{
		if (data.size() < sizeof(endofcdr)+commentlen) return nullptr;
		
		size_t trystart = data.size()-sizeof(endofcdr)-commentlen;
		endofcdr* ret = (endofcdr*)data.slice(trystart, sizeof(endofcdr)).ptr();
		if (ret->signature == ret->signature_expected)
		{
			if (ret->diskid_this != 0) return nullptr;
			return ret;
		}
	}
	
	return nullptr;
}

// Assembly:
leaq (%rdx,%rsi), %rdi
addq $-0x11, %rdi
xorl %eax, %eax
xorl %r9d, %r9d
cmpq $0xffff, %r9            # imm = 0xFFFF
ja 0x174c2
movq %r9, %rcx
addq $0x16, %r9
cmpq %rdx, %r9
ja 0x174c2
leaq -0x1(%rdi), %r8
addq $-0x15, %r9
cmpl $0x6054b50, -0x5(%rdi)  # imm = 0x6054B50
movq %r8, %rdi
jne 0x17481
incq %rcx
addq %rsi, %rdx
subq %rcx, %rdx
addq $-0x15, %rdx
xorl %eax, %eax
cmpw $0x0, (%r8)
cmoveq %rdx, %rax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/zip.cpp
// Function: zip::replace_idx(unsigned long, arrayview<unsigned char>, long)
void zip::replace_idx(size_t id, arrayview<uint8_t> data, time_t date)
{
	if (!data)
	{
		filenames.remove(id);
		filedat.remove(id);
		return;
	}
	
	file& f = filedat[id];
	f.decomplen = data.size();
	f.crc32 = crc32(data);
	if (date) f.dosdate = todosdate(date); // else leave unchanged, or leave as 0
	
	array<uint8_t> comp;
	comp.resize(data.size());
	size_t complen = tdefl_compress_mem_to_mem(comp.ptr(), comp.size(), data.ptr(), data.size(), TDEFL_DEFAULT_MAX_PROBES);
	if (complen != 0 && complen < data.size())
	{
		comp.resize(complen);
		f.method = 8;
		f.data = std::move(comp);
	}
	else
	{
		f.method = 0;
		f.data = data;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r12
movq %rdi, %r14
testq %rcx, %rcx
je 0x17ce4
movq %r8, %r13
movq %rcx, %rbx
movq %rdx, %r15
movq 0x10(%r14), %rbp
shlq $0x5, %r12
leaq (%r12,%rbp), %r14
movl %ebx, (%rbp,%r12)
movq %rdx, %rdi
movq %rcx, %rsi
callq 0x17795
movl %eax, 0x18(%rbp,%r12)
testq %r13, %r13
je 0x17c72
leaq 0x8(%rsp), %rdi
movq %r13, (%rdi)
leaq 0x10(%rsp), %r12
movq %r12, %rsi
callq 0x3720
movl 0x14(%r12), %eax
movl 0x10(%r12), %ecx
movl 0xc(%r12), %edx
movl 0x8(%r12), %esi
movl (%r12), %edi
movl 0x4(%r12), %r8d
shll $0x19, %eax
addl $0x60000000, %eax       # imm = 0x60000000
shll $0x15, %ecx
addl $0x200000, %ecx         # imm = 0x200000
orl %eax, %ecx
shll $0x10, %edx
shll $0xb, %esi
orl %edx, %esi
shll $0x5, %r8d
orl %esi, %r8d
orl %ecx, %r8d
sarl %edi
orl %r8d, %edi
movl %edi, 0x1c(%r14)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r12
movaps %xmm0, (%r12)
movq %r12, %rdi
movq %rbx, %rsi
callq 0xbaee
movq (%r12), %rdi
movq 0x8(%r12), %rsi
movq %r15, %rdx
movq %rbx, %rcx
movl $0x80, %r8d
callq 0x262f0
testq %rax, %rax
sete %cl
cmpq %rbx, %rax
setae %dl
orb %cl, %dl
jne 0x17d0c
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0xbaee
movw $0x8, 0x4(%r14)
movaps (%rbx), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, (%rbx)
movq 0x8(%r14), %rdi
movups %xmm0, 0x8(%r14)
callq 0x3430
jmp 0x17d24
movq %r14, %rdi
movq %r12, %rsi
callq 0xf35a
addq $0x10, %r14
movq %r14, %rdi
movq %r12, %rsi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x18368
andw $0x0, 0x4(%r14)
addq $0x8, %r14
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xbd3a
movq 0x10(%rsp), %rdi
callq 0x3430
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/zip.cpp
// Function: zip::write(cstring, arrayview<unsigned char>, long)
void zip::write(cstring name, arrayview<uint8_t> data, time_t date)
{
	size_t id = find_file(name);
	
	if (id == (size_t)-1)
	{
		if (!data) return;
		
		id = filenames.size();
		filenames.append(name);
		filedat.append();
		if (!date) date = time(NULL);
	}
	
	replace_idx(id, data, date);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r15
movq %r8, %rbx
movq %rcx, (%rsp)
movq %rdx, %rbp
movq %rsi, %r14
movq %rdi, %r12
callq 0x1795a
cmpq $-0x1, %rax
je 0x17d91
movq %rax, %r13
movq %r12, %rdi
movq %r13, %rsi
movq (%rsp), %rdx
movq %rbx, %rcx
movq %r15, %r8
callq 0x17bc6
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rbx, %rbx
je 0x17d82
movq 0x8(%r12), %r13
leaq 0x18(%rsp), %rsi
movq %r14, (%rsi)
movq %rbp, 0x8(%rsi)
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x14754
movq %r12, %rdi
movq %r14, %rsi
callq 0xf338
movq %r14, %rdi
callq 0x56b4
leaq 0x10(%r12), %rdi
callq 0x183c0
testq %r15, %r15
jne 0x17d6d
xorl %edi, %edi
callq 0x3310
movq %rax, %r15
jmp 0x17d6d
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/zip.cpp
// Function: zip::clean()
bool zip::clean()
{
	bool any = false;
	for (size_t i=0;i<filenames.size();i++)
	{
		if (filenames[i].startswith("__MACOSX/") || filenames[i].endswith("/.DS_Store") || filenames[i].iendswith("/thumbs.db"))
		{
			filenames.remove(i);
			filedat.remove(i);
			i--;
			any = true;
		}
	}
	return any;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq 0x10(%rdi), %r14
xorl %ebp, %ebp
xorl %r15d, %r15d
cmpq 0x8(%rbx), %r15
jae 0x17f0d
movq %r15, %r13
shlq $0x4, %r13
movq (%rbx), %r12
addq %r13, %r12
leaq 0x28(%rsp), %rdi
leaq 0x110e1(%rip), %rsi     # 0x28f58
callq 0x42ce
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %r12, %rdi
callq 0x14a3e
testb %al, %al
jne 0x17ee9
movq (%rbx), %r12
addq %r13, %r12
leaq 0x18(%rsp), %rdi
leaq 0x110be(%rip), %rsi     # 0x28f62
callq 0x42ce
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %r12, %rdi
callq 0x14a9e
testb %al, %al
jne 0x17ee9
addq (%rbx), %r13
leaq 0x8(%rsp), %rdi
leaq 0x1109f(%rip), %rsi     # 0x28f6d
callq 0x42ce
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r13, %rdi
callq 0x14cfe
testb %al, %al
je 0x17f05
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf35a
movq %r14, %rdi
movq %r15, %rsi
callq 0x18368
decq %r15
movb $0x1, %bpl
incq %r15
jmp 0x17e54
andb $0x1, %bpl
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/zip.cpp
// Function: zip::repack()
void zip::repack()
{
	for (size_t i=0;i<filedat.size();i++)
	{
		array<uint8_t> data = read_idx(i);
		if (!data) continue;
		
		file& f = filedat[i];
		array<uint8_t> comp;
		comp.resize(data.size());
		size_t complen = tdefl_compress_mem_to_mem(comp.ptr(), comp.size(), data.ptr(), data.size(), TDEFL_DEFAULT_MAX_PROBES);
		if (complen != 0 && complen < f.data.size())
		{
			comp.resize(complen);
			f.method = 8;
			f.data = std::move(comp);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
pushq $0x10
popq %r13
xorl %r14d, %r14d
leaq 0x18(%rsp), %r15
movq %rsp, %r12
cmpq 0x18(%rbx), %r14
jae 0x17ff0
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x183ca
movq 0x20(%rsp), %rsi
testq %rsi, %rsi
je 0x17fda
movq 0x10(%rbx), %rbp
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq %r12, %rdi
callq 0xbaee
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rcx
movl $0x80, %r8d
callq 0x262f0
testq %rax, %rax
je 0x17fd1
cmpq (%rbp,%r13), %rax
jae 0x17fd1
movq %r12, %rdi
movq %rax, %rsi
callq 0xbaee
movw $0x8, -0xc(%rbp,%r13)
movaps (%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, (%rsp)
movq -0x8(%rbp,%r13), %rdi
movups %xmm0, -0x8(%rbp,%r13)
callq 0x3430
movq (%rsp), %rdi
callq 0x3430
movq 0x18(%rsp), %rdi
callq 0x3430
incq %r14
addq $0x20, %r13
jmp 0x17f42
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/zip.cpp
// Function: zip::sort()
void zip::sort()
{
	for (size_t a=0;a<filenames.size();a++)
	{
		size_t b;
		for (b=0;b<a;b++)
		{
			if (string::less(filenames[a], filenames[b])) break;
		}
		filenames.swap(a, b);
		filedat.swap(a, b);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x10(%rdi), %r14
xorl %r15d, %r15d
cmpq 0x8(%rbx), %r15
jae 0x18079
movq %r15, %rbp
shlq $0x4, %rbp
pushq $0x8
popq %r13
xorl %r12d, %r12d
cmpq %r12, %r15
je 0x18055
movq (%rbx), %rax
movq (%rax,%rbp), %rdi
movq 0x8(%rax,%rbp), %rsi
movq -0x8(%rax,%r13), %rdx
movq (%rax,%r13), %rcx
callq 0x113b8
testb %al, %al
jne 0x18058
incq %r12
addq $0x10, %r13
jmp 0x18029
movq %r15, %r12
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xf040
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x18628
incq %r15
jmp 0x18015
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/zlibhead.cpp
// Function: inflator::zlibhead::adler32(arrayview<unsigned char>, unsigned int)
uint32_t inflator::zlibhead::adler32(bytesr by, uint32_t adler_prev)
{
	// could simd this, but not much point, it's not a bottleneck
	uint32_t a = adler_prev&0xFFFF;
	uint32_t b = adler_prev>>16;
	
	size_t i = 0;
	while (i < (by.size()&~4095)) // 5552 is safe, but 4096 is easier to deal with
	{
		do {
			a += by[i++]; b += a;
			a += by[i++]; b += a;
			a += by[i++]; b += a;
			a += by[i++]; b += a;
		} while (i&4095);
		a %= 65521;
		b %= 65521;
	}
	while (i < (by.size()&~3))
	{
		a += by[i++]; b += a;
		a += by[i++]; b += a;
		a += by[i++]; b += a;
		a += by[i++]; b += a;
	}
	while (i < by.size())
	{
		a += by[i++];
		b += a;
	}
	a %= 65521;
	b %= 65521;
	
	return a | (b<<16);
}

// Assembly:
movl %edx, %ecx
movzwl %cx, %r8d
shrl $0x10, %ecx
movq %rsi, %r10
andq $-0x1000, %r10          # imm = 0xF000
xorl %r9d, %r9d
movl $0xfff1, %r11d          # imm = 0xFFF1
cmpq %r10, %r9
jae 0x186e1
movzbl (%rdi,%r9), %eax
addl %r8d, %eax
addl %eax, %ecx
movzbl 0x1(%rdi,%r9), %edx
addl %eax, %edx
addl %edx, %ecx
movzbl 0x2(%rdi,%r9), %eax
addl %edx, %eax
addl %eax, %ecx
movzbl 0x3(%rdi,%r9), %r8d
addq $0x4, %r9
addl %eax, %r8d
addl %r8d, %ecx
testw $0xfff, %r9w            # imm = 0xFFF
jne 0x18695
movl %r8d, %eax
xorl %edx, %edx
divl %r11d
movl %edx, %r8d
movl %ecx, %eax
xorl %edx, %edx
divl %r11d
movl %edx, %ecx
jmp 0x18690
movq %rsi, %rax
andq $-0x4, %rax
cmpq %rax, %r9
jae 0x1872f
movzbl (%rdi,%r9), %edx
addl %edx, %r8d
addl %r8d, %ecx
movzbl 0x1(%rdi,%r9), %edx
addl %r8d, %edx
addl %edx, %ecx
movzbl 0x2(%rdi,%r9), %r10d
addl %edx, %r10d
addl %r10d, %ecx
movzbl 0x3(%rdi,%r9), %r8d
addq $0x4, %r9
addl %r10d, %r8d
addl %r8d, %ecx
jmp 0x186e8
movzbl (%rdi,%r9), %eax
incq %r9
addl %eax, %r8d
addl %r8d, %ecx
cmpq %rsi, %r9
jb 0x18721
movl $0xfff1, %edi           # imm = 0xFFF1
movl %r8d, %eax
xorl %edx, %edx
divl %edi
movl %edx, %esi
movl %ecx, %eax
xorl %edx, %edx
divl %edi
shll $0x10, %edx
orl %edx, %esi
movl %esi, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/zlibhead.cpp
// Function: inflator::zlibhead::inflate()
inflator::ret_t inflator::zlibhead::inflate()
{
	if (inf.m_state >= 254)
	{
	process_tail:
		inf.bits_refill_fast();
		if (inf.m_in_nbits < 32) return ret_more_input; // state 254 only needs 16 bits, but the other 16 will be used soon anyways
		if (inf.m_state == 254) // zlib header
		{
			uint32_t head = inf.bits_extract(16);
			if ((head&0x000F) != 0x0008 || // CMF.CF == DEFLATE (ZIP supports 8=DEFLATE and 0=uncompressed, but zlib only supports 8)
			// ignore 00F0 CMF.CINFO, inflator ignores window size (and it's almost always 7, the maximum)
			// ignore C000 FLG.FLEVEL, it's just informational, and there are too many compressors for it to make sense anymore
			    (head&0x2000) != 0x0000 || // FLG.FDICT, not supported
			    (__builtin_bswap16(head)%31) != 0) return ret_error; // FLG.FCHECK (1F00 bits), must be a multiple of 31
			// (are both 0 and 31 allowed in FCHECK if 0 is the correct checksum? I think they are)
			
			inf.m_state = 0;
		}
		else // zlib footer
		{
			inf.m_in_bits_buf >>= inf.m_in_nbits&7;
			inf.m_in_nbits &= ~7;
			uint32_t adler_head = __builtin_bswap32(inf.bits_extract(32)); // zlib header is big endian, even though DEFLATE is little...
			if (adler_head != adler) return ret_error;
			return ret_done;
		}
	}
	
	const uint8_t * out_prev = inf.m_out_at;
	ret_t ret = inf.inflate();
	adler = adler32(bytesr(out_prev, inf.m_out_at - out_prev), adler);
	if (ret != ret_done) return ret;
	
	inf.m_state = 255;
	goto process_tail;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x8(%rdi), %r14
cmpb $-0x2, 0x8(%rdi)
jb 0x187ac
movq %r14, %rdi
callq 0x6c90
movl 0xc(%rbx), %eax
cmpq $0x20, %rax
jb 0x187d7
cmpb $-0x2, (%r14)
jne 0x187dc
pushq $0x10
popq %rsi
movq %r14, %rdi
callq 0x6d02
movl %eax, %ecx
andl $0x200f, %ecx           # imm = 0x200F
pushq $0x1
popq %rbp
cmpl $0x8, %ecx
jne 0x18800
rolw $0x8, %ax
movw $0x1f, %cx
xorl %edx, %edx
divw %cx
testw %dx, %dx
jne 0x18800
movb $0x0, (%r14)
movq 0x38(%rbx), %r15
movq %r14, %rdi
callq 0x6d6c
movl %eax, %ebp
movq 0x38(%rbx), %rsi
subq %r15, %rsi
movl (%rbx), %edx
movq %r15, %rdi
callq 0x18674
movl %eax, (%rbx)
testl %ebp, %ebp
jne 0x18800
movb $-0x1, (%r14)
jmp 0x18764
pushq $0x2
popq %rbp
jmp 0x18800
movl %eax, %ecx
andb $0x7, %cl
shrq %cl, 0x10(%rbx)
andl $-0x8, %eax
movl %eax, 0xc(%rbx)
pushq $0x20
popq %rsi
movq %r14, %rdi
callq 0x6d02
bswapl %eax
xorl %ebp, %ebp
cmpl (%rbx), %eax
setne %bpl
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/zlibhead.cpp
// Function: inflator::zlibhead::inflate(arrayview<unsigned char>)
bytearray inflator::zlibhead::inflate(bytesr in)
{
	inflator::zlibhead inf;
	inf.set_input(in, true);
	bytearray ret;
	ret.resize(max(4096, in.size()*8));
	inf.set_output_first(ret);
again:
	inflator::ret_t err = inf.inflate();
	if (err == inflator::ret_more_output)
	{
		ret.resize(ret.size()*2);
		inf.set_output_grow(ret);
		goto again;
	}
	else if (err != inflator::ret_done || inf.unused_input() != 0) ret.reset();
	else ret.resize(inf.output_in_last());
	
	return ret;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x12f0, %rsp           # imm = 0x12F0
movq %rdx, %r14
movq %rdi, %rbx
leaq 0x28(%rsp), %rdi
movl $0x1, -0x8(%rdi)
movb $0x0, 0x2(%rdi)
andq $0x0, 0x30(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x4(%rdi)
movups %xmm0, 0x10(%rdi)
movb $-0x2, (%rdi)
pushq $0x1
popq %rcx
callq 0x7922
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
shll $0x3, %r14d
cmpl $0x1001, %r14d          # imm = 0x1001
movl $0x1000, %esi           # imm = 0x1000
cmovgel %r14d, %esi
movq %rbx, %rdi
callq 0xbaee
movq (%rbx), %rax
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movq 0x8(%rbx), %rax
movq %rax, 0x8(%rsi)
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x9d50
movq %rsp, %r15
movq %r14, %rdi
callq 0x18750
cmpl $0x3, %eax
jne 0x188c9
movq 0x8(%rbx), %rsi
addq %rsi, %rsi
movq %rbx, %rdi
callq 0xbaee
movq (%rbx), %rax
movq %rax, (%rsp)
movq 0x8(%rbx), %rax
movq %rax, 0x8(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x189aa
jmp 0x18890
testl %eax, %eax
jne 0x188f7
movq 0x40(%rsp), %rax
subq 0x38(%rsp), %rax
movl 0x2c(%rsp), %ecx
shrl $0x3, %ecx
addq %rax, %rcx
jne 0x188f7
movq 0x58(%rsp), %rsi
subq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0xbaee
jmp 0x188ff
movq %rbx, %rdi
callq 0xbc86
movq %rbx, %rax
addq $0x12f0, %rsp           # imm = 0x12F0
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/arlib/zlibhead.cpp
// Function: inflator::zlibhead::inflate(arrayvieww<unsigned char>, arrayview<unsigned char>)
bool inflator::zlibhead::inflate(bytesw out, bytesr in)
{
	inflator::zlibhead inf;
	inf.set_input(in, true);
	inf.set_output_first(out);
	return (inf.inflate() == inflator::ret_done && inf.output_in_last() == out.size() && inf.unused_input() == 0);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x12e8, %rsp           # imm = 0x12E8
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
movl $0x1, -0x8(%rdi)
movb $0x0, 0x2(%rdi)
andq $0x0, 0x30(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x4(%rdi)
movups %xmm0, 0x10(%rdi)
movb $-0x2, (%rdi)
pushq $0x1
popq %rcx
callq 0x7922
movq (%rbx), %rax
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
movq 0x8(%rbx), %rax
movq %rax, 0x8(%rsi)
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x9d50
movq %r14, %rdi
callq 0x18750
testl %eax, %eax
jne 0x1899d
movq 0x50(%rsp), %rax
subq 0x48(%rsp), %rax
cmpq 0x8(%rbx), %rax
jne 0x1899d
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
movl 0x24(%rsp), %ecx
shrl $0x3, %ecx
addq %rax, %rcx
sete %al
jmp 0x1899f
xorl %eax, %eax
addq $0x12e8, %rsp           # imm = 0x12E8
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/font.cpp
// Function: font::init_from_image(image const&)
void font::init_from_image(const image& img)
{
	memset(characters, 0, sizeof(characters));
	memset(width, 0, sizeof(uint8_t)*32);
	
	int cw = img.width/16;
	int ch = img.height/6;
	
	for (int cy=0;cy<6;cy++)
	for (int cx=0;cx<16;cx++)
	{
		uint8_t charid = 32 + cy*16 + cx;
		
		uint8_t maxbits = 1;
		for (int y=0;y<ch;y++)
		{
			int ty = cy*ch + y;
			uint32_t* pixels = img.pixels32 + img.stride/sizeof(uint32_t)*ty;
			
			uint8_t bits = 0;
			for (int x=0;x<cw;x++)
			{
				int tx = cx*cw + x;
				bits |= !(pixels[tx]&1) << x;
			}
			characters[charid][y] = bits;
			maxbits |= bits;
		}
		
		width[charid] = ilog2(maxbits)+2; // +1 because maxbits=1 has width 1 but log2(1)=0, +1 because letter spacing
	}
	
	height = ch;
	scale = 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq $0x0, (%rsp)
movl $0x420, %edx            # imm = 0x420
xorl %esi, %esi
callq 0x3170
movl (%r14), %esi
movl 0x4(%r14), %eax
shrl $0x4, %esi
pushq $0x6
popq %rcx
xorl %edx, %edx
divl %ecx
movl %esi, %ecx
shll $0x2, %ecx
movq %rcx, 0x18(%rsp)
movl %eax, %ecx
shll $0x2, %ecx
movq %rcx, 0x8(%rsp)
xorl %edx, %edx
cmpq $0x6, %rdx
je 0x18d47
movq %rdx, 0x10(%rsp)
shlq $0x4, %rdx
addq $0x20, %rdx
movq %rdx, 0x20(%rsp)
xorl %r10d, %r10d
xorl %r11d, %r11d
cmpq $0x10, %r11
je 0x18d31
movq %r11, %r12
orq 0x20(%rsp), %r12
movb $0x1, %bpl
leaq (%rbx,%r12,8), %r13
movq (%rsp), %r15
xorl %edi, %edi
cmpq %rax, %rdi
je 0x18d0e
movl 0xc(%r14), %r8d
shrl $0x2, %r8d
movq 0x10(%r14), %rcx
addq %r10, %rcx
imulq %r15, %r8
addq %rcx, %r8
xorl %ecx, %ecx
xorl %edx, %edx
cmpq %rcx, %rsi
je 0x18cfe
movl (%r8,%rcx,4), %r9d
notl %r9d
andl $0x1, %r9d
shll %cl, %r9d
orb %r9b, %dl
incq %rcx
jmp 0x18ce3
movb %dl, (%rdi,%r13)
orb %dl, %bpl
incq %rdi
addq $0x4, %r15
jmp 0x18cc4
movzbl %bpl, %ecx
bsrl %ecx, %ecx
xorl $0x7, %ecx
movb $0x9, %dl
subb %cl, %dl
movb %dl, 0x400(%rbx,%r12)
incq %r11
addq 0x18(%rsp), %r10
jmp 0x18ca5
movq 0x10(%rsp), %rdx
incq %rdx
movq 0x8(%rsp), %rcx
addq %rcx, (%rsp)
jmp 0x18c83
movb %al, 0x480(%rbx)
movb $0x1, 0x488(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/font.cpp
// Function: font::measure(cstring, float)
uint32_t font::measure(cstring text, float spacesize)
{
	float ret = 0;
	for (size_t i=0;i<text.length();i++)
	{
		if (text[i] == ' ') ret += spacesize;
		ret += width[(uint8_t)text[i]] * scale;
	}
	return ret;
}

// Assembly:
leaq -0x10(%rsp), %rax
movq %rsi, (%rax)
movq %rdx, %rcx
shrq $0x38, %rcx
xorl $0xf, %ecx
testq %rdx, %rdx
cmovsq %rdx, %rcx
movq %rdx, 0x8(%rax)
movl %ecx, %ecx
cmovsq %rsi, %rax
movzbl 0x488(%rdi), %edx
xorps %xmm1, %xmm1
xorl %esi, %esi
movabsq $0x100000000, %r8       # imm = 0x100000000
subq $0x1, %rcx
jb 0x18dd4
movq %rsi, %r9
sarq $0x20, %r9
movzbl (%rax,%r9), %r9d
cmpq $0x20, %r9
jne 0x18db9
addss %xmm0, %xmm1
movzbl 0x400(%rdi,%r9), %r9d
imull %edx, %r9d
cvtsi2ss %r9d, %xmm2
addss %xmm2, %xmm1
addq %r8, %rsi
jmp 0x18d9d
cvttss2si %xmm1, %rax
retq
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/font.cpp
// Function: font::render_justified(image&, int, int, unsigned int, unsigned int, cstring, bool) const
void font::render_justified(image& img, int32_t x, int32_t y, uint32_t width1, uint32_t width2, cstring text, bool align) const
{
	size_t linestart = 0;
	size_t numspaces = 0;
	
	uint32_t linewidth = 0;
	for (size_t i=0;i<=text.length();i++)
	{
		if (i == text.length() || text[i] == '\n')
		{
			linewidth *= this->scale;
			
			float spacesize;
			if (linewidth >= width1 && linewidth <= width2) spacesize = ((width2 - linewidth) / (float)numspaces);
			else spacesize = 0;
			
			this->render(img, x, y, text.substr(linestart, i), spacesize, align);
			
			y += this->height * this->scale;
			linestart = i+1;
			linewidth = 0;
			numspaces = 0;
			continue;
		}
		
		if (text[i] == ' ') numspaces++;
		linewidth += this->width[(uint8_t)text[i]];
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, 0x18(%rsp)
movl %r8d, 0x14(%rsp)
movl %ecx, %r14d
movl %edx, 0x10(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, %r13
leaq 0x60(%rsp), %rbx
xorl %esi, %esi
movzbl 0x70(%rsp), %eax
movl %eax, 0xc(%rsp)
movabsq $0x100000000, %r12      # imm = 0x100000000
movzbl 0xf(%rbx), %ecx
movl 0x8(%rbx), %edx
movq %rbx, %r8
testb %cl, %cl
jns 0x190a8
movq (%rbx), %r8
movq %rcx, %r9
xorq $0xf, %r9
movq %rsi, %r10
shlq $0x20, %r10
xorl %edi, %edi
xorl %eax, %eax
movq %rsi, %rbp
testb %cl, %cl
js 0x190ce
movq %r9, %r11
cmpq %r9, %rbp
jbe 0x190da
jmp 0x191b7
movq %rdx, %r11
cmpq %rdx, %rbp
ja 0x191b7
cmpq %r11, %rbp
je 0x19113
movq %r10, %r11
sarq $0x20, %r11
movzbl (%r8,%r11), %r11d
cmpq $0xa, %r11
je 0x19113
xorl %r15d, %r15d
cmpq $0x20, %r11
sete %r15b
addq %r15, %rdi
movzbl 0x400(%r13,%r11), %r11d
addl %r11d, %eax
incq %rbp
addq %r12, %r10
jmp 0x190bd
testq %rdi, %rdi
js 0x1911f
cvtsi2ss %rdi, %xmm0
jmp 0x19134
movq %rdi, %rcx
shrq %rcx
andl $0x1, %edi
orq %rcx, %rdi
cvtsi2ss %rdi, %xmm0
addss %xmm0, %xmm0
movzbl 0x488(%r13), %ecx
imull %ecx, %eax
movl 0x18(%rsp), %ecx
xorps %xmm2, %xmm2
xorps %xmm1, %xmm1
subl %eax, %ecx
jb 0x19156
cvtsi2ss %rcx, %xmm1
divss %xmm0, %xmm1
cmpl 0x14(%rsp), %eax
jb 0x1915f
movaps %xmm1, %xmm2
movss %xmm2, 0x1c(%rsp)
movq %rbx, %rdi
movl %ebp, %edx
callq 0x55aa
movq %rdx, %r9
movl 0xc(%rsp), %ecx
movl %ecx, (%rsp)
movq %r13, %rdi
movq 0x20(%rsp), %rsi
movl 0x10(%rsp), %edx
movl %r14d, %ecx
movq %rax, %r8
movss 0x1c(%rsp), %xmm0
callq 0x18dda
movzbl 0x480(%r13), %eax
movzbl 0x488(%r13), %ecx
imull %eax, %ecx
addl %ecx, %r14d
incq %rbp
movq %rbp, %rsi
jmp 0x19097
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/font.cpp
// Function: font::render_wrap(image&, int, int, unsigned int, cstring) const
void font::render_wrap(image& img, int32_t x, int32_t y, uint32_t width, cstring text) const
{
	size_t linestart = 0;
	size_t numspaces = 0;
	
	size_t lastspace = 0; // index to the string
	uint32_t widthlastspace = 0; // text width (pixels) from linestart to lastspace
	
	uint32_t linewidth = 0; // text width (pixels) from linestart to i
	
	for (size_t i=0;i<=text.length();i++)
	{
		if (i == text.length() || text[i] == '\n' || linewidth >= width)
		{
			float spacesize = 0;
			if (linewidth >= width)
			{
				i = lastspace;
				linewidth = widthlastspace;
				spacesize = ((width - linewidth) / (float)(numspaces-1));
			}
			
			this->render(img, x, y, text.substr(linestart, i), spacesize, true);
			
			y += this->height * this->scale;
			linestart = i+1;
			linewidth = 0;
			numspaces = 0;
			continue;
		}
		
		if (text[i] == ' ')
		{
			lastspace = i;
			widthlastspace = linewidth;
			numspaces++;
		}
		linewidth += this->width[(uint8_t)text[i]] * this->scale;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, %ebx
movl %ecx, %ebp
movl %edx, 0x18(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, %r12
xorl %ecx, %ecx
leaq 0x60(%rsp), %r13
xorl %r15d, %r15d
xorl %edi, %edi
xorl %eax, %eax
xorl %r14d, %r14d
xorl %esi, %esi
movl %ebx, %edx
movl %edi, 0x10(%rsp)
subl %edi, %edx
cvtsi2ss %rdx, %xmm0
movss %xmm0, 0x14(%rsp)
movzbl 0xf(%r13), %edx
testb %dl, %dl
js 0x1922a
movq %rdx, %rdi
xorq $0xf, %rdi
cmpq %rdi, %r14
ja 0x1932b
movzbl %dil, %edi
jmp 0x19237
movl 0x8(%r13), %edi
cmpq %rdi, %r14
ja 0x1932b
cmpq %rdi, %r14
je 0x1925c
movq %r13, %rdi
testb %dl, %dl
jns 0x19247
movq (%r13), %rdi
movslq %r14d, %rdx
movzbl (%rdi,%rdx), %edx
cmpq $0xa, %rdx
je 0x1925c
cmpl %ebx, %eax
jb 0x192ef
decq %rcx
js 0x19268
cvtsi2ss %rcx, %xmm0
jmp 0x1927d
movq %rcx, %rdx
shrq %rdx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
xorps %xmm1, %xmm1
cmpl %ebx, %eax
cmovaeq %r15, %r14
jb 0x19292
movss 0x14(%rsp), %xmm1
divss %xmm0, %xmm1
movss %xmm1, 0x1c(%rsp)
movq %r13, %rdi
movl %r14d, %edx
callq 0x55aa
movq %rdx, %r9
movl $0x1, (%rsp)
movq %r12, %rdi
movq 0x20(%rsp), %rsi
movl 0x18(%rsp), %edx
movl %ebp, %ecx
movq %rax, %r8
movss 0x1c(%rsp), %xmm0
callq 0x18dda
movzbl 0x480(%r12), %eax
movzbl 0x488(%r12), %ecx
imull %eax, %ecx
addl %ecx, %ebp
incq %r14
xorl %ecx, %ecx
xorl %eax, %eax
movq %r14, %rsi
jmp 0x1920b
xorl %edi, %edi
cmpq $0x20, %rdx
sete %dil
cmoveq %r14, %r15
movl 0x10(%rsp), %r8d
cmovel %eax, %r8d
addq %rdi, %rcx
movzbl 0x400(%r12,%rdx), %edx
movzbl 0x488(%r12), %edi
imull %edx, %edi
addl %edi, %eax
movl %r8d, %edi
incq %r14
jmp 0x191f8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/game.cpp
// Function: (anonymous namespace)::game_impl::save(arrayvieww<unsigned char>)
void save(bytesw dat)
	{
		if (dat.size() != savedat_size) abort();
		
		dat[0] = unlocked;
		dat[1] = seen_random_tutorial;
		
#ifdef ARLIB_THREAD
		writeu_le64(dat.skip(2 ).ptr(), gamegen_next[0]);
		writeu_le32(dat.skip(10).ptr(), gamegen_diff_expect[0]);
		writeu_le64(dat.skip(14).ptr(), gamegen_next[1]);
		writeu_le32(dat.skip(22).ptr(), gamegen_diff_expect[1]);
		writeu_le64(dat.skip(26).ptr(), gamegen_next[2]);
		writeu_le32(dat.skip(34).ptr(), gamegen_diff_expect[2]);
#else
		writeu_le64(dat.skip(2 ).ptr(), 0);
		writeu_le32(dat.skip(10).ptr(), 0);
		writeu_le64(dat.skip(14).ptr(), 0);
		writeu_le32(dat.skip(22).ptr(), 0);
		writeu_le64(dat.skip(26).ptr(), 0);
		writeu_le32(dat.skip(34).ptr(), 0);
#endif
	}

// Assembly:
cmpq $0x26, 0x8(%rsi)
jne 0x1c6bc
movb 0x4c(%rdi), %al
movq (%rsi), %rcx
movb %al, (%rcx)
movb 0x24acd(%rdi), %al
movq (%rsi), %rcx
movb %al, 0x1(%rcx)
movq (%rsi), %rax
movq 0x24a80(%rdi), %rcx
movq %rcx, 0x2(%rax)
movq (%rsi), %rax
movl 0x24aac(%rdi), %ecx
movl %ecx, 0xa(%rax)
movq (%rsi), %rax
movq 0x24a88(%rdi), %rcx
movq %rcx, 0xe(%rax)
movq (%rsi), %rax
movl 0x24ab0(%rdi), %ecx
movl %ecx, 0x16(%rax)
movq (%rsi), %rax
movq 0x24a90(%rdi), %rcx
movq %rcx, 0x1a(%rax)
movq (%rsi), %rax
movl 0x24ab4(%rdi), %ecx
movl %ecx, 0x22(%rax)
retq
pushq %rax
callq 0x3180
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/game.cpp
// Function: (anonymous namespace)::birds::reset(bool)
void reset(bool force)
	{
		if (frame < -800/spd) return; // approaching but not on the screen = leave them there, so they appear earlier
		
		// first, pick a center for the birds, anywhere in the screen that's at least 100px from the edge
		xmid = 100 + g_rand(640-200);
		ymid = 100 + g_rand(480-200);
		
		// then pick a random direction
		angle = (float)g_rand.rand32()/65536/65536 * M_PI*2;
		
		frame = -800/spd;
		if (!force)
		{
			frame -= 60*60 + g_rand(60*60);
		}
	}

// Assembly:
cmpl $0xffffff38, 0xc(%rdi)  # imm = 0xFFFFFF38
jl 0x1c7dd
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x24ccd(%rip), %r14     # 0x41410
movq %r14, %rdi
movl $0x1b8, %esi            # imm = 0x1B8
callq 0x124f6
addl $0x64, %eax
cvtsi2ss %rax, %xmm0
movss %xmm0, (%rbx)
movq %r14, %rdi
movl $0x118, %esi            # imm = 0x118
callq 0x124f6
addl $0x64, %eax
cvtsi2ss %rax, %xmm0
movss %xmm0, 0x4(%rbx)
movq %r14, %rdi
callq 0x123a8
movl %eax, %eax
cvtsi2ss %rax, %xmm0
movss 0xe477(%rip), %xmm1     # 0x2ac04
mulss %xmm1, %xmm0
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0xe767(%rip), %xmm0     # 0x2af08
addsd %xmm0, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x8(%rbx)
movl $0xffffff38, 0xc(%rbx)  # imm = 0xFFFFFF38
testb %bpl, %bpl
jne 0x1c7d9
leaq 0x24c4f(%rip), %rdi     # 0x41410
movl $0xe10, %esi            # imm = 0xE10
callq 0x124f6
movl 0xc(%rbx), %ecx
subl %eax, %ecx
addl $0xfffff1f0, %ecx       # imm = 0xFFFFF1F0
movl %ecx, 0xc(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/game.cpp
// Function: (anonymous namespace)::game_impl::background()
void background()
	{
		if (tileset == 0)
		{
			out.insert_tile(0, 0, 640, 480, ((bgpos/15) & 1) ? resources::bg0b : resources::bg0);
		}
		if (tileset == 1)
		{
			int off = (bgpos/6)%21;
			out.insert_tile(0, 0, 640, 480, resources::bg1, off, 21-off);
		}
		if (tileset == 2)
		{
			out.insert_tile(0, 0, 640, 480, resources::bg2);
		}
		
		bgpos++;
		//must be a multiple of
		//- 30 (bg0 animation)
		//- 6*21 (bg1 animation)
		//- 90 (castle flag animation)
		bgpos %= 630;
	}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x48(%rdi), %eax
testl %eax, %eax
jne 0x1c821
leaq 0x28(%rbx), %rdi
movl 0x44(%rbx), %eax
pushq $0xf
popq %rcx
cltd
idivl %ecx
testb $0x1, %al
jne 0x1c803
leaq 0x2483f(%rip), %r9      # 0x41040
jmp 0x1c80a
leaq 0x2484e(%rip), %r9      # 0x41058
xorl %esi, %esi
xorl %edx, %edx
movl $0x280, %ecx            # imm = 0x280
movl $0x1e0, %r8d            # imm = 0x1E0
callq 0xa7a2
movl 0x48(%rbx), %eax
cmpl $0x1, %eax
jne 0x1c863
movl 0x44(%rbx), %eax
pushq $0x6
popq %rcx
cltd
idivl %ecx
pushq $0x15
popq %r10
cltd
idivl %r10d
movl %edx, %eax
leaq 0x28(%rbx), %rdi
subl %edx, %r10d
leaq 0x24829(%rip), %r9      # 0x41070
xorl %esi, %esi
xorl %edx, %edx
movl $0x280, %ecx            # imm = 0x280
movl $0x1e0, %r8d            # imm = 0x1E0
pushq %r10
pushq %rax
callq 0xa8c0
popq %rax
popq %rcx
movl 0x48(%rbx), %eax
cmpl $0x2, %eax
jne 0x1c887
leaq 0x28(%rbx), %rdi
leaq 0x24815(%rip), %r9      # 0x41088
xorl %esi, %esi
xorl %edx, %edx
movl $0x280, %ecx            # imm = 0x280
movl $0x1e0, %r8d            # imm = 0x1E0
callq 0xa7a2
movl 0x44(%rbx), %eax
incl %eax
movl $0x276, %ecx            # imm = 0x276
cltd
idivl %ecx
movl %edx, 0x44(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/game.cpp
// Function: (anonymous namespace)::birds::draw(image&, image const&, int)
void draw(image& out, const image& birdsmap, int tileset)
	{
		if (tileset == 2) return; // no birds in the snow region
		
		image bird;
		int animframe = frame/10 & 1;
		bird.init_ref_sub(birdsmap, animframe*8, tileset*6, 8, 6);
		
		int x = xmid + cosf(angle)*spd*frame;
		int y = ymid + sinf(angle)*spd*frame;
		
		for (int n=0;n<5;n++)
		{
			out.insert(x + cosf(angle + flock_angle_rad)*n*flock_dist, y + sinf(angle + flock_angle_rad)*n*flock_dist, bird);
			out.insert(x + cosf(angle - flock_angle_rad)*n*flock_dist, y + sinf(angle - flock_angle_rad)*n*flock_dist, bird);
		}
		
		frame++;
		
		//if outside the screen and distance increasing, reset them
		if (frame > 800/spd)
			reset(false);
	}

// Assembly:
cmpl $0x2, %edx
je 0x1ca69
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movl %edx, %ecx
movq %rsi, %r14
movq %rdi, %rbx
movl 0xc(%rdi), %eax
pushq $0xa
popq %rsi
cltd
idivl %esi
leal (,%rax,8), %edx
andl $0x8, %edx
imull $0x6, %ecx, %ecx
leaq 0x247cc(%rip), %rsi     # 0x410a0
leaq 0x38(%rsp), %r15
pushq $0x8
popq %r8
pushq $0x6
popq %r9
movq %r15, %rdi
callq 0xb140
movss (%rbx), %xmm0
movss %xmm0, (%rsp)
movss 0x8(%rbx), %xmm0
callq 0x3240
mulss 0xe304(%rip), %xmm0     # 0x2ac08
cvtsi2ssl 0xc(%rbx), %xmm1
mulss %xmm0, %xmm1
addss (%rsp), %xmm1
movaps %xmm1, (%rsp)
movss 0x4(%rbx), %xmm0
movss %xmm0, 0x10(%rsp)
movss 0x8(%rbx), %xmm0
callq 0x32a0
cvtsi2ssl 0xc(%rbx), %xmm1
mulss 0xe2d0(%rip), %xmm0     # 0x2ac08
mulss %xmm0, %xmm1
addss 0x10(%rsp), %xmm1
cvttps2dq (%rsp), %xmm0
cvtdq2ps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
cvttps2dq %xmm1, %xmm0
cvtdq2ps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
xorl %r12d, %r12d
cmpl $0x5, %r12d
je 0x1ca43
movss 0x8(%rbx), %xmm0
movss 0xe297(%rip), %xmm1     # 0x2ac0c
addss %xmm1, %xmm0
callq 0x3240
cvtsi2ss %r12d, %xmm1
movss %xmm1, (%rsp)
mulss %xmm1, %xmm0
movss 0xe27c(%rip), %xmm1     # 0x2ac10
mulss %xmm1, %xmm0
addss 0x10(%rsp), %xmm0
cvttss2si %xmm0, %ebp
movss 0x8(%rbx), %xmm0
addss 0xe25d(%rip), %xmm0     # 0x2ac0c
callq 0x32a0
mulss (%rsp), %xmm0
mulss 0xe24f(%rip), %xmm0     # 0x2ac10
addss 0x20(%rsp), %xmm0
cvttss2si %xmm0, %edx
movq %r14, %rdi
movl %ebp, %esi
movq %r15, %rcx
callq 0xa200
movss 0x8(%rbx), %xmm0
movss 0xe22f(%rip), %xmm1     # 0x2ac14
addss %xmm1, %xmm0
callq 0x3240
mulss (%rsp), %xmm0
mulss 0xe215(%rip), %xmm0     # 0x2ac10
addss 0x10(%rsp), %xmm0
cvttss2si %xmm0, %ebp
movss 0x8(%rbx), %xmm0
addss 0xe202(%rip), %xmm0     # 0x2ac14
callq 0x32a0
mulss (%rsp), %xmm0
mulss 0xe1ec(%rip), %xmm0     # 0x2ac10
addss 0x20(%rsp), %xmm0
cvttss2si %xmm0, %edx
movq %r14, %rdi
movl %ebp, %esi
movq %r15, %rcx
callq 0xa200
incl %r12d
jmp 0x1c95e
movl 0xc(%rbx), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0xc(%rbx)
cmpl $0xc7, %eax
jle 0x1ca5d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1c726
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/game.cpp
// Function: (anonymous namespace)::game_impl::to_game(int, bool)
void to_game(int id, bool use_kb)
	{
		state = st_ingame;
		
		game_load(id, use_kb);
		game_menu = false;
		game_menu_pos = 480;
	}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl $0x3, 0x40(%rdi)
callq 0x1ccd8
movb $0x0, 0x24a74(%rbx)
movl $0x1e0, 0x24a78(%rbx)   # imm = 0x1E0
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/game.cpp
// Function: (anonymous namespace)::game_impl::game_load(int, bool)
void game_load(int id, bool use_kb)
	{
		map_id = id;
		if (id < 30)
		{
			map.init(game_maps[id]);
			tileset = id/10;
		}
		else
		{
			gamemap::genparams p = game_params(id);
#ifdef ARLIB_THREAD
			if (gamegen_next[id-100])
			{
				gamemap::generator::unpack(p, gamegen_next[id-100], map);
				gamegen_next[id-100] = 0;
			}
			else // this can only happen if player enters a map, leaves, and reenters, within half a second (or savefile is corrupt)
			     // getting a generator delay is suboptimal, but unavoidable, and no human can click that fast
#endif
				map.generate(p);
			map.reset();
			
			tileset = id-100;
		}
		
		popup_id = pop_none;
		popup_frame = 0;
		if (id == 0) popup_id = pop_tutor1;
		if (id == 5) popup_id = pop_lv6p1;
		if (id == 10) popup_id = pop_lv11;
		if (id >= 100 && !seen_random_tutorial)
		{
			seen_random_tutorial = true;
			popup_id = pop_tutorrandom1;
		}
		
		birdfg.reset(false);
		
		game_kb_state = use_kb ? 1 : 0;
		game_kb_x = 0;
		game_kb_y = 0;
		
		recent_change = true;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
movl %esi, 0x24a70(%rdi)
cmpl $0x1d, %esi
jg 0x1cd21
leaq 0x68(%rbx), %rdi
movslq %r14d, %rax
leaq 0x23b89(%rip), %rcx     # 0x40890
movq (%rcx,%rax,8), %rsi
callq 0x1d0e0
pushq $0xa
popq %rcx
movl %r14d, %eax
cltd
idivl %ecx
movl %eax, 0x48(%rbx)
jmp 0x1cdf7
movabsq $0x4e2000000000, %rax   # imm = 0x4E2000000000
movq %rax, 0x18(%rsp)
movb $0x0, 0x14(%rsp)
leaq 0x308(%rip), %rax       # 0x1d044
movq %rax, 0x28(%rsp)
movq %rax, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
movw $0x707, 0x8(%rsp)       # imm = 0x707
movq $0x3ecccccd, 0xc(%rsp)  # imm = 0x3ECCCCCD
movw $0x101, 0x11(%rsp)      # imm = 0x101
cmpl $0x66, %r14d
je 0x1cd91
cmpl $0x65, %r14d
je 0x1cd87
cmpl $0x64, %r14d
jne 0x1cda0
movl $0x3e4ccccd, 0xc(%rsp)  # imm = 0x3E4CCCCD
movl $0x3f400000, 0x18(%rsp) # imm = 0x3F400000
jmp 0x1cda0
movl $0x3f800000, 0x18(%rsp) # imm = 0x3F800000
jmp 0x1cda0
movl $0x3f800000, 0x18(%rsp) # imm = 0x3F800000
movw $0x909, 0x8(%rsp)       # imm = 0x909
leal -0x64(%r14), %r13d
movslq %r14d, %r15
movq 0x24760(%rbx,%r15,8), %rsi
leaq 0x68(%rbx), %r12
testq %rsi, %rsi
je 0x1cdd4
addq $-0x64, %r15
leaq 0x8(%rsp), %rdi
movq %r12, %rdx
callq 0x1f3b4
andq $0x0, 0x24a80(%rbx,%r15,8)
jmp 0x1cde1
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x1d074
movq %r12, %rdi
callq 0x1d5f8
movl %r13d, 0x48(%rbx)
leaq 0x20(%rsp), %rdi
callq 0x1d048
andq $0x0, 0x24ac4(%rbx)
testl %r14d, %r14d
je 0x1ce18
cmpl $0xa, %r14d
je 0x1ce14
cmpl $0x5, %r14d
jne 0x1ce4e
pushq $0x7
jmp 0x1ce1a
pushq $0x9
jmp 0x1ce1a
pushq $0x3
popq %rax
movl %eax, 0x24ac4(%rbx)
leaq 0x50(%rbx), %rdi
xorl %esi, %esi
callq 0x1c726
movb %bpl, 0x24ac1(%rbx)
andq $0x0, 0x24ab8(%rbx)
movb $0x1, 0x21(%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x64, %r14d
jl 0x1ce21
cmpb $0x0, 0x24acd(%rbx)
jne 0x1ce21
movb $0x1, 0x24acd(%rbx)
pushq $0xd
jmp 0x1ce1a
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/gamemap.cpp
// Function: gamemap::toggle(int, int, int)
void gamemap::toggle(int x, int y, int dir)
{
	if (dir == 0)
	{
		island& here = map[y][x];
		if (here.bridges[0] == 3) return;
		
		int newbridges = (here.bridges[0]+1)%3;
		int diff = newbridges - here.bridges[0];
		for (int xx=0;xx<here.bridgelen[0];xx++)
		{
			map[y][x+xx  ].bridges[0] = newbridges;
			map[y][x+xx+1].bridges[2] = newbridges;
			get(map[y][x+xx  ].rootnode).totbridges += diff;
			get(map[y][x+xx+1].rootnode).totbridges += diff;
		}
	}
	else
	{
		island& here = map[y][x];
		if (here.bridges[3] == 3) return;
		
		int newbridges = (here.bridges[3]+1)%3;
		int diff = newbridges - here.bridges[3];
		for (int yy=0;yy<here.bridgelen[3];yy++)
		{
			map[y+yy  ][x].bridges[3] = newbridges;
			map[y+yy+1][x].bridges[1] = newbridges;
			get(map[y+yy  ][x].rootnode).totbridges += diff;
			get(map[y+yy+1][x].rootnode).totbridges += diff;
		}
	}
}

// Assembly:
pushq %rbx
leaq 0xc(%rdi), %r8
movslq %edx, %rax
movslq %esi, %rdx
imulq $0x4b0, %rax, %r9       # imm = 0x4B0
leaq (%rdi,%r9), %r10
addq $0xc, %r10
imulq $0xc, %rdx, %r11
addq %r11, %r10
testl %ecx, %ecx
je 0x1d565
movzbl 0xb(%r10), %ebx
cmpw $0x3, %bx
je 0x1d570
movzwl %bx, %eax
incl %eax
movw $0x3, %cx
xorl %edx, %edx
divw %cx
movl %edx, %ecx
movl %ecx, %esi
subb %bl, %sil
movsbq 0x7(%r10), %r10
addq %r11, %r9
addq %r9, %rdi
addq $0x4c5, %rdi            # imm = 0x4C5
movw $0x64, %r9w
xorl %r11d, %r11d
cmpq %r10, %r11
jge 0x1d570
movb %cl, -0x4ae(%rdi)
movb %cl, (%rdi)
movzwl -0x4b7(%rdi), %eax
xorl %edx, %edx
divw %r9w
movzwl %ax, %eax
movzwl %dx, %edx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
addq %r8, %rax
imulq $0xc, %rdx, %rdx
addb %sil, 0x1(%rdx,%rax)
movzwl -0x7(%rdi), %eax
xorl %edx, %edx
divw %r9w
movzwl %ax, %eax
movzwl %dx, %edx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
addq %r8, %rax
imulq $0xc, %rdx, %rdx
addb %sil, 0x1(%rdx,%rax)
incq %r11
addq $0x4b0, %rdi            # imm = 0x4B0
jmp 0x1d503
movzbl 0x8(%r10), %ebx
cmpw $0x3, %bx
jne 0x1d572
popq %rbx
retq
movzwl %bx, %eax
incl %eax
movw $0x3, %cx
xorl %edx, %edx
divw %cx
movl %edx, %ecx
movl %ecx, %esi
subb %bl, %sil
movsbq 0x4(%r10), %r10
addq %r11, %r9
addq %r9, %rdi
addq $0x22, %rdi
movw $0x64, %r9w
xorl %r11d, %r11d
cmpq %r10, %r11
jge 0x1d570
movb %cl, -0xe(%rdi)
movb %cl, (%rdi)
movzwl -0x14(%rdi), %eax
xorl %edx, %edx
divw %r9w
movzwl %ax, %eax
movzwl %dx, %edx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
addq %r8, %rax
imulq $0xc, %rdx, %rdx
addb %sil, 0x1(%rdx,%rax)
movzwl -0x8(%rdi), %eax
xorl %edx, %edx
divw %r9w
movzwl %ax, %eax
movzwl %dx, %edx
imulq $0x4b0, %rax, %rax      # imm = 0x4B0
addq %r8, %rax
imulq $0xc, %rdx, %rdx
addb %sil, 0x1(%rdx,%rax)
incq %r11
addq $0xc, %rdi
jmp 0x1d59e
nop
// File: /workspace/github_cpp_makefile_star2_O2/Alcaro[P]bridges/gamemap.cpp
// Function: gamemap::reset()
void gamemap::reset()
{
	for (int y=0;y<height;y++)
	for (int x=0;x<width;x++)
	{
		island& here = map[y][x];
		
		here.totbridges = 0;
		if (here.bridges[0] <= 2) here.bridges[0] = 0;
		if (here.bridges[1] <= 2) here.bridges[1] = 0;
		if (here.bridges[2] <= 2) here.bridges[2] = 0;
		if (here.bridges[3] <= 2) here.bridges[3] = 0;
	}
}

// Assembly:
movl (%rdi), %edx
movl 0x4(%rdi), %eax
xorl %ecx, %ecx
testl %edx, %edx
cmovlel %ecx, %edx
testl %eax, %eax
cmovlel %ecx, %eax
imulq $0xc, %rdx, %rdx
addq $0x17, %rdi
cmpq %rax, %rcx
je 0x1d662
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x1d656
movb $0x0, -0xa(%rdi,%rsi)
cmpb $0x2, -0x3(%rdi,%rsi)
ja 0x1d62e
movb $0x0, -0x3(%rdi,%rsi)
cmpb $0x2, -0x2(%rdi,%rsi)
ja 0x1d63a
movb $0x0, -0x2(%rdi,%rsi)
cmpb $0x2, -0x1(%rdi,%rsi)
ja 0x1d646
movb $0x0, -0x1(%rdi,%rsi)
cmpb $0x2, (%rdi,%rsi)
ja 0x1d650
movb $0x0, (%rdi,%rsi)
addq $0xc, %rsi
jmp 0x1d618
incq %rcx
addq $0x4b0, %rdi            # imm = 0x4B0
jmp 0x1d611
retq
nop