// File: /workspace/github_cpp_makefile_star2_O3/ixchow[P]http-tweak/tweak.cpp
// Function: tweak::sync()
void sync() {
	auto &internal = get_internal();
	std::unique_lock< std::mutex > lock(internal.mutex);

	if (!internal.server) internal.server = std::make_unique< http::server >(internal.port);

	//Read adjustments (and poll requests) from the server:
	internal.server->poll([&](http::request const &request, std::unique_ptr< http::response > response){
		if (request.method == "GET" && request.url == "/") {
			//serve UI:
			std::ifstream ui(internal.ui_file, std::ios::binary);
			std::ostringstream ss;
			ss << ui.rdbuf();
			response->body = ss.str();
		} else if (request.method == "GET" && request.url == "/tweaks") {
			//serve current state (...by registering a poll):
			internal.polls.emplace_back(0, std::move(response));
		} else if (request.method == "GET" && request.url.substr(0,8) == "/tweaks?") {
			//long poll:
			uint32_t serial = -1U;
			try {
				serial = std::stoul(request.url.substr(8));
			} catch (...) {
				std::cerr << "[tweak::sync()] got invalid serial in url '" + request.url + "'." << std::endl;
				serial = -1U;
			}
			if (serial != -1U) {
				internal.polls.emplace_back(std::stoul(request.url.substr(8)), std::move(response));
			}
		} else if (request.method == "POST" && request.url == "/tweaks") {
			//adjust current state
			//std::cout << "Got tweaks:\n" << request.body << std::endl; //DEBUG

			//looking at something like: {"name":"value","name2":"value2",...}

			std::string const &json = request.body;
			uint32_t i = 0;
			auto skip_wsp = [&json,&i]() {
				while (i < json.size()
					&& (json[i] == 0x09 || json[i] == 0x0A || json[i] == 0x0D || json[i] == 0x20)
					) ++i;
			};
			auto skip_char = [&json,&i](char c) -> bool {
				if (i >= json.size()) return false;
				if (json[i] != c) return false;
				++i;
				return true;
			};
			auto extract_string = [&json, &i](std::string *into) -> bool {
				if (i >= json.size() || json[i] != '"') return false;
				uint32_t begin = i;
				++i;
				while (i < json.size() && json[i] != '"') {
					if (json[i] == '\\') ++i;
					++i;
				}
				if (i >= json.size()) return false;
				assert(json[i] == '"');
				++i;
				uint32_t end = i;
				std::string data = json.substr(begin, end - begin);
				std::string err = "";
				if (!json_to_utf8(data, into, &err)) {
					std::cerr << "Error decoding json string: " << err << std::endl;
					return false;
				}
				return true;
			};
			skip_wsp();
			if (!skip_char('{')) {
				std::cerr << "Missing opening '{'" << std::endl;
				return;
			}
			skip_wsp();
			bool first = true;
			while (i < json.size()) {
				if (json[i] == '}') break; //closing character
				if (first) {
					first = false;
				} else {
					if (!skip_char(',')) {
						std::cerr << "Missing separating ','" << std::endl;
						return;
					}
					skip_wsp();
				}
				std::string name, value;
				if (!extract_string(&name)) {
					std::cerr << "Missing name string." << std::endl;
					return;
				}
				skip_wsp();
				if (!skip_char(':')) {
					std::cerr << "Missing separating ':'" << std::endl;
					return;
				}
				skip_wsp();
				if (!extract_string(&value)) {
					std::cerr << "Missing value string." << std::endl;
					return;
				}

				//std::cout << "Received: '" << name << "':'" << value << "'" << std::endl; //DEBUG
				internal.received[name] = value;

				skip_wsp();
			}
			if (!skip_char('}')) {
				std::cerr << "Missing closing '{'" << std::endl;
				return;
			}
			skip_wsp();
			if (i < json.size()) {
				std::cerr << "Trailing garbage" << std::endl;
				return;
			}
		} else {
			response->status.code = 404;
			response->status.message = "Not Found";
			response->body = "Not Found";
			response->headers.emplace_back("Content-Type", "text/plain");
		}
	});

	//Read all adjustments from the server, and encode current state and hits:
	std::map< std::string, std::string > state;
	for (auto tweak : internal.tweaks) {
		auto f = internal.received.find(tweak->name);
		if (f != internal.received.end()) {
			try {
				tweak->deserialize(f->second);
			} catch (...) {
				std::cerr << "Failed to deserialize " << f->first << " from '" << f->second << "'" << std::endl;
			}
		}
		state[tweak->name] = "{\"hint\":" + utf8_to_json(tweak->hint) + ",\"value\":" + utf8_to_json(tweak->serialize()) + "}";
	}
	internal.received.clear();

	std::string all_state = "{\n";
	for (auto const &name_value : state) {
		if (&name_value != &(*state.begin())) all_state += ",\n";
		all_state += utf8_to_json(name_value.first) + ":" + name_value.second;
	}
	all_state += "\n}";

	//if state has changed, update serial:
	if (internal.state != all_state) {
		internal.state = all_state;
		++internal.state_serial;
	}

	//respond to polls:
	for (auto poll = internal.polls.begin(); poll != internal.polls.end(); /* later */) {
		auto next = poll;
		++next;
		if (poll->serial != internal.state_serial) {
			poll->response->body = "{\"serial\":" + std::to_string(internal.state_serial) + ",\"state\":" + internal.state + "}";
			poll->response->headers.emplace_back("Content-Type", "application/json");
			internal.polls.erase(poll);
		}
		poll = next;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
callq 0x4374
leaq 0xada8(%rip), %rax      # 0xf338
leaq -0x170(%rbp), %rbx
movq %rax, (%rbx)
movb $0x0, 0x8(%rbx)
movq %rbx, %rdi
callq 0x8efe
movb $0x1, 0x8(%rbx)
movq 0xadef(%rip), %rdi      # 0xf3a0
testq %rdi, %rdi
jne 0x461b
movl $0x30, %edi
callq 0x3370
movq %rax, %r14
movzwl 0xadce(%rip), %esi      # 0xf398
movq %rax, %rdi
callq 0x935c
movq $0x0, -0x120(%rbp)
movq 0xadbc(%rip), %rsi      # 0xf3a0
movq %r14, 0xadb5(%rip)      # 0xf3a0
testq %rsi, %rsi
je 0x4614
leaq 0xada9(%rip), %rdi      # 0xf3a0
callq 0x7b2e
movq -0x120(%rbp), %rsi
testq %rsi, %rsi
je 0x4614
leaq -0x120(%rbp), %rdi
callq 0x7b2e
movq 0xad85(%rip), %rdi      # 0xf3a0
leaq -0x120(%rbp), %rsi
movq $0x0, 0x8(%rsi)
leaq 0xace7(%rip), %rax      # 0xf318
movq %rax, (%rsi)
leaq 0xf9b(%rip), %rax       # 0x55d6
movq %rax, 0x18(%rsi)
leaq 0x19b0(%rip), %rax      # 0x5ff6
movq %rax, 0x10(%rsi)
xorps %xmm0, %xmm0
callq 0x6836
movq -0x110(%rbp), %rax
testq %rax, %rax
je 0x466f
leaq -0x120(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq -0x118(%rbp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq 0xacdb(%rip), %rax      # 0xf370
testq %rax, %rax
je 0x4adf
leaq -0x38(%rbp), %r14
leaq -0x58(%rbp), %r12
movq %rax, -0xf0(%rbp)
movq 0x8(%rax), %r13
leaq 0xad30(%rip), %rdi      # 0xf3e8
movq %r13, %rsi
callq 0x9dd8
movq %rax, %r15
leaq 0xad26(%rip), %rax      # 0xf3f0
cmpq %rax, %r15
je 0x4730
leaq -0x130(%rbp), %rax
movq %rax, -0x140(%rbp)
movq 0x40(%r15), %rsi
movq 0x48(%r15), %rdx
addq %rsi, %rdx
leaq -0x140(%rbp), %rdi
callq 0x3f36
cmpq $0x0, 0x70(%r13)
je 0x4a27
leaq 0x60(%r13), %rdi
leaq -0x140(%rbp), %rsi
callq *0x78(%r13)
movq -0x140(%rbp), %rdi
leaq -0x130(%rbp), %rax
cmpq %rax, %rdi
je 0x4730
movq -0x130(%rbp), %rsi
incq %rsi
callq 0x3380
leaq 0x20(%r13), %rsi
leaq -0xe8(%rbp), %r15
movq %r15, %rdi
callq 0x52e6
movl $0x8, %r8d
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x6aa9(%rip), %rcx      # 0xb200
callq 0x33d0
leaq -0x78(%rbp), %r15
movq %r15, -0x88(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4786
movq %rdx, -0x88(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x78(%rbp)
jmp 0x478d
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, -0x80(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x88(%rbp), %rdi
leaq 0x6a57(%rip), %rsi      # 0xb209
callq 0x35b0
movq %r14, -0x48(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
leaq -0x160(%rbp), %rbx
je 0x47de
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x47e5
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
cmpq $0x0, 0x50(%r13)
je 0x503e
leaq 0x40(%r13), %rsi
movq %rbx, %rdi
callq *0x58(%r13)
leaq -0xc8(%rbp), %rdi
movq %rbx, %rsi
callq 0x52e6
movq -0x48(%rbp), %rcx
movl $0xf, %edi
cmpq %r14, %rcx
je 0x4833
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %r8
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
jbe 0x486b
movl $0xf, %edi
leaq -0xb8(%rbp), %r9
cmpq %r9, %rsi
je 0x4866
movq -0xb8(%rbp), %rdi
cmpq %rdi, %rax
jbe 0x4876
leaq -0x48(%rbp), %rdi
callq 0x3130
jmp 0x4886
leaq -0xc8(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x33d0
movq %r12, -0x68(%rbp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x48a3
movq %rdx, -0x68(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x58(%rbp)
jmp 0x48ab
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x60(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq -0x68(%rbp), %rdi
leaq 0x6948(%rip), %rsi      # 0xb21a
callq 0x35b0
leaq -0x98(%rbp), %rsi
movq %rsi, -0xa8(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4907
movq %rdx, -0xa8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x98(%rbp)
jmp 0x490d
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0xa0(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x120(%rbp), %rdi
movq %r13, %rsi
callq 0x7084
movq %rax, %rdi
leaq -0xa8(%rbp), %rsi
callq 0x3400
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x4967
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x497c
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x499e
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x160(%rbp), %rdi
leaq -0x150(%rbp), %rax
cmpq %rax, %rdi
je 0x49c0
movq -0x150(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0x49d5
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x49ed
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x4a0f
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0xf0(%rbp), %rax
movq (%rax), %rax
testq %rax, %rax
jne 0x46a6
jmp 0x4adf
callq 0x3190
jmp 0x5043
movq %rax, %rbx
jmp 0x4a5b
movq %rax, %rbx
movq -0x140(%rbp), %rdi
leaq -0x130(%rbp), %rax
cmpq %rax, %rdi
je 0x4a5b
movq -0x130(%rbp), %rsi
incq %rsi
callq 0x3380
movq %rbx, %rdi
callq 0x31b0
movl $0x16, %edx
movq 0xa579(%rip), %rdi      # 0xefe8
leaq 0x676b(%rip), %rsi      # 0xb1e1
callq 0x33e0
movq 0x20(%r15), %rsi
movq 0x28(%r15), %rdx
movq 0xa55e(%rip), %rdi      # 0xefe8
callq 0x33e0
movq %rax, %rbx
movl $0x7, %edx
movq %rax, %rdi
leaq 0x6757(%rip), %rsi      # 0xb1f8
callq 0x33e0
movq 0x40(%r15), %rsi
movq 0x48(%r15), %rdx
movq %rbx, %rdi
callq 0x33e0
movq %rax, %r15
movl $0x1, %edx
movq %rax, %rdi
leaq 0x6be7(%rip), %rsi      # 0xb6af
callq 0x33e0
movq %r15, %rdi
callq 0x31d0
callq 0x3530
jmp 0x4730
leaq 0xa902(%rip), %rdi      # 0xf3e8
callq 0x9e28
leaq -0x98(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x6716(%rip), %rsi      # 0xb213
leaq 0x6711(%rip), %rdx      # 0xb215
leaq -0xa8(%rbp), %rdi
callq 0x3e98
movq -0x108(%rbp), %rbx
leaq -0x118(%rbp), %rax
cmpq %rax, %rbx
je 0x4c6f
leaq -0x38(%rbp), %r15
leaq -0x58(%rbp), %r12
leaq -0x88(%rbp), %r14
leaq -0xa8(%rbp), %r13
cmpq -0x108(%rbp), %rbx
je 0x4b55
movq %r13, %rdi
leaq 0x66c6(%rip), %rsi      # 0xb216
callq 0x35b0
leaq 0x20(%rbx), %rsi
movq %r14, %rdi
callq 0x52e6
movq %r14, %rdi
leaq 0x66c4(%rip), %rsi      # 0xb22f
callq 0x35b0
movq %r15, -0x48(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4b90
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x4b97
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x40(%rbx), %rsi
movq 0x48(%rbx), %rdx
leaq -0x48(%rbp), %rdi
callq 0x3130
movq %r12, -0x68(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4bdf
movq %rdx, -0x68(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x58(%rbp)
jmp 0x4be7
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, -0x60(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %r13, %rdi
callq 0x3130
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x4c23
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x4c38
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x4c54
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x3380
movq %rbx, %rdi
callq 0x32c0
movq %rax, %rbx
leaq -0x118(%rbp), %rax
cmpq %rax, %rbx
jne 0x4b3d
leaq 0x65a3(%rip), %rsi      # 0xb219
leaq -0xa8(%rbp), %rdi
callq 0x35b0
movq 0xa747(%rip), %rdx      # 0xf3d0
cmpq -0xa0(%rbp), %rdx
jne 0x4cae
testq %rdx, %rdx
je 0x4cc7
movq -0xa8(%rbp), %rsi
movq 0xa723(%rip), %rdi      # 0xf3c8
callq 0x3390
testl %eax, %eax
je 0x4cc7
leaq 0xa713(%rip), %rdi      # 0xf3c8
leaq -0xa8(%rbp), %rsi
callq 0x3220
incl 0xa6f9(%rip)            # 0xf3c0
movq 0xa6da(%rip), %r14      # 0xf3a8
leaq 0xa6d3(%rip), %rax      # 0xf3a8
cmpq %rax, %r14
je 0x4ff2
leaq -0x78(%rbp), %rbx
leaq -0x38(%rbp), %r13
movl 0xa6d3(%rip), %r15d     # 0xf3c0
leaq -0xc8(%rbp), %r12
movl $0xd1b71759, %esi       # imm = 0xD1B71759
movq (%r14), %rcx
cmpl %r15d, 0x10(%r14)
je 0x4fe6
movq %rcx, -0xf0(%rbp)
movl $0x1, %eax
cmpl $0xa, %r15d
jb 0x4d58
movl $0x4, %eax
movl %r15d, %ecx
cmpl $0x63, %ecx
jbe 0x4d51
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x4d56
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x4d58
movl %ecx, %edx
imulq %rsi, %rdx
shrq $0x2d, %rdx
addl $0x4, %eax
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x4d20
addl $-0x3, %eax
jmp 0x4d58
addl $-0x2, %eax
jmp 0x4d58
decl %eax
movl %eax, %esi
leaq -0xb8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq %r12, %rdi
xorl %edx, %edx
callq 0x33f0
movq -0xc8(%rbp), %rdi
movl -0xc0(%rbp), %esi
movl %r15d, %edx
callq 0x78f0
movl $0xa, %r8d
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x6481(%rip), %rcx      # 0xb21c
callq 0x33d0
leaq -0xd8(%rbp), %r12
movq %r12, -0xe8(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4dd0
movq %rdx, -0xe8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xd8(%rbp)
jmp 0x4dd8
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, -0xe0(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0xe8(%rbp), %rdi
leaq 0x6427(%rip), %rsi      # 0xb227
callq 0x35b0
movq %rbx, -0x88(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4e2b
movq %rdx, -0x88(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x78(%rbp)
jmp 0x4e31
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, -0x80(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0xa579(%rip), %rsi      # 0xf3c8
movq 0xa57a(%rip), %rdx      # 0xf3d0
leaq -0x88(%rbp), %rdi
callq 0x3130
movq %r13, -0x48(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4e82
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x4e8a
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x48(%rbp), %rdi
leaq 0x636e(%rip), %rsi      # 0xb21a
callq 0x35b0
leaq -0x58(%rbp), %r15
movq %r15, -0x68(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4ed5
movq %rdx, -0x68(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x58(%rbp)
jmp 0x4edc
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, -0x60(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x18(%r14), %rdi
addq $0x40, %rdi
leaq -0x68(%rbp), %rsi
callq 0x3400
movq -0x68(%rbp), %rdi
cmpq %r15, %rdi
je 0x4f19
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x4f2e
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x88(%rbp), %rdi
cmpq %rbx, %rdi
je 0x4f46
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0xe8(%rbp), %rdi
cmpq %r12, %rdi
je 0x4f61
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
leaq -0xc8(%rbp), %r12
je 0x4f8a
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x3380
leaq 0x18(%r14), %r15
movq (%r15), %rdi
addq $0x28, %rdi
leaq 0x6295(%rip), %rsi      # 0xb231
leaq 0x629b(%rip), %rdx      # 0xb23e
callq 0x7104
decq 0xa409(%rip)            # 0xf3b8
movq %r14, %rdi
callq 0x3520
movq %r15, %rdi
callq 0x7150
movl $0x20, %esi
movq %r14, %rdi
callq 0x3380
movl 0xa3ed(%rip), %r15d     # 0xf3c0
leaq 0xa3ce(%rip), %rax      # 0xf3a8
movl $0xd1b71759, %esi       # imm = 0xD1B71759
movq -0xf0(%rbp), %rcx
movq %rcx, %r14
cmpq %rax, %rcx
jne 0x4cf9
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x5014
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x3380
leaq -0x120(%rbp), %rdi
callq 0x8e4e
leaq -0x170(%rbp), %rdi
callq 0x681c
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3190
movq %rax, %rbx
callq 0x3530
jmp 0x52c6
jmp 0x509f
movq %rax, %rbx
movl $0x30, %esi
movq %r14, %rdi
callq 0x3380
jmp 0x52d2
movq %rax, %rbx
jmp 0x52d2
jmp 0x509f
jmp 0x51c4
movq %rax, %rbx
movq -0x110(%rbp), %rax
testq %rax, %rax
je 0x52d2
leaq -0x120(%rbp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x52d2
movq %rax, %rdi
callq 0x3e8a
jmp 0x5147
movq %rax, %r14
jmp 0x5137
movq %rax, %r14
jmp 0x50f3
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x50db
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3380
jmp 0x50db
movq %rax, %r14
jmp 0x5115
movq %rax, %r14
movq -0x88(%rbp), %rdi
cmpq %rbx, %rdi
je 0x50f3
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x5115
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x5137
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x3380
leaq -0x98(%rbp), %rax
movq %r14, %rbx
jmp 0x51a6
jmp 0x5147
jmp 0x5147
movq %rax, %rbx
jmp 0x519f
movq %rax, %rbx
jmp 0x5183
movq %rax, %rbx
jmp 0x516e
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x516e
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x5183
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x519f
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x3380
leaq -0x98(%rbp), %rax
movq -0xa8(%rbp), %rdi
cmpq %rax, %rdi
je 0x52c6
movq -0x98(%rbp), %rsi
jmp 0x52be
jmp 0x51c4
movq %rax, %rbx
jmp 0x52c6
movq %rax, %rbx
jmp 0x52a4
movq %rax, %rbx
jmp 0x528c
jmp 0x5270
movq %rax, %rbx
jmp 0x524c
movq %rax, %rbx
jmp 0x522a
movq %rax, %rbx
jmp 0x5215
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x5215
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x522a
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x524c
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0x160(%rbp), %rdi
leaq -0x150(%rbp), %rax
cmpq %rax, %rdi
je 0x5273
movq -0x150(%rbp), %rsi
incq %rsi
callq 0x3380
jmp 0x5273
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0x5288
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x3380
leaq -0x78(%rbp), %r15
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x52a4
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x3380
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x52c6
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x3380
leaq -0x120(%rbp), %rdi
callq 0x8e4e
leaq -0x170(%rbp), %rdi
callq 0x681c
movq %rbx, %rdi
callq 0x3570