// File: /workspace/github_c_makefile_star2_O3/qpfiffer[P]38-Moths/src/grengine.c
// Function: m38_generate_response
m38_handled_request *m38_generate_response(const int accept_fd, const m38_app *app) {
	unsigned char *to_read = calloc(1, MAX_READ_LEN);
	char *actual_response = NULL;
	m38_http_response response = {
		.mimetype = {0},
		0
	};
	response.extra_headers = vector_new(sizeof(m38_header_pair *), 4);

	m38_handled_request *hreq = NULL;
	const m38_route *matching_route = NULL;
	size_t num_read = 0;
	int rc = 0;

	rc = read_max_bytes_from_socket(accept_fd, &to_read, &num_read);
	if (rc != 0)
		goto error;

	m38_http_request request = {
		.verb = {0},
		.resource = {0},
		.matches = {{0}},
		.header_len = 0,
		.full_header = NULL,
		.body_len = 0,
		.full_body = NULL
	};

	rc = m38_parse_request(to_read, num_read, &request);
	if (rc != 0) {
		m38_log_msg(LOG_ERR, "Could not parse request.");
		goto error;
	}

	char *clength = m38_get_header_value_raw(request.full_header, request.header_len, "Content-Length");
	size_t clength_num = 0;
	if (clength == NULL) {
		m38_log_msg(LOG_WARN, "Could not parse content length.");
	} else {
		clength_num = atoi(clength);
		free(clength);
	}

	/* Do we have a POST body or something? */
	const size_t post_body_len = num_read - request.header_len;
	if (post_body_len <= 0 && clength_num > 0) {
		/* re-read will just copy into the m38_http_request. */
		rc = attempt_reread_from_socket(accept_fd, clength_num, post_body_len, &request);
		if (rc != 0) {
			m38_log_msg(LOG_ERR, "Could not reread from socket and parse body.");
			goto error;
		}
	} else {
		rc = m38_parse_body(post_body_len, clength_num, to_read, &request);
		if (rc != 0) {
			m38_log_msg(LOG_ERR, "Could not parse body.");
			goto error;
		}
	}

	/* Parses form encoding, if applicable: */
	const char form_encoding[] = "application/x-www-form-urlencoded";
	const size_t form_encoding_siz = strlen(form_encoding);
	char *content_type = m38_get_header_value_request(&request, "Content-Type");

	if (content_type &&
			strlen(content_type) >= form_encoding_siz &&
			strncmp(form_encoding, content_type, form_encoding_siz) == 0) {
		rc = m38_parse_form_encoded_body(&request);
		if (rc != 0) {
			/* application/x-www-form-urlencoded */
			m38_log_msg(LOG_ERR, "Could not parse form-urlencoded body.");
			goto error;
		}
	
	}

	/* Find our matching route: */
	int64_t i;
	for (i = 0; i < app->num_routes; i++) {
		const m38_route *cur_route = &app->routes[i];
		if (strcmp(cur_route->verb, request.verb) != 0)
			continue;

		assert(cur_route->expected_matches < MAX_MATCHES);
		regex_t regex;
		int reti = regcomp(&regex, cur_route->route_match, REG_EXTENDED);
		if (reti != 0) {
			char errbuf[128];
			regerror(reti, &regex, errbuf, sizeof(errbuf));
			m38_log_msg(LOG_ERR, "%s", errbuf);
			assert(reti == 0);
		}

		if (cur_route->expected_matches > 0)
			reti = regexec(&regex, request.resource, cur_route->expected_matches + 1, request.matches, 0);
		else
			reti = regexec(&regex, request.resource, 0, NULL, 0);
		regfree(&regex);
		if (reti == 0) {
			matching_route = &app->routes[i];
			break;
		}
	}

	/* If we didn't find one just use the 404 route: */
	int64_t response_code = 0;
	if (matching_route == NULL) {
		matching_route = &r_404_route;
		response_code = 404;
		if (app->r_404_route) {
			m38_log_msg(LOG_INFO, "Setting custom 404 handler for %s.", matching_route->name);
			matching_route = app->r_404_route;
		} else {
			m38_log_msg(LOG_INFO, "Using internal 404 handler for %s.", matching_route->name);
		}
	} else {
		/* Run the handler through with the data we have: */
		m38_log_msg(LOG_INFO, "Calling handler for %s.", matching_route->name);
		response_code = matching_route->handler(&request, &response);
	}

	/* It doesn't seem like you actually need the response.outsize and .out checks here,
	 * but this makes it so that a view function can return a 404 and the 404 handler will
	 * be called. Very nifty.
	 */
	if (response_code == 404 && (response.outsize == 0 || response.out == NULL)) {
		m38_log_msg(LOG_INFO, "No response gen: Calling 404 handler for %s.", matching_route->name);
		matching_route = &r_404_route;

		if (app->r_404_route) {
			m38_log_msg(LOG_INFO, "Setting custom 404 handler for %s.", matching_route->name);
			matching_route = app->r_404_route;
		} else {
			m38_log_msg(LOG_INFO, "Using internal 404 handler for %s.", matching_route->name);
		}

		if (matching_route->handler) {
			response_code = matching_route->handler(&request, &response);
		} else {
			m38_log_msg(LOG_ERR, "No handler for route %s.", matching_route->name);
		}
	}

	/* Embed the handler's text into the header: */
	size_t header_size = 0;
	size_t actual_response_siz = 0;

	/* Figure out if this thing needs to be partial */
	char *range_header_value = m38_get_header_value_raw(request.full_header, request.header_len, "Range");
	if (range_header_value && RESPONSE_OK(response_code)) {
		response_code = 206;
	}

	/* Figure out what header we need to use: */
	const code_to_message *matched_response = NULL;
	const code_to_message *response_headers = get_response_headers();
	const int64_t num_elements = get_response_headers_num_elements();
	for (i = 0; i < num_elements; i++) {
		code_to_message current_response = response_headers[i];
		if (current_response.code == response_code) {
			matched_response = &response_headers[i];
			break;
		}
	}
	/* Blow up if we don't have that code. We should have them all at
	 * compile time. */
	assert(matched_response != NULL);

	if (response_code == 200 || response_code == 404 || response_code == 301 ||
			response_code == 302 ||response_code == 400 || response_code == 403 ||
			response_code == 500) {
		const size_t integer_length = UINT_LEN(response.outsize);
		if (response.mimetype[0] == '\0')
			memcpy(response.mimetype, "text/html", strlen("text/html"));

		header_size = strlen(response.mimetype) + strlen(matched_response->message)
			+ integer_length - strlen("%s") - strlen("%zu") + strlen(r_final);

		size_t i = 0;
		for (i = 0; i < response.extra_headers->count; i++) {
			m38_header_pair **pair = (m38_header_pair **)vector_get(response.extra_headers, i);
			header_size += (*pair)->header_len + strlen(": ") + (*pair)->value_len
								    + strlen("\r\n");
		}
		actual_response_siz = response.outsize + header_size;
		actual_response = malloc(actual_response_siz + 1);
		memset(actual_response, '\0', actual_response_siz);
		actual_response[actual_response_siz] = '\0';

		/* snprintf the header because it's just a string: */
		snprintf(actual_response, actual_response_siz, matched_response->message, response.mimetype, response.outsize);
		for (i = 0; i < response.extra_headers->count; i++) {
			m38_header_pair **pair = (m38_header_pair **)vector_get(response.extra_headers, i);
			const size_t siz = (*pair)->header_len + strlen(": ") + (*pair)->value_len
								    + strlen("\r\n") + 1;
			char buf[siz];
			buf[siz] = '\0';
			snprintf(buf, actual_response_siz, "%s: %s\r\n", (*pair)->header, (*pair)->value);
			strncat(actual_response, buf, siz);
		}
		strcat(actual_response, r_final);

		/* memcpy the rest because it could be anything: */
		memcpy(actual_response + header_size, response.out, response.outsize);
	} else if (response_code == 206) {
		/* Byte range queries have some extra shit. */
		m38_range_header byte_range = m38_parse_range_header(range_header_value);
		/* TODO: Add the custom header stuff here (for 206), too. */

		m38_log_msg(LOG_INFO, "Range header parsed: Raw: %s Limit: %zu Offset: %zu", range_header_value, byte_range.limit, byte_range.offset);
		free(range_header_value);

		size_t end_byte = 0;
		if (byte_range.limit == 0) {
			end_byte = response.outsize - 1;
		} else {
			end_byte = (response.outsize - byte_range.limit) - 1;
		}

		if (end_byte >= response.outsize)
			end_byte = response.outsize - 1;
		const size_t start_byte = byte_range.offset < response.outsize ? byte_range.offset : 0;
		const size_t max_size = response.outsize; /* Should be the same as file size. */
		const size_t integer_length = UINT_LEN(max_size);

		const size_t minb_len = start_byte == 0 ? 1 : UINT_LEN(start_byte);
		const size_t maxb_len = end_byte == 0 ? 1 : UINT_LEN(end_byte);
		/* Compute the size of the header */
		header_size = strlen(response.mimetype) + strlen(matched_response->message) + strlen(r_final)
			+ integer_length + minb_len + maxb_len + integer_length
			- strlen("%s") - (strlen("%zu") * 4);
		actual_response_siz = max_size + header_size;
		/* malloc the full response */
		actual_response = malloc(actual_response_siz + 1);
		actual_response[actual_response_siz] = '\0';

		/* snprintf the header because it's just a string: */
		snprintf(actual_response, actual_response_siz, matched_response->message,
			response.mimetype, max_size,
			start_byte, end_byte, max_size);
		m38_log_msg(LOG_INFO, "Sending back: Content-Range: %zu-%zu/%zu", start_byte, end_byte, max_size);

		strcat(actual_response, r_final);

		/* memcpy the rest because it could be anything: */
		memcpy(actual_response + header_size, response.out + start_byte, end_byte - start_byte);
	}

	log_request(&request, &response, response_code);

	hreq = malloc(sizeof(m38_handled_request));
	hreq->response_bytes = actual_response;
	hreq->response_len = actual_response_siz;
	hreq->response_code = response_code;
	hreq->accept_fd = accept_fd;
	hreq->sent = 0;
	hreq->matching_route = matching_route;
	memcpy(&hreq->response, &response, sizeof(response));

	free(to_read);
	free(request.full_header);
	free(request.full_body);
	free(request.form_elements);
	return hreq;

error:
	if (matching_route != NULL && matching_route->cleanup != NULL)
		matching_route->cleanup(500, &response);
	free(actual_response);
	free(to_read);
	free(request.full_header);
	free(request.full_body);
	free(request.form_elements);
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3a8, %rsp            # imm = 0x3A8
movq %rsi, %r15
movl %edi, %r13d
movl $0x1, %edi
movl $0x400, %esi            # imm = 0x400
callq 0x32e0
leaq -0xb0(%rbp), %rbx
movq %rax, (%rbx)
xorl %r14d, %r14d
movq %r14, -0x60(%rbp)
xorpd %xmm0, %xmm0
movapd %xmm0, -0x70(%rbp)
movapd %xmm0, -0x80(%rbp)
movapd %xmm0, -0x90(%rbp)
movl $0x8, %edi
movl $0x4, %esi
callq 0x3410
movq %rax, -0x58(%rbp)
leaq -0xa8(%rbp), %rdx
movq %r14, (%rdx)
movl %r13d, %edi
movq %rbx, %rsi
callq 0x5aac
movq (%rbx), %r14
testl %eax, %eax
jne 0x5108
leaq -0x348(%rbp), %rbx
movl $0x258, %edx            # imm = 0x258
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3220
movq -0xa8(%rbp), %r12
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x3250
testl %eax, %eax
je 0x4fe1
leaq 0x525a(%rip), %rsi      # 0xa236
jmp 0x50fc
movl %r13d, -0x2c(%rbp)
movq -0x118(%rbp), %rdi
movq -0x110(%rbp), %rsi
leaq 0x5255(%rip), %rdx      # 0xa24f
callq 0x3210
testq %rax, %rax
je 0x50bc
movq %rax, %rbx
movq %rax, %rdi
callq 0x3530
movslq %eax, %r13
movq %rbx, %rdi
callq 0x3050
movq -0x110(%rbp), %rax
cmpq %rax, %r12
sete %cl
testl %r13d, %r13d
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x50d9
leaq -0xf0(%rbp), %rbx
movq $0x0, (%rbx)
movl $0x1, %edi
movl $0x400, %esi            # imm = 0x400
callq 0x32e0
leaq -0x3d0(%rbp), %r12
movq %rax, (%r12)
leaq 0x5548(%rip), %rsi      # 0xa5b3
movl $0x2, %edi
movq %r13, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3540
leaq 0x5567(%rip), %rsi      # 0xa5ea
movl $0x2, %edi
movq %r13, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x3540
movl -0x2c(%rbp), %edi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x5aac
movq (%r12), %rdi
testl %eax, %eax
je 0x5148
callq 0x3050
leaq 0x51c4(%rip), %rsi      # 0xa27e
jmp 0x50fc
leaq 0x519b(%rip), %rsi      # 0xa25e
xorl %r13d, %r13d
movl $0x2, %edi
xorl %eax, %eax
callq 0x3540
movq -0x110(%rbp), %rax
subq %rax, %r12
leaq -0x348(%rbp), %rcx
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x3420
testl %eax, %eax
je 0x515d
leaq 0x51af(%rip), %rsi      # 0xa2ab
movl $0x3, %edi
xorl %eax, %eax
callq 0x3540
movq %r14, %rdi
callq 0x3050
xorl %ebx, %ebx
movq -0x118(%rbp), %rdi
callq 0x3050
movq -0x108(%rbp), %rdi
callq 0x3050
movq -0xf8(%rbp), %rdi
callq 0x3050
movq %rbx, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0xf0(%rbp), %rax
movq %rdi, -0x108(%rbp)
movq %rax, -0x100(%rbp)
leaq 0x515d(%rip), %rsi      # 0xa2c1
leaq -0x348(%rbp), %rdi
callq 0x3040
testq %rax, %rax
je 0x51a2
movq %rax, %rbx
movq %rax, %rdi
callq 0x3150
cmpq $0x21, %rax
jb 0x51a2
leaq 0x54c3(%rip), %rdi      # 0xa650
movl $0x21, %edx
movq %rbx, %rsi
callq 0x30b0
testl %eax, %eax
je 0x5a1b
movl 0x18(%r15), %ebx
testl %ebx, %ebx
jle 0x5273
xorl %r14d, %r14d
xorl %r13d, %r13d
movq 0x10(%r15), %r12
leaq (%r12,%r14), %rdi
leaq -0x348(%rbp), %rsi
callq 0x32f0
testl %eax, %eax
jne 0x525d
cmpq $0x4, 0x150(%r12,%r14)
jae 0x5a3b
leaq (%r12,%r14), %rsi
addq $0x50, %rsi
leaq -0xf0(%rbp), %rdi
movl $0x1, %edx
callq 0x32c0
testl %eax, %eax
jne 0x5a5a
movq 0x150(%r12,%r14), %rdx
testq %rdx, %rdx
je 0x522a
incq %rdx
leaq -0xf0(%rbp), %r12
movq %r12, %rdi
leaq -0x338(%rbp), %rsi
leaq -0x138(%rbp), %rcx
jmp 0x523f
leaq -0xf0(%rbp), %r12
movq %r12, %rdi
leaq -0x338(%rbp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3400
movl %eax, %ebx
movq %r12, %rdi
callq 0x3140
testl %ebx, %ebx
je 0x536a
movl 0x18(%r15), %ebx
incq %r13
movslq %ebx, %rax
addq $0x168, %r14            # imm = 0x168
cmpq %rax, %r13
jl 0x51b4
cmpq $0x0, 0x20(%r15)
je 0x5297
leaq 0x50fd(%rip), %rsi      # 0xa37e
leaq 0x9a08(%rip), %rdx      # 0xec90
xorl %edi, %edi
xorl %eax, %eax
callq 0x3540
movq 0x20(%r15), %r13
jmp 0x52b5
leaq 0x5103(%rip), %rsi      # 0xa3a1
leaq 0x99eb(%rip), %rdx      # 0xec90
xorl %edi, %edi
xorl %eax, %eax
callq 0x3540
leaq 0x99cb(%rip), %r13      # 0xec80
movl -0x2c(%rbp), %r12d
cmpq $0x0, -0x88(%rbp)
movl $0x194, %r14d           # imm = 0x194
je 0x52d7
cmpq $0x0, -0x90(%rbp)
jne 0x53bc
addq $0x10, %r13
leaq 0x50fa(%rip), %rsi      # 0xa3dc
xorl %edi, %edi
movq %r13, %rdx
xorl %eax, %eax
callq 0x3540
cmpq $0x0, 0x20(%r15)
je 0x5312
leaq 0x5082(%rip), %rsi      # 0xa37e
leaq 0x998d(%rip), %rdx      # 0xec90
xorl %edi, %edi
xorl %eax, %eax
callq 0x3540
movq 0x20(%r15), %r13
jmp 0x5330
leaq 0x5088(%rip), %rsi      # 0xa3a1
leaq 0x9970(%rip), %rdx      # 0xec90
xorl %edi, %edi
xorl %eax, %eax
callq 0x3540
leaq 0x9950(%rip), %r13      # 0xec80
movq 0x158(%r13), %rax
testq %rax, %rax
je 0x5351
leaq -0x348(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq *%rax
movslq %eax, %r14
jmp 0x53bc
leaq 0x10(%r13), %rdx
leaq 0x50ad(%rip), %rsi      # 0xa409
movl $0x3, %edi
xorl %eax, %eax
callq 0x3540
jmp 0x53bc
movq 0x10(%r15), %rax
testq %rax, %rax
je 0x5273
leaq (%rax,%r14), %r13
leaq (%rax,%r14), %rbx
addq $0x10, %rbx
leaq 0x503a(%rip), %rsi      # 0xa3c4
xorl %edi, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3540
leaq -0x348(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq *0x148(%rbx)
cmpl $0x194, %eax            # imm = 0x194
je 0x52b5
movslq %eax, %r14
movl -0x2c(%rbp), %r12d
movq -0x118(%rbp), %rdi
movq -0x110(%rbp), %rsi
leaq 0x5051(%rip), %rdx      # 0xa422
callq 0x3210
movq %rax, %rbx
leaq -0xc8(%r14), %rax
cmpq $0xc8, %rax
movl $0xce, %ecx
cmovaeq %r14, %rcx
testq %rbx, %rbx
cmoveq %r14, %rcx
xorl %r15d, %r15d
leaq 0x9800(%rip), %r14      # 0xec00
movslq (%r15,%r14), %rax
cmpq %rax, %rcx
je 0x5435
addq $0x10, %r15
cmpq $0x80, %r15
jne 0x5400
leaq 0x500b(%rip), %rdi      # 0xa428
leaq 0x4efa(%rip), %rsi      # 0xa31e
leaq 0x4f02(%rip), %rcx      # 0xa32d
movl $0x21e, %edx            # imm = 0x21E
callq 0x3200
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
cmpq $0x18f, %rcx            # imm = 0x18F
movq %rcx, -0x48(%rbp)
jg 0x5702
leaq -0x12d(%rcx), %rax
cmpq $0x2, %rax
jb 0x5728
cmpq $0xc8, -0x48(%rbp)
je 0x5728
cmpq $0xce, -0x48(%rbp)
jne 0x5918
movq %r13, -0x50(%rbp)
movq %rbx, %rdi
callq 0x3580
movq %rax, %r12
movq %rdx, %r13
leaq 0x4fae(%rip), %rsi      # 0xa44a
xorl %edi, %edi
movq %rbx, %rdx
movq %rax, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x3540
movq %rbx, %rdi
callq 0x3050
xorl %edx, %edx
movq -0x88(%rbp), %rdi
movq %r12, %rsi
notq %rsi
addq %rdi, %rsi
leaq -0x1(%rdi), %rax
leaq -0x1(%rdi), %rcx
testq %r12, %r12
cmoveq %rcx, %rax
cmoveq %rcx, %rsi
cmpq %rdi, %rsi
cmovaeq %rax, %rsi
cmpq %rdi, %r13
cmovbq %r13, %rdx
movl $0x8, %r13d
movq %rdi, -0x38(%rbp)
cmpq $0x1, %rdi
movq %rdx, -0x98(%rbp)
jb 0x5566
movsd -0x38(%rbp), %xmm1
unpcklps 0x4bb4(%rip), %xmm1     # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x4bbc(%rip), %xmm1     # 0xa0d0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %rsi, %rbx
callq 0x3310
callq 0x3520
movq %rbx, %rsi
addsd 0x4ba8(%rip), %xmm0     # 0xa0e0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd 0x4ba0(%rip), %xmm0     # 0xa0e8
cvttsd2si %xmm0, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
leaq 0x6(,%rdx,2), %r13
movq -0x98(%rbp), %rdx
movl $0x1, %r12d
movl $0x1, %ebx
testq %rdx, %rdx
je 0x55ce
movq %rdx, %xmm1
punpckldq 0x4b3d(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x4b45(%rip), %xmm1     # 0xa0d0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq %rsi, %rbx
callq 0x3310
callq 0x3520
movq %rbx, %rsi
addsd 0x4b31(%rip), %xmm0     # 0xa0e0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x4b25(%rip), %xmm0     # 0xa0e8
cvttsd2si %xmm0, %rbx
andq %rcx, %rbx
orq %rax, %rbx
movq %rsi, -0xa0(%rbp)
testq %rsi, %rsi
je 0x562e
movsd -0xa0(%rbp), %xmm1
unpcklps 0x4ad7(%rip), %xmm1     # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x4adf(%rip), %xmm1     # 0xa0d0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
callq 0x3310
callq 0x3520
addsd 0x4ad1(%rip), %xmm0     # 0xa0e0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x4ac5(%rip), %xmm0     # 0xa0e8
cvttsd2si %xmm0, %r12
andq %rcx, %r12
orq %rax, %r12
leaq -0x80(%rbp), %rdi
callq 0x3150
movq %rax, -0x40(%rbp)
movq 0x8(%r15,%r14), %r15
movq %r15, %rdi
callq 0x3150
addq %rbx, %r13
addq %r12, %r13
addq -0x40(%rbp), %r13
addq %rax, %r13
movq -0x38(%rbp), %r12
leaq (%r12,%r13), %rbx
leaq (%r12,%r13), %rdi
incq %rdi
callq 0x33a0
movq %rax, %r14
movb $0x0, (%rax,%rbx)
movq %rax, %rdi
movq %rbx, -0x40(%rbp)
movq %rbx, %rsi
movq %r15, %rdx
leaq -0x80(%rbp), %rcx
movq %r12, %r8
movq -0x98(%rbp), %rbx
movq %rbx, %r9
xorl %eax, %eax
pushq %r12
movq -0xa0(%rbp), %r15
pushq %r15
callq 0x31e0
addq $0x10, %rsp
leaq 0x4dd3(%rip), %rsi      # 0xa47e
xorl %edi, %edi
movq %rbx, %rdx
movq %r15, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x3540
movq %r14, %rdi
callq 0x3150
movabsq $0xa0d0a0d736874, %rcx  # imm = 0xA0D0A0D736874
movq %rcx, 0xd(%r14,%rax)
movapd 0x4fa4(%rip), %xmm0     # 0xa680
movupd %xmm0, (%r14,%rax)
movq %r14, -0x38(%rbp)
addq %r14, %r13
subq %rbx, %r15
leaq -0x80(%rbp), %rax
addq -0x10(%rax), %rbx
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
jmp 0x590b
leaq -0x190(%rcx), %rax
cmpq $0x4, %rax
ja 0x571a
movl $0x19, %ecx
btq %rax, %rcx
jb 0x5728
cmpq $0x1f4, -0x48(%rbp)     # imm = 0x1F4
jne 0x5918
movq %r13, -0x50(%rbp)
movq -0x88(%rbp), %rax
testq %rax, %rax
je 0x5790
movq %rax, %xmm1
punpckldq 0x497b(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x4983(%rip), %xmm1     # 0xa0d0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
callq 0x3310
callq 0x3520
addsd 0x4975(%rip), %xmm0     # 0xa0e0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd 0x496d(%rip), %xmm0     # 0xa0e8
cvttsd2si %xmm0, %r13
sarq $0x3f, %rcx
andq %rcx, %r13
orq %rax, %r13
addq $0xf, %r13
jmp 0x5796
movl $0x10, %r13d
leaq -0x80(%rbp), %rdi
cmpb $0x0, (%rdi)
jne 0x57b0
movabsq $0x6d74682f74786574, %rax # imm = 0x6D74682F74786574
movq %rax, (%rdi)
movb $0x6c, 0x8(%rdi)
callq 0x3150
movq %rax, %r12
movq 0x8(%r15,%r14), %rbx
movq %rbx, %rdi
callq 0x3150
addq %r12, %r13
addq %rax, %r13
movq -0x58(%rbp), %rdi
cmpq $0x0, 0x10(%rdi)
je 0x5803
xorl %ebx, %ebx
movl %ebx, %esi
callq 0x3170
movq (%rax), %rax
movq 0x18(%rax), %rcx
addq 0x8(%rax), %r13
addq %rcx, %r13
addq $0x4, %r13
incq %rbx
movq -0x58(%rbp), %rdi
cmpq 0x10(%rdi), %rbx
jb 0x57d8
movq 0x8(%r15,%r14), %rbx
movq -0x88(%rbp), %r14
leaq (%r14,%r13), %r12
leaq (%r14,%r13), %rdi
incq %rdi
callq 0x33a0
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x3220
movb $0x0, (%r15,%r12)
movq %r15, -0x38(%rbp)
movq %r15, %rdi
movq %r12, -0x40(%rbp)
movq %r12, %rsi
movq %rbx, %rdx
leaq -0x80(%rbp), %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x31e0
movq -0x58(%rbp), %rdi
cmpq $0x0, 0x10(%rdi)
je 0x58cf
xorl %ebx, %ebx
movl %ebx, %esi
callq 0x3170
movq %rsp, %r14
movq (%rax), %rcx
movq 0x8(%rcx), %rdx
movq 0x18(%rcx), %rcx
leaq (%rdx,%rcx), %r15
addq $0x5, %r15
addq %rdx, %rcx
addq $0x14, %rcx
andq $-0x10, %rcx
movq %rsp, %r12
subq %rcx, %r12
movq %r12, %rsp
movb $0x0, (%r12,%r15)
movq (%rax), %rax
movq (%rax), %rcx
movq 0x10(%rax), %r8
movq %r12, %rdi
movq -0x40(%rbp), %rsi
leaq 0x4b98(%rip), %rdx      # 0xa441
xorl %eax, %eax
callq 0x31e0
movq -0x38(%rbp), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x3270
movq %r14, %rsp
incq %rbx
movq -0x58(%rbp), %rdi
cmpq 0x10(%rdi), %rbx
jb 0x585b
movq -0x38(%rbp), %rbx
movq %rbx, %rdi
callq 0x3150
movabsq $0xa0d0a0d736874, %rcx  # imm = 0xA0D0A0D736874
movq %rcx, 0xd(%rbx,%rax)
movapd 0x4d8e(%rip), %xmm0     # 0xa680
movupd %xmm0, (%rbx,%rax)
addq %r13, %rbx
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq %rbx, %rdi
callq 0x3350
movl -0x2c(%rbp), %r12d
movq -0x50(%rbp), %r13
leaq -0x338(%rbp), %r15
movq 0x220(%r15), %rdi
movq 0x228(%r15), %rsi
leaq 0x4cd9(%rip), %rdx      # 0xa60d
callq 0x3210
movq %rax, %r14
movq 0x220(%r15), %rdi
movq 0x228(%r15), %rsi
leaq 0x4cc6(%rip), %rdx      # 0xa617
callq 0x3210
movq %rax, %rbx
testq %r14, %r14
leaq 0x4cd5(%rip), %rdx      # 0xa638
cmovneq %r14, %rdx
testq %rax, %rax
leaq 0x4ccc(%rip), %r10      # 0xa63d
cmovneq %rax, %r10
leaq 0x4ca6(%rip), %rsi      # 0xa622
leaq -0x348(%rbp), %rcx
movl $0x4, %edi
movq %r15, %r8
movq -0x48(%rbp), %r15
movl %r15d, %r9d
xorl %eax, %eax
pushq %r10
pushq -0x88(%rbp)
callq 0x3540
addq $0x10, %rsp
movq %r14, %rdi
callq 0x3050
movq %rbx, %rdi
callq 0x3050
movl $0x68, %edi
callq 0x33a0
movq %rax, %rbx
movq -0x38(%rbp), %rax
movq %rax, (%rbx)
movq -0x40(%rbp), %rax
movq %rax, 0x8(%rbx)
movl %r15d, 0x14(%rbx)
movl %r12d, 0x10(%rbx)
movq $0x0, 0x18(%rbx)
movq %r13, 0x20(%rbx)
movapd -0x90(%rbp), %xmm0
movaps -0x80(%rbp), %xmm1
movaps -0x70(%rbp), %xmm2
movaps -0x60(%rbp), %xmm3
movupd %xmm0, 0x28(%rbx)
movups %xmm1, 0x38(%rbx)
movups %xmm2, 0x48(%rbx)
movups %xmm3, 0x58(%rbx)
movq -0xb0(%rbp), %rdi
callq 0x3050
jmp 0x5112
leaq -0x348(%rbp), %rdi
callq 0x3190
testl %eax, %eax
je 0x51a2
leaq 0x4898(%rip), %rsi      # 0xa2ce
jmp 0x50fc
leaq 0x48b2(%rip), %rdi      # 0xa2f4
leaq 0x48d5(%rip), %rsi      # 0xa31e
leaq 0x48dd(%rip), %rcx      # 0xa32d
movl $0x1cb, %edx            # imm = 0x1CB
callq 0x3200
leaq -0xf0(%rbp), %rsi
leaq -0x3d0(%rbp), %rbx
movl $0x80, %ecx
movl %eax, %edi
movq %rbx, %rdx
callq 0x3360
leaq 0x4af6(%rip), %rsi      # 0xa574
movl $0x3, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3540
leaq 0x48e0(%rip), %rdi      # 0xa374
leaq 0x4883(%rip), %rsi      # 0xa31e
leaq 0x488b(%rip), %rcx      # 0xa32d
movl $0x1d2, %edx            # imm = 0x1D2
callq 0x3200