LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/GUI-Graphics[P]cpuraytracing/metal.cpp
// Function: gui::Metal::scatter(gui::Ray const&, gui::Intersection const&, gui::Vector3&, gui::Ray&) const
bool Metal::scatter(
		const Ray& in,
		const Intersection& intersection,
		Vector3& attenuation, Ray& scattered) const {

		attenuation = albedo;
		scattered.origin = intersection.position + intersection.normal * 0.001f;
		scattered.direction = in.direction.reflect(intersection.normal) + Math::randomSphere() * fuzzy;
		if (scattered.direction.dot(intersection.normal) > 0) return true;
		return false;
	}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %r8, %r14
movq %rdx, %rbx
movq %rdi, %r15
movl 0x10(%rdi), %eax
movl %eax, 0x8(%rcx)
movq 0x8(%rdi), %rax
movq %rax, (%rcx)
movss 0x18(%rdx), %xmm0
mulss 0x1604(%rip), %xmm0     # 0x51fc
movsd 0x4(%rdx), %xmm1
movsd 0x10(%rdx), %xmm2
mulps 0x15f7(%rip), %xmm2     # 0x5200
addps %xmm1, %xmm2
addss 0xc(%rdx), %xmm0
movlps %xmm2, (%r8)
movss %xmm0, 0x8(%r8)
movss 0x14(%rsi), %xmm4
movss 0x18(%rdx), %xmm0
movsd 0xc(%rsi), %xmm5
movsd 0x10(%rdx), %xmm1
movaps %xmm5, %xmm2
mulps %xmm1, %xmm2
shufps $0x55, %xmm2, %xmm2     # xmm2 = xmm2[1,1,1,1]
movaps %xmm5, %xmm3
mulss %xmm1, %xmm3
addss %xmm2, %xmm3
movaps %xmm4, %xmm2
mulss %xmm0, %xmm2
addss %xmm3, %xmm2
mulss %xmm2, %xmm0
shufps $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0]
mulps %xmm1, %xmm2
addps %xmm2, %xmm2
addss %xmm0, %xmm0
subps %xmm2, %xmm5
movaps %xmm5, 0x10(%rsp)
subss %xmm0, %xmm4
movss %xmm4, 0xc(%rsp)
callq 0x305a
movss 0x14(%r15), %xmm2
mulss %xmm2, %xmm1
shufps $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0]
mulps %xmm0, %xmm2
addps 0x10(%rsp), %xmm2
addss 0xc(%rsp), %xmm1
movlps %xmm2, 0xc(%r14)
movss %xmm1, 0x14(%r14)
movaps %xmm2, %xmm0
shufps $0x55, %xmm2, %xmm0     # xmm0 = xmm0[1,1],xmm2[1,1]
mulss 0x14(%rbx), %xmm0
mulss 0x10(%rbx), %xmm2
addss %xmm0, %xmm2
mulss 0x18(%rbx), %xmm1
addss %xmm2, %xmm1
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm1
seta %al
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/GUI-Graphics[P]cpuraytracing/./vector3.h
// Function: gui::Vector3::refract(gui::Vector3 const&, float, gui::Vector3&) const
bool refract(const Vector3& normal, float niOverNt, Vector3& refracted) const {
			Vector3 v = Vector3(*this).identity();
			float c1 = v.dot(normal);
			float c2 = 1 - niOverNt * niOverNt * (1 - c1 * c1);
			if(c2 > 0) {
				refracted = (v - normal * c1) * niOverNt - normal * sqrt(c2);
				return true;
			}
			return false;
		}

// Assembly:
movaps %xmm0, %xmm4
movss 0x8(%rdi), %xmm5
movsd (%rdi), %xmm0
movaps %xmm0, %xmm1
mulps %xmm0, %xmm1
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
movaps %xmm0, %xmm2
mulss %xmm0, %xmm2
addss %xmm1, %xmm2
movaps %xmm5, %xmm1
mulss %xmm5, %xmm1
addss %xmm2, %xmm1
sqrtss %xmm1, %xmm1
movss 0x102a(%rip), %xmm6     # 0x5010
movaps %xmm6, %xmm7
divss %xmm1, %xmm7
mulss %xmm7, %xmm5
shufps $0x0, %xmm7, %xmm7      # xmm7 = xmm7[0,0,0,0]
mulps %xmm0, %xmm7
movsd (%rsi), %xmm8
movaps %xmm8, %xmm0
mulps %xmm7, %xmm0
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movaps %xmm7, %xmm2
mulss %xmm8, %xmm2
addss %xmm0, %xmm2
movss 0x8(%rsi), %xmm0
movaps %xmm5, %xmm1
mulss %xmm0, %xmm1
addss %xmm2, %xmm1
movaps %xmm1, %xmm2
mulss %xmm1, %xmm2
movaps %xmm6, %xmm3
subss %xmm2, %xmm3
movaps %xmm4, %xmm2
mulss %xmm4, %xmm2
mulss %xmm3, %xmm2
subss %xmm2, %xmm6
xorps %xmm2, %xmm2
ucomiss %xmm2, %xmm6
jbe 0x40f4
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rdx, %rbx
movq %rsi, %r14
mulss %xmm1, %xmm0
shufps $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
mulps %xmm1, %xmm8
subss %xmm0, %xmm5
mulss %xmm4, %xmm5
ucomiss %xmm2, %xmm6
jb 0x407c
xorps %xmm0, %xmm0
sqrtss %xmm6, %xmm0
jmp 0x40bf
movaps %xmm6, %xmm0
movaps %xmm4, 0x30(%rsp)
movss %xmm5, 0xc(%rsp)
movss %xmm6, 0x8(%rsp)
movaps %xmm7, 0x20(%rsp)
movaps %xmm8, 0x10(%rsp)
callq 0x2250
xorps %xmm2, %xmm2
movaps 0x10(%rsp), %xmm8
movaps 0x20(%rsp), %xmm7
movss 0x8(%rsp), %xmm6
movss 0xc(%rsp), %xmm5
movaps 0x30(%rsp), %xmm4
movss 0x8(%r14), %xmm1
mulss %xmm0, %xmm1
subss %xmm1, %xmm5
subps %xmm8, %xmm7
unpcklps %xmm4, %xmm4            # xmm4 = xmm4[0,0,1,1]
mulps %xmm7, %xmm4
movsd (%r14), %xmm1
unpcklps %xmm0, %xmm0            # xmm0 = xmm0[0,0,1,1]
mulps %xmm1, %xmm0
subps %xmm0, %xmm4
movlps %xmm4, (%rbx)
movss %xmm5, 0x8(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r14
ucomiss %xmm2, %xmm6
seta %al
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/GUI-Graphics[P]cpuraytracing/renderer.cpp
// Function: gui::Renderer::radiance(gui::Ray const&, gui::Scene const&, int) const
Vector3 Renderer::radiance(const Ray& ray, const Scene& scene, int depth) const {
		Intersection intersection;
		if (scene.intersect(ray, 0, 10000, intersection)) {
			Ray scattered;
			Vector3 attenuation;
			if (intersection.material->scatter(
				ray, intersection, attenuation, scattered) && depth < 30) {
				return attenuation * radiance(scattered, scene, ++depth);
			} else {
				return Vector3(0);
			}
		} else {
			Vector3 unit = ray.direction;
			float k = (unit.identity().y + 1) * 0.5f;
			return Vector3(1) * (1 - k) + Vector3(0.5f, 0.7f, 1) * k;
		}
	}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, %ebx
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
leaq 0x30(%rsp), %rdx
movl $0x7f7fffff, (%rdx)     # imm = 0x7F7FFFFF
movq (%r14), %rax
movss 0x1140(%rip), %xmm1     # 0x5274
xorps %xmm0, %xmm0
movq %r14, %rdi
callq *0x10(%rax)
testb %al, %al
je 0x419c
leaq 0x30(%rsp), %rdx
movq 0x20(%rdx), %rdi
movq (%rdi), %rax
leaq 0x8(%rsp), %rcx
leaq 0x18(%rsp), %r8
movq %r12, %rsi
callq *0x10(%rax)
xorps %xmm0, %xmm0
cmpl $0x1d, %ebx
jg 0x4214
testb %al, %al
xorps %xmm1, %xmm1
je 0x4208
incl %ebx
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
movq %r14, %rdx
movl %ebx, %ecx
callq 0x4108
movaps %xmm0, %xmm2
movsd 0x8(%rsp), %xmm0
mulps %xmm2, %xmm0
mulss 0x10(%rsp), %xmm1
jmp 0x4208
movss 0xc(%r12), %xmm0
movss 0x10(%r12), %xmm4
movss 0x14(%r12), %xmm2
movaps %xmm4, %xmm3
mulss %xmm4, %xmm3
mulss %xmm0, %xmm0
addss %xmm3, %xmm0
mulss %xmm2, %xmm2
addss %xmm0, %xmm2
sqrtss %xmm2, %xmm2
movss 0xe3c(%rip), %xmm0      # 0x5010
movaps %xmm0, %xmm1
divss %xmm2, %xmm1
mulss %xmm4, %xmm1
addss %xmm0, %xmm1
mulss 0xfd9(%rip), %xmm1      # 0x51c4
movaps %xmm1, %xmm2
shufps $0x0, %xmm1, %xmm2      # xmm2 = xmm2[0,0],xmm1[0,0]
mulps 0x1087(%rip), %xmm2     # 0x5280
subss %xmm1, %xmm0
addss %xmm0, %xmm1
shufps $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
addps %xmm2, %xmm0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
xorps %xmm1, %xmm1
jmp 0x4208
nop
// File: /workspace/github_cpp_makefile_star2_O3/alibakhtiar[P]ExampleHTTPServer/example.cc
// Function: main
int main(int argc, char* argv[])
{
	Server server;

	server.ip = "0.0.0.0";
	server.port = 5000;

	if (argc >= 2) {
		server.port = std::atoi(argv[1]);
	}

	server.onRequest([](Request *req, Response *res) {
		res->header("Content-Type", "text/plain");
		res->header("Server", "ExampleHTTPServer");
		res->header("Cache-Control", "no-cache, no-store, must-revalidate");

		if (req->url == "/" || req->url == "/index.cpp") {
			res->body = "Your Request:\n";

			res->body += "method: ";
			res->body += req->method;
			res->body += "\n";

			res->body += "http version: ";
			res->body += std::to_string(req->httpMajorVersion);
			res->body += ".";
			res->body += std::to_string(req->httpMinorVersion);
			res->body += "\n";

			res->body += "url: ";
			res->body += req->url;
			res->body += "\n";

			if (req->queryString != "") {
				res->body += "query string: ";
				res->body += req->queryString;
				res->body += "\n";
			}

			res->body += "headers:\n";
			for (auto const &h : req->headers) {
				res->body += h.first;
				res->body += ": ";
				res->body += h.second;
				res->body += "\n";
			}
		}
		else {
			res->statusCode = 404;
			res->errorPage();
		}

		res->send();

		return true;
	});

	bool rc = createServer(&server);
	if (rc == false)
		return 1;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rsi, %r14
movl %edi, %ebp
leaq 0x4f3f(%rip), %r12      # 0x7d50
leaq 0x28(%rsp), %rdi
movq %r12, -0x8(%rdi)
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
movl $0x2e302e30, (%r15)     # imm = 0x2E302E30
movl $0x302e302e, 0x3(%r15)  # imm = 0x302E302E
leaq 0x2371(%rip), %rcx      # 0x51aa
movq $0x7, -0x8(%r15)
movb $0x0, 0x7(%r15)
movl $0x1388, 0x10(%r15)     # imm = 0x1388
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%r15)
movups %xmm0, 0x28(%r15)
movl $0x7, %edx
movl $0x7, %r8d
xorl %esi, %esi
callq 0x2270
leaq 0x50(%rsp), %rbx
movl $0x1388, -0x8(%rbx)     # imm = 0x1388
cmpl $0x2, %ebp
jl 0x2e8b
movq 0x8(%r14), %rdi
callq 0x2280
movl %eax, 0x48(%rsp)
xorps %xmm0, %xmm0
movq %rsp, %rsi
movaps %xmm0, (%rsi)
leaq 0xbd(%rip), %rax        # 0x2f58
movq %rax, 0x18(%rsi)
leaq 0x70a(%rip), %rax       # 0x35b0
movq %rax, 0x10(%rsi)
movq %rbx, %rdi
callq 0x45a6
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x2ec9
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x20(%rsp), %rdi
callq 0x2a33
movq %r12, 0x20(%rsp)
movq 0x60(%rsp), %rax
testq %rax, %rax
je 0x2eef
movq %rbx, %rdi
movq %rbx, %rsi
movl $0x3, %edx
callq *%rax
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x2f06
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21d0
movl $0x1, %eax
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2f3a
jmp 0x2f3a
jmp 0x2f42
movq %rax, %rbx
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x2f45
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x2f45
movq %rax, %rdi
callq 0x37e7
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x36e8
movq %rbx, %rdi
callq 0x22c0
nop
// File: /workspace/github_cpp_makefile_star2_O3/alibakhtiar[P]ExampleHTTPServer/./HttpServer.hh
// Function: SimpleHttpServer::Request::~Request()
virtual ~Request(void)
	{
		this->method.clear();
		this->url.clear();
		this->queryString.clear();
		this->headers.clear();
	}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x4592(%rip), %rax      # 0x7cd0
movq %rax, (%rdi)
xorl %eax, %eax
movq %rax, 0x28(%rdi)
movq 0x20(%rdi), %rcx
movb %al, (%rcx)
movq %rax, 0x48(%rdi)
movq 0x40(%rdi), %rcx
movb %al, (%rcx)
movq %rax, 0x68(%rdi)
movq 0x60(%rdi), %rcx
movb %al, (%rcx)
leaq 0x88(%rdi), %r14
movq %r14, %rdi
callq 0x37f2
movq %r14, %rdi
callq 0x389e
movq 0x60(%rbx), %rdi
leaq 0x70(%rbx), %rax
cmpq %rax, %rdi
je 0x3790
movq (%rax), %rsi
incq %rsi
callq 0x21d0
movq 0x40(%rbx), %rdi
leaq 0x50(%rbx), %rax
cmpq %rax, %rdi
je 0x37a8
movq (%rax), %rsi
incq %rsi
callq 0x21d0
movq 0x20(%rbx), %rdi
addq $0x30, %rbx
cmpq %rbx, %rdi
je 0x37c7
movq (%rbx), %rsi
incq %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x21d0
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/alibakhtiar[P]ExampleHTTPServer/./HttpServer.hh
// Function: SimpleHttpServer::Response::write(char const*, unsigned long)
static ssize_t sendBytes(int sock, const char *buffer, size_t length)
{
	ssize_t n = 0;
	const char *p = buffer;

	while (length > 0) {
		n = send(sock, p, length, 0);

		if (n < 1)
			break;

		p += n;
		length -= n;
	}

	return n;
}

// Assembly:
testq %rdx, %rdx
je 0x407d
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movl 0x8(%rdi), %ebp
movl %ebp, %edi
movq %r14, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x2120
testq %rax, %rax
jle 0x4078
addq %rax, %r14
subq %rax, %rbx
jne 0x405c
popq %rbx
popq %r14
popq %rbp
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/jweinst1[P]Pages/src/story/StoryEvent.cpp
// Function: StoryEvent::operator<<(char const*)
StoryEvent& StoryEvent::operator<<(const char* words)
{
        long wordSize = 0;
        const char* count = words;
        while(*count++) wordSize++;
        if(wordSize >= getSpace()) expandBy(wordSize * 2);
        while(*words) *_mark++ = *words++;
        return *this;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movb (%rsi), %al
testb %al, %al
je 0x2b70
xorl %ecx, %ecx
leaq 0x1(%rcx), %rsi
cmpb $0x0, 0x1(%r14,%rcx)
movq %rsi, %rcx
jne 0x2b5f
jmp 0x2b72
xorl %esi, %esi
movq 0x10(%rbx), %rcx
subq 0x8(%rbx), %rcx
cmpq %rcx, %rsi
jl 0x2b8d
addq %rsi, %rsi
movq %rbx, %rdi
callq 0x2bb4
movb (%r14), %al
testb %al, %al
je 0x2bac
incq %r14
movq 0x8(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
movb %al, (%rcx)
movb (%r14), %al
incq %r14
testb %al, %al
jne 0x2b94
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/jweinst1[P]Pages/src/story/StoryEvent.cpp
// Function: StoryEvent::expandBy(long)
void StoryEvent::expandBy(long addSize)
{
        long newCap = getCapacity() + addSize;
        long oldLen = getLen();
        char* newStream = new char[newCap + 1];
        std::fill(newStream, newStream + newCap, 0);
        char* writer = newStream;
        char* reader = _stream;
        while(reader != _mark)
        {
                *writer++ = *reader++;
        }
        delete[] _stream;
        _stream = newStream;
        _mark = _stream + oldLen;
        _end = _stream + newCap;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x10(%rdi), %rax
movq (%rdi), %r15
movq 0x8(%rdi), %r13
subq %r15, %rax
leaq (%rax,%rsi), %r14
leaq (%rax,%rsi), %rdi
incq %rdi
callq 0x1030
movq %rax, %r12
testq %r14, %r14
je 0x2bf8
movq %r12, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x10b0
cmpq %r13, %r15
je 0x2c12
movq %r15, %rax
movq %r12, %rcx
movb (%rax), %dl
incq %rax
movb %dl, (%rcx)
incq %rcx
cmpq %r13, %rax
jne 0x2c03
testq %r15, %r15
je 0x2c1f
movq %r15, %rdi
callq 0x1140
addq %r12, %r14
subq %r15, %r13
movq %r12, (%rbx)
addq %r12, %r13
movq %r13, 0x8(%rbx)
movq %r14, 0x10(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/jweinst1[P]Pages/src/story/StoryEvent.cpp
// Function: StoryEvent::operator<<(StoryPart::Type)
StoryEvent& StoryEvent::operator<<(StoryPart::Type flag)
{
        if(3 >= getSpace()) expandBy(getLen() * 2);
        switch(flag)
        {
        case StoryPart::Comma:
                *_mark++ = ',';
                *_mark++ = ' ';
                break;
        case StoryPart::Period:
                *_mark++ = '.';
                *_mark++ = ' ';
                break;
        case StoryPart::Space:
                *_mark++ = ' ';
                break;
        case StoryPart::Newline:
                *_mark++ = '\n';
                break;
        }
        return *this;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %r14d
movq %rdi, %rbx
movq 0x8(%rdi), %rsi
movq 0x10(%rdi), %rax
subq %rsi, %rax
cmpq $0x3, %rax
jg 0x2c6e
subq (%rbx), %rsi
addq %rsi, %rsi
movq %rbx, %rdi
callq 0x2bb4
cmpl $0x3, %r14d
ja 0x2cbb
movb $0x20, %al
movl %r14d, %ecx
leaq 0x1498(%rip), %rdx      # 0x4118
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq 0x8(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
movb $0x2c, (%rcx)
jmp 0x2cad
movq 0x8(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
movb $0x2e, (%rcx)
jmp 0x2cad
movb $0xa, %al
movq 0x8(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rbx)
movb %al, (%rcx)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/jweinst1[P]Pages/src/story/StoryEvent.cpp
// Function: StoryEvent::operator<<(Descriptor const&)
StoryEvent& StoryEvent::operator<<(const Descriptor& desc)
{
        DescriptorPath::Type path = DescriptorPath::get();
        switch(path)
        {
        case DescriptorPath::Zero:
                break;
        case DescriptorPath::One:
                *this << StoryPart::Space << desc.get().getString();
                break;
        case DescriptorPath::Two:
                *this << StoryPart::Space
                      << desc.get().getString()
                      << StoryPart::Comma
                      << desc.get().getString();
                break;
        case DescriptorPath::Two_And:
                *this << StoryPart::Space
                      << desc.get().getString()
                      << " and "
                      << desc.get().getString();
                break;
        }

        return *this;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
callq 0x1050
leal 0x3(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
andl $-0x4, %ecx
subl %ecx, %eax
cmpl $0x3, %eax
je 0x2d32
cmpl $0x2, %eax
je 0x2cfd
cmpl $0x1, %eax
jne 0x2d83
movq %rbx, %rdi
xorl %esi, %esi
jmp 0x2d2b
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2c42
callq 0x1050
cltq
cqto
idivq 0x18(%r14)
movq (%r14), %rax
movq (%rax,%rdx,8), %rsi
movq %rbx, %rdi
callq 0x2b4a
movq %rbx, %rdi
movl $0x1, %esi
callq 0x2c42
jmp 0x2d67
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2c42
callq 0x1050
cltq
cqto
idivq 0x18(%r14)
movq (%r14), %rax
movq (%rax,%rdx,8), %rsi
movq %rbx, %rdi
callq 0x2b4a
leaq 0x13c9(%rip), %rsi      # 0x4128
movq %rbx, %rdi
callq 0x2b4a
callq 0x1050
cltq
cqto
idivq 0x18(%r14)
movq (%r14), %rax
movq (%rax,%rdx,8), %rsi
movq %rbx, %rdi
callq 0x2b4a
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/jweinst1[P]Pages/src/story/StoryEvent.cpp
// Function: StoryEvent::operator<<(StoryObject const&)
StoryEvent& StoryEvent::operator<<(const StoryObject& sobj)
{
        *this << sobj.getDeterminer()
              << sobj.descriptor()
              << StoryPart::Space
              << sobj.getName();
        return *this;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
callq 0x1050
cltq
cqto
idivq 0x18(%r14)
movq (%r14), %rax
movq (%rax,%rdx,8), %rsi
movq %rbx, %rdi
callq 0x2b4a
leaq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x2cc4
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2c42
movq 0x60(%r14), %rsi
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x2b4a
nop
// File: /workspace/github_cpp_makefile_star2_O3/jweinst1[P]Pages/src/story/StoryEvent.cpp
// Function: StoryEvent::operator<<(StoryAction const&)
StoryEvent& StoryEvent::operator<<(const StoryAction& sact)
{
        *this << StoryPart::Space;
        ActionPath::Type path = ActionPath::get();
        switch(path)
        {
        case ActionPath::Adverb:
                *this << sact.getAdverb()
                      << StoryPart::Space
                      << sact.getName();
                break;
        case ActionPath::None:
                *this << sact.getName();
                break;
        }
        return *this;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
xorl %esi, %esi
callq 0x2c42
callq 0x1050
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
andl $-0x2, %ecx
subl %ecx, %eax
cmpl $0x1, %eax
je 0x2e31
testl %eax, %eax
jne 0x2e3c
callq 0x1050
cltq
cqto
idivq 0x40(%r14)
movq 0x28(%r14), %rax
movq (%rax,%rdx,8), %rsi
movq %rbx, %rdi
callq 0x2b4a
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2c42
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x2b4a
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/jweinst1[P]Pages/src/util/BlockStr.cpp
// Function: BlockStr::operator=(BlockStr const&)
BlockStr& BlockStr::operator=(const BlockStr& other)
{
        _str = new char[BlockStr::getLen(other.getString()) + 1];
        char* writer = _str;
        const char* reader = other.getString();
        while((*writer++ = *reader++)) ;
        return *this;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
cmpb $0x0, (%rax)
je 0x3009
movl $0x1, %ecx
leaq 0x1(%rcx), %rdi
cmpb $0x0, (%rax,%rcx)
movq %rdi, %rcx
jne 0x2ffa
jmp 0x300e
movl $0x1, %edi
callq 0x1030
movq %rax, (%rbx)
movq (%r14), %rcx
xorl %edx, %edx
movb (%rcx,%rdx), %sil
movb %sil, (%rax,%rdx)
incq %rdx
testb %sil, %sil
jne 0x301b
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/jweinst1[P]Pages/src/util/BlockStr.cpp
// Function: operator<(BlockStr const&, BlockStr const&)
bool operator<(const BlockStr& lhs, const BlockStr& rhs)
{
        long lhsTotal = 0;
        long rhsTotal = 0;
        const char* lhsPtr = lhs.getString();
        const char* rhsPtr = rhs.getString();
        while(*lhsPtr) lhsTotal += *lhsPtr++;
        while(*rhsPtr) rhsTotal += *rhsPtr++;
        return lhsTotal < rhsTotal;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq (%rdi), %rdx
movq (%rsi), %rax
movb (%rdx), %sil
testb %sil, %sil
je 0x305e
incq %rdx
xorl %ecx, %ecx
movsbq %sil, %rsi
addq %rsi, %rcx
movb (%rdx), %sil
incq %rdx
testb %sil, %sil
jne 0x304a
jmp 0x3060
xorl %ecx, %ecx
movb (%rax), %sil
testb %sil, %sil
je 0x3081
incq %rax
xorl %edx, %edx
movsbq %sil, %rsi
addq %rsi, %rdx
movb (%rax), %sil
incq %rax
testb %sil, %sil
jne 0x306d
jmp 0x3083
xorl %edx, %edx
cmpq %rdx, %rcx
setl %al
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/jweinst1[P]Pages/src/util/BlockStr.cpp
// Function: BlockStr::operator==(BlockStr const&) const
bool BlockStr::operator ==(const BlockStr& other) const
{
        const char* current = _str;
        const char* comp = other.getString();
        while(*comp && *current)
        {
                if((*comp++ != *current++)) return false;
        }
        if(*comp != '\0' || *current != '\0') return false;
        else return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq (%rdi), %rax
movq (%rsi), %rcx
xorl %edx, %edx
movb (%rcx,%rdx), %sil
movb (%rax,%rdx), %dil
testb %sil, %sil
je 0x30c5
incq %rdx
cmpb %dil, %sil
je 0x30ac
xorl %eax, %eax
jmp 0x30cb
testb %dil, %dil
sete %al
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Rom.cpp
// Function: DoaERando::ROM::ReadRom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void ROM::ReadRom(std::string file)
{
    ifstream fin(file, ios::binary);
    if (fin.fail()) throw 0;
    myContents = vector<BYTE>(
        (istreambuf_iterator<char>(fin)),
        (istreambuf_iterator<char>())
        );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x230, %rsp            # imm = 0x230
movq %rdi, %rbx
leaq -0x238(%rbp), %r14
movq %r14, %rdi
movl $0x4, %edx
callq 0x456a80
movq (%r14), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x218(%rbp,%rax)
jne 0x4046f9
movq -0x150(%rbp,%rax), %rsi
leaq -0x30(%rbp), %rdi
leaq -0x11(%rbp), %r9
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x404aee
movq (%rbx), %rdi
movq -0x30(%rbp), %rax
movq %rax, (%rbx)
movq -0x28(%rbp), %rax
movq %rax, 0x8(%rbx)
movq -0x20(%rbp), %rax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, -0x30(%rbp)
movq $0x0, -0x20(%rbp)
testq %rdi, %rdi
je 0x4046e1
callq 0x410b90
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x4046e1
callq 0x410b90
leaq -0x238(%rbp), %rdi
callq 0x4577b0
addq $0x230, %rsp            # imm = 0x230
popq %rbx
popq %r14
popq %rbp
retq
movl $0x4, %edi
callq 0x410e70
movl $0x0, (%rax)
movq $0x5f66e8, %rsi         # imm = 0x5F66E8
movq %rax, %rdi
xorl %edx, %edx
callq 0x411ec0
jmp 0x40471c
movq %rax, %rbx
leaq -0x238(%rbp), %rdi
callq 0x4577b0
movq %rbx, %rdi
callq 0x4bb660
nop
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::PrintName(unsigned char)
void Randomizer::PrintName(BYTE id)
{
    int nameOffset = GetGeneralLocation(id) + 20;
    while (myRom->ReadByte(nameOffset) != 0xFF)
    {
        char character = myRom->ReadByte(nameOffset) + 'A' - 0x10;
        switch(myRom->ReadByte(nameOffset))
        {
            case 0x2D:
                character = 'r';
                break;
            case 0x2F:
                character = 't';
                break;
            case 0x64:
                character = 'u';
                break;
            case 0x0A:
                character = ' ';
                break;
            default:
                break;
        }

        printf("%c", character);
        ++nameOffset;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x404e36
movl %eax, %r14d
addl $0x14, %r14d
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x4049fa
cmpb $-0x1, %al
je 0x404f03
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x4049fa
movl %eax, %r15d
addb $0x31, %r15b
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x4049fa
movzbl %al, %eax
cmpl $0x2e, %eax
jg 0x404ede
cmpl $0xa, %eax
je 0x404eed
cmpl $0x2d, %eax
jne 0x404ef5
movb $0x72, %r15b
jmp 0x404ef5
cmpl $0x2f, %eax
je 0x404ef2
cmpl $0x64, %eax
jne 0x404ef5
movb $0x75, %r15b
jmp 0x404ef5
movb $0x20, %r15b
jmp 0x404ef5
movb $0x74, %r15b
movsbl %r15b, %edi
callq 0x4e9e00
incl %r14d
jmp 0x404e9b
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::FixNMIGlitch()
void Randomizer::FixNMIGlitch()
{
    // This should hopefully stop all of the crashes
    std::vector<BYTE> loopingCode = {
        0x68,               // PLA
        0x85, 0xF3,         // STA $F3
        0x68,               // PLA
        0x85, 0xF4,         // STA $F4
        // Now we're just shifting this section up to follow immediately
        0xA0, 0x02,         // LDY #$02
        0xB1, 0xF3,         // LDA ($F3),Y
        0x48,               // PHA
        0x88,               // DEY
        0xB1, 0xF3,         // LDA ($F3),Y
        0x48,               // PHA
        0xA5, 0x45,         // LDA $45
        0x4C, 0x80, 0xC4,   // JMP $C480
        // Zero out remaining bytes from this logic
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    };
    for (int i = 0; i < loopingCode.size(); ++i)
    {
        myRom->WriteByte(0x3C50B + i, loopingCode[i]);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
movups 0x1862dc(%rip), %xmm0   # 0x58c397
leaq -0x50(%rbp), %rsi
movups %xmm0, 0xf(%rsi)
movups 0x1862be(%rip), %xmm0   # 0x58c388
movaps %xmm0, (%rsi)
leaq -0x30(%rbp), %r14
leaq -0x11(%rbp), %rcx
movl $0x1f, %edx
movq %r14, %rdi
callq 0x40a9ca
movq (%r14), %rdi
cmpq %rdi, 0x8(%r14)
je 0x406118
xorl %r14d, %r14d
movq (%rbx), %rax
movzbl (%rdi,%r14), %edx
leal 0x3c50b(%r14), %esi
movq %rax, %rdi
callq 0x404a24
incq %r14
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rax
subq %rdi, %rax
cmpq %r14, %rax
ja 0x4060ee
testq %rdi, %rdi
je 0x406122
callq 0x410b90
addq $0x40, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x40613c
callq 0x410b90
movq %rbx, %rdi
callq 0x4bb660
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::GivePartyMaxFoodFromNPC()
void Randomizer::GivePartyMaxFoodFromNPC()
{
    printf("Feeding the armies well...\n");
    // 0xF423F is 999999 in decimal.  These bytes determine the amount of food the NPC gives you.
    // Note that the text still says 1000.  I'll need to change that elsewhere.
    myRom->WriteByte(0x361D7, 0x0F);
    myRom->WriteByte(0x361DB, 0x42);
    myRom->WriteByte(0x361DF, 0x3F);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1860de(%rip), %rdi    # 0x58c2b8
callq 0x4e96e0
movq (%rbx), %rdi
movl $0x361d7, %esi          # imm = 0x361D7
movl $0xf, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x361db, %esi          # imm = 0x361DB
movl $0x42, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x361df, %esi          # imm = 0x361DF
movl $0x3f, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x404a24
nop
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::ModifyEncounterRate()
void Randomizer::ModifyEncounterRate()
{
    printf("Keeping the enemies away(ish)...\n");
    // Don't encounter enemies on anything that's not mountains (and whatever id 0x05 is)
    myRom->WriteByte(0x3F4D6, 0x04);
    // Make Mountain encounter rate really high (50%)
    myRom->WriteByte(0x3F51C, 0x01);
    myRom->WriteByte(0x3F522, 0x00);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1860a7(%rip), %rdi    # 0x58c2d3
callq 0x4e96e0
movq (%rbx), %rdi
movl $0x3f4d6, %esi          # imm = 0x3F4D6
movl $0x4, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x3f51c, %esi          # imm = 0x3F51C
movl $0x1, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x3f522, %esi          # imm = 0x3F522
xorl %edx, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x404a24
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::DisableChapter1LockForSiShui()
void Randomizer::DisableChapter1LockForSiShui()
{
    printf("Opening Si Shui fortress to Liu Bei...\n");
    // Make only chapters below 1 (i.e., none) block entrance to Si Shui
    myRom->WriteByte(0x3642B, 0x01);
    // Don't disable Si Shui battle unless we enter in chapter 0 (i.e., never)
    myRom->WriteByte(0x3643B, 0x00);
    // Don't decrement the Y counter unless we are in a chapter below 1 (i.e., never)
    myRom->WriteByte(0x3BE8B, 0x01);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x18607a(%rip), %rdi    # 0x58c2f4
callq 0x4e96e0
movq (%rbx), %rdi
movl $0x3642b, %esi          # imm = 0x3642B
movl $0x1, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x3643b, %esi          # imm = 0x3643B
xorl %edx, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x3be8b, %esi          # imm = 0x3BE8B
movl $0x1, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x404a24
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::IncreaseTacticGains()
void Randomizer::IncreaseTacticGains()
{
    // Since we aren't gaining TP on every level now, let's up our TP gain
    // Here, we're going to randomize each 1/16 chance value to be between
    // 5-10, with the last slot being 15-20.
    const int TACTIC_GAINS_OFFSET = 0x3B666;
    for (int i = 0; i < 15; ++i)
    {
        BYTE tacticGain = myRNG.GetRandomByte(5, 10);
        myRom->WriteByte(TACTIC_GAINS_OFFSET + i, tacticGain);
        printf("Increasing tactic gain 0x%X to %d\n", i, tacticGain);
    }
    BYTE tacticGain = myRNG.GetRandomByte(15, 20);
    myRom->WriteByte(TACTIC_GAINS_OFFSET + 15, tacticGain);
    printf("Increasing tactic gain 0x%X to %d\n", 15, tacticGain);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x8(%rdi), %r14
leaq 0x185dd9(%rip), %r15    # 0x58c143
xorl %r12d, %r12d
movq %r14, %rdi
movl $0x5, %esi
movl $0xa, %edx
callq 0x410846
movq (%rbx), %rdi
leal 0x3b666(%r12), %esi
movzbl %al, %r13d
movl %r13d, %edx
callq 0x404a24
movq %r15, %rdi
movl %r12d, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0x4e21a0
incl %r12d
cmpl $0xf, %r12d
jne 0x40636d
movq %r14, %rdi
movl $0xf, %esi
movl $0x14, %edx
callq 0x410846
movq (%rbx), %rdi
movzbl %al, %ebx
movl $0x3b675, %esi          # imm = 0x3B675
movl %ebx, %edx
callq 0x404a24
leaq 0x185d69(%rip), %rdi    # 0x58c143
movl $0xf, %esi
movl %ebx, %edx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4e21a0
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::DoubleXpGain()
void Randomizer::DoubleXpGain()
{
    const int XP_MULTIPLIER_OFFSET = 0x39a28;
    for (int i = 0; i < 8; ++i)
    {
        BYTE currentXpBoost = myRom->ReadByte(XP_MULTIPLIER_OFFSET + i);
        BYTE increasedXpBoost = currentXpBoost * 2;
        myRom->WriteByte(XP_MULTIPLIER_OFFSET + i, increasedXpBoost);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl $0x39a28, %r14d         # imm = 0x39A28
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x4049fa
addb %al, %al
movq (%rbx), %rdi
movzbl %al, %edx
movl %r14d, %esi
callq 0x404a24
incl %r14d
cmpl $0x39a30, %r14d         # imm = 0x39A30
jne 0x406406
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::MakeAllGeneralsRecruitableAndEncounterable()
void Randomizer::MakeAllGeneralsRecruitableAndEncounterable()
{
    myGenerals.SetAllGeneralsEncounterable();
    myGenerals.SetAllGeneralsRecruitable();

    //Allow any General that appears in a town and isn't already on your party to show up.
    myRom->WriteByte(0x3E8F0, 0xC0); // Compare general config with 0xC0 rather than 0x80
    myRom->WriteByte(0x3E8F1, 0xD0); // Branch if != 0xC0 rather than branching if == 0x80 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x9d0(%rdi), %r14
movq %r14, %rdi
callq 0x40c85e
movq %r14, %rdi
callq 0x40c87e
movq (%rbx), %rdi
movl $0x3e8f0, %esi          # imm = 0x3E8F0
movl $0xc0, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x3e8f1, %esi          # imm = 0x3E8F1
movl $0xd0, %edx
popq %rbx
popq %r14
popq %rbp
jmp 0x404a24
nop
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::RandomizeTacticLevels()
void Randomizer::RandomizeTacticLevels()
{
    const int TACTIC_LEVEL_OFFSET = 0x3b880;
    printf("Old Tactic Levels:\n");
    for(int i = 1; i < 50; ++i)
    {
        printf("  Level %d: Tactic id 0x%X\n", i + 1, myRom->ReadByte(TACTIC_LEVEL_OFFSET + i));
    }
    for (int i = 0; i < 10000; ++i)
    {
        int levelSlot1 = myRNG.GetRandomByte(1, 49);
        int levelSlot2 = myRNG.GetRandomByte(1, 49);

        myRom->SwapBytes(TACTIC_LEVEL_OFFSET + levelSlot1, TACTIC_LEVEL_OFFSET + levelSlot2);
    }

    printf("New Tactic Levels:\n");
    for(int i = 1; i < 50; ++i)
    {
        printf("  Level %d: Tactic id 0x%X\n", i + 1, myRom->ReadByte(TACTIC_LEVEL_OFFSET + i));
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x185e87(%rip), %rdi    # 0x58c31b
callq 0x4e96e0
movl $0x3b881, %r14d         # imm = 0x3B881
leaq 0x185cc0(%rip), %r15    # 0x58c166
leal -0x3b87f(%r14), %r12d
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x4049fa
movzbl %al, %edx
movq %r15, %rdi
movl %r12d, %esi
xorl %eax, %eax
callq 0x4e21a0
incl %r14d
cmpl $0x3b8b2, %r14d         # imm = 0x3B8B2
jne 0x4064a6
leaq 0x8(%rbx), %r14
movl $0x2710, %r12d          # imm = 0x2710
movl $0x3b880, %r13d         # imm = 0x3B880
movq %r14, %rdi
movl $0x1, %esi
movl $0x31, %edx
callq 0x410846
movzbl %al, %r15d
movq %r14, %rdi
movl $0x1, %esi
movl $0x31, %edx
callq 0x410846
movzbl %al, %edx
movq (%rbx), %rdi
addl %r13d, %r15d
addl %r13d, %edx
movl %r15d, %esi
callq 0x404a4e
decl %r12d
jne 0x4064e4
leaq 0x185e02(%rip), %rdi    # 0x58c32e
callq 0x4e96e0
movl $0x3b881, %r14d         # imm = 0x3B881
leaq 0x185c28(%rip), %r15    # 0x58c166
leal -0x3b87f(%r14), %r12d
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x4049fa
movzbl %al, %edx
movq %r15, %rdi
movl %r12d, %esi
xorl %eax, %eax
callq 0x4e21a0
incl %r14d
cmpl $0x3b8b2, %r14d         # imm = 0x3B8B2
jne 0x40653e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::RandomizeBattles()
void Randomizer::RandomizeBattles()
{
    myBattleRandomizer.RandomizeZone1(myGenerals, myRNG);
    myBattleRandomizer.RandomizeZone2(myGenerals, myRNG);
    myBattleRandomizer.RandomizeZone3(myGenerals, myRNG);
    myBattleRandomizer.RandomizeZone4(myGenerals, myRNG);
    myBattleRandomizer.RandomizeZone5(myGenerals, myRNG);
    myBattleRandomizer.RandomizeZone6(myGenerals, myRNG);
    myBattleRandomizer.RandomizeZone7(myGenerals, myRNG);
    myBattleRandomizer.RandomizeZone8(myGenerals, myRNG);
    myBattleRandomizer.UpdateBattles(*myRom);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
leaq 0xa20(%rdi), %r14
leaq 0x9d0(%rdi), %r15
leaq 0x8(%rdi), %r12
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x40d868
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x40dc8e
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x40deba
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x40e0c0
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x40e398
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x40e5c8
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x40e7d2
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x40eb16
movq (%rbx), %rsi
movq %r14, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x40fed2
nop
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::MoveGuiYangBattle()
void Randomizer::MoveGuiYangBattle()
{
    // First, set the flags to clear the throne room battle
    // We only want to set two bits, so let's read and then set those 2 bits only
    auto flags = myRom->ReadByte(0x34761);
    // bit 1 = Gui Yang battle started
    // bit 2 = Gui Yang battle won
    flags |= 0x06;
    myRom->WriteByte(0x34761, flags);

    // Next, we're going to move the Gui Yang battle to the castle entrance
    myRom->WriteByte(0x30C2B, 0x09); // Vertical offset in block
    myRom->WriteByte(0x30C83, 0x12); // Vertical block
    myRom->WriteByte(0x30CDB, 0x03); // Horizontal offset in block
    myRom->WriteByte(0x30D33, 0x0E); // Horizontal block
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
movl $0x34761, %esi          # imm = 0x34761
callq 0x4049fa
orb $0x6, %al
movq (%rbx), %rdi
movzbl %al, %edx
movl $0x34761, %esi          # imm = 0x34761
callq 0x404a24
movq (%rbx), %rdi
movl $0x30c2b, %esi          # imm = 0x30C2B
movl $0x9, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x30c83, %esi          # imm = 0x30C83
movl $0x12, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x30cdb, %esi          # imm = 0x30CDB
movl $0x3, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x30d33, %esi          # imm = 0x30D33
movl $0xe, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x404a24
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::SetGeneralForZone0AndRemove(unsigned char, std::vector<unsigned char, std::allocator<unsigned char>>&)
void Randomizer::SetGeneralForZone0AndRemove(BYTE generalId, std::vector<BYTE>& ids)
{
    myGenerals.SetAndScaleGeneralForZone(generalId, 0, myRNG);
    myGenerals.SetGeneralEncounterable(generalId, false);
    myGenerals.SetGeneralRecruitable(generalId, false);
    PullIdFromVector(generalId, ids);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %r14d
leaq 0x9d0(%rdi), %r15
leaq 0x8(%rdi), %rcx
movq %r15, %rdi
xorl %edx, %edx
callq 0x40c942
movq %r15, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x40c9e4
movq %r15, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x40ca08
movl %r14d, %edi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x406c93
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::ReconfigureLiuKuiTentGeneral()
void Randomizer::ReconfigureLiuKuiTentGeneral()
{
    std::vector<BYTE> tentNPCData {
        // Configure NPC info ->actual NPC ID to be set by the manipulator,
        // So we just set it to 0 for now
        0x13, 0x04, 0x97, 0x1C, 0x19, 0x19, 0x00,
        // Since there's no longer any code to execute, we need to clear
        // those extra 2 bytes too (plus move the original FF)
        0xFF, 0x00, 0x00
    };

    for (int i = 0; i < tentNPCData.size(); ++i)
    {
        myRom->WriteByte(0x31420 + i, tentNPCData[i]);
    }

    // Remove now-unused code for loading the NPC so we can reclaim
    // it for other nefarious purposes.
    const size_t NUM_EVENT_BYTES_TO_CLEAR = 11;
    for (size_t i = 0; i < NUM_EVENT_BYTES_TO_CLEAR; ++i)
    {
        myRom->WriteByte(0x36EE0 + i, 0x00);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
movabsq $-0xffe6e6e368fbed, %rax # imm = 0xFF0019191C970413
leaq -0x3a(%rbp), %rsi
movq %rax, (%rsi)
movw $0x0, 0x8(%rsi)
leaq -0x30(%rbp), %r14
leaq -0x11(%rbp), %rcx
movl $0xa, %edx
movq %r14, %rdi
callq 0x40a9ca
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x406e31
xorl %r14d, %r14d
movq (%rbx), %rdi
movzbl (%rax,%r14), %edx
leal 0x31420(%r14), %esi
callq 0x404a24
incq %r14
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rax, %rcx
cmpq %r14, %rcx
ja 0x406e0a
movq $-0xb, %r14
movq (%rbx), %rdi
leal 0x36eeb(%r14), %esi
xorl %edx, %edx
callq 0x404a24
incq %r14
jne 0x406e38
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x406e5c
callq 0x410b90
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq
jmp 0x406e67
movq %rax, %rbx
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x406e78
callq 0x410b90
movq %rbx, %rdi
callq 0x4bb660
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::MakeZone0GeneralsUnfirable()
void Randomizer::MakeZone0GeneralsUnfirable()
{
    std::vector<BYTE> newCode {
        // $60AF contains the general id
        0xAC, 0xAF, 0x60,   // LDY $60AF
        0xA9, 0x02,         // LDA #$02
        // E3C8 returns byte A of the general info of the general id in Y
        0x20, 0xC8, 0xE3,   // JSR $E3C8
        0xF0, 0x05,         // BEQ ($94E5) - the "can't fire" response
        0xD0, 0x09,         // BNE ($94EB) - the confirmation dialog
        // Now finish padding the rest of the overwritten code
        0x00, 0x00, 0x00
    };

    for (int i = 0; i < newCode.size(); ++i)
    {
        myRom->WriteByte(0x394E6 + i, newCode[i]);
    }

    // Remove the old unfirable generals list so we can reclaim
    // it for other nefarious purposes.
    const size_t NUM_EVENT_BYTES_TO_CLEAR = 17;
    for (size_t i = 0; i < NUM_EVENT_BYTES_TO_CLEAR; ++i)
    {
        myRom->WriteByte(0x39587 + i, 0x00);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
movabsq $-0x1c37dffd569f5054, %rax # imm = 0xE3C82002A960AFAC
leaq -0x3f(%rbp), %rsi
movq %rax, (%rsi)
movl $0x9d005f0, 0x8(%rsi)   # imm = 0x9D005F0
movw $0x0, 0xc(%rsi)
movb $0x0, 0xe(%rsi)
leaq -0x30(%rbp), %r14
leaq -0x11(%rbp), %rcx
movl $0xf, %edx
movq %r14, %rdi
callq 0x40a9ca
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x406ef8
xorl %r14d, %r14d
movq (%rbx), %rdi
movzbl (%rax,%r14), %edx
leal 0x394e6(%r14), %esi
callq 0x404a24
incq %r14
movq -0x30(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rax, %rcx
cmpq %r14, %rcx
ja 0x406ed1
movq $-0x11, %r14
movq (%rbx), %rdi
leal 0x39598(%r14), %esi
xorl %edx, %edx
callq 0x404a24
incq %r14
jne 0x406eff
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x406f23
callq 0x410b90
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq
jmp 0x406f2e
movq %rax, %rbx
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x406f3f
callq 0x410b90
movq %rbx, %rdi
callq 0x4bb660
nop
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::RemoveUneededEntranceTriggerCode()
void Randomizer::RemoveUneededEntranceTriggerCode()
{
    // Tie Men Xia - we don't want to remove NPCs, so the
    // code is unneeded
    // Remove the "code executed" bit
    BYTE execByte = myRom->ReadByte(0x31A2D);
    execByte &= 0xDF; // clear bit 5
    myRom->WriteByte(0x31A2D, execByte);
    // Blank out both the code-to-execute pointer (moving the
    // FF terminator as well) and the actual code
    myRom->WriteByte(0x31A31, 0xFF);
    myRom->WriteByte(0x31A32, 0x00);
    myRom->WriteByte(0x31A33, 0x00);

    const size_t NUM_EVENT_BYTES_TO_CLEAR = 15;
    for (size_t i = 0; i < NUM_EVENT_BYTES_TO_CLEAR; ++i)
    {
        myRom->WriteByte(0x3536E, 0x00);
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
movl $0x31a2d, %esi          # imm = 0x31A2D
callq 0x4049fa
andb $-0x21, %al
movq (%rbx), %rdi
movzbl %al, %edx
movl $0x31a2d, %esi          # imm = 0x31A2D
callq 0x404a24
movq (%rbx), %rdi
movl $0x31a31, %esi          # imm = 0x31A31
movl $0xff, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x31a32, %esi          # imm = 0x31A32
xorl %edx, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x31a33, %esi          # imm = 0x31A33
xorl %edx, %edx
callq 0x404a24
movl $0xf, %r14d
movq (%rbx), %rdi
movl $0x3536e, %esi          # imm = 0x3536E
xorl %edx, %edx
callq 0x404a24
decq %r14
jne 0x406fa7
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::MoveGemswordToSimaHuisHut()
void Randomizer::MoveGemswordToSimaHuisHut()
{
    // Move the actual gemsword
    myRom->WriteByte(0x30A12, 0x01);
    myRom->WriteByte(0x30A52, 0x01);
    myRom->WriteByte(0x30A92, 0x0A);
    myRom->WriteByte(0x30AD2, 0x1E);

    // Remove the gemsword room in Luo Yang
    // (Easier and nicer than removing the discolored tile
    myRom->WriteByte(0x1F6F2, 0x15);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
movl $0x30a12, %esi          # imm = 0x30A12
movl $0x1, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x30a52, %esi          # imm = 0x30A52
movl $0x1, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x30a92, %esi          # imm = 0x30A92
movl $0xa, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x30ad2, %esi          # imm = 0x30AD2
movl $0x1e, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x1f6f2, %esi          # imm = 0x1F6F2
movl $0x15, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x404a24
nop
// File: /workspace/github_cpp_makefile_star2_O3/Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::RemoveFinalIntroScreen()
void Randomizer::RemoveFinalIntroScreen()
{
    // This is just a way of freeing bytes from bank 7 in order to
    // put code in.  We free a few hundred bytes this way. We free
    // up bytes in 2 places: the code that calls the screen and
    // the text in that screen.

    const int NUM_BYTES_TO_CLEAR_CODE = 0x1DC58 - 0x1DAF9;
    const int NUM_BYTES_TO_CLEAR_TEXT = 0x1D27A - 0x1D244;

    for (int i = 0; i < NUM_BYTES_TO_CLEAR_CODE; ++i)
    {
        myRom->WriteByte(0x1DAF9, 0x00);
    }

    for (int i = 0; i < NUM_BYTES_TO_CLEAR_TEXT; ++i)
    {
        myRom->WriteByte(0x1D27A, 0x00);
    }

    // Lastly, we have to tell the code to skip over the zeroed code
    // (JMP $926A)
    myRom->WriteByte(0x1D241, 0x4C);
    myRom->WriteByte(0x1D242, 0x6A);
    myRom->WriteByte(0x1D243, 0x92);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl $0x15f, %r14d           # imm = 0x15F
movq (%rbx), %rdi
movl $0x1daf9, %esi          # imm = 0x1DAF9
xorl %edx, %edx
callq 0x404a24
decl %r14d
jne 0x4077d0
movl $0x36, %r14d
movq (%rbx), %rdi
movl $0x1d27a, %esi          # imm = 0x1D27A
xorl %edx, %edx
callq 0x404a24
decl %r14d
jne 0x4077ea
movq (%rbx), %rdi
movl $0x1d241, %esi          # imm = 0x1D241
movl $0x4c, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x1d242, %esi          # imm = 0x1D242
movl $0x6a, %edx
callq 0x404a24
movq (%rbx), %rdi
movl $0x1d243, %esi          # imm = 0x1D243
movl $0x92, %edx
popq %rbx
popq %r14
popq %rbp
jmp 0x404a24