// File: /workspace/github_cpp_makefile_star2_O3/patxitron[P]BattleyeRconToolLinux/a3s.cpp
// Function: patxi::a3s::send_request(char const*, unsigned long, patxi::a3s::request_type)
void a3s::send_request(char const* data, std::size_t length, request_type rtp)
{
	request_t req;
	char* request = reinterpret_cast<char*>(&req);
	if(rtp == LOGIN) {
		memcpy(req.payload, data, length);
		length += sizeof(reqheader_t);
	} else if(rtp == BROADCAST_RESPONSE) {
		req.hdr.begin_msg = 0x02;
		memcpy(req.payload, data, length);
		length += sizeof(reqheader_t);
	} else {
		req.hdr.begin_msg = 0x01;
		req.payload[0] = *reinterpret_cast<char*>(&sequence_);
		sequence_ += 1;
		memcpy(req.payload + 1, data, length);
		length += sizeof(reqheader_t) + 1;
	}
	boost::crc_32_type crc;
	crc.process_bytes(request + 6, length - 6);
	req.hdr.checksum = crc.checksum();
	socket_.async_send_to(
		boost::asio::buffer(request, length),
		endpoint_,
		[](boost::system::error_code ec, std::size_t /*bytes_sent*/)
		{
			if(ec) {
				cerr << "Error sending request" << ec << endl;
			}
		}
	);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdx, %r15
movq %rdi, %rbx
leaq 0x38(%rsp), %rdi
movw $0x4542, -0x8(%rdi)     # imm = 0x4542
movl $0x0, -0x6(%rdi)
movw $0xff, -0x2(%rdi)
movl $0x8, %r12d
cmpl $0x1, %ecx
je 0x6d34
cmpl $0x2, %ecx
jne 0x6d1a
movb $0x2, 0x37(%rsp)
jmp 0x6d34
leaq 0x39(%rsp), %rdi
movb $0x1, -0x2(%rdi)
movb 0x2(%rbx), %al
movb %al, -0x1(%rdi)
incb %al
movb %al, 0x2(%rbx)
movl $0x9, %r12d
leaq 0x36(%rsp), %r14
movq %r15, %rdx
callq 0x62f0
addq %r15, %r12
movl $0x80000000, %eax       # imm = 0x80000000
movl $0x1, %ecx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl %eax, %edx
orl %ecx, %edx
movl %edx, %esi
andl %edi, %esi
movl %edx, %r8d
cmpl %ecx, %esi
je 0x6d65
xorl %r8d, %r8d
cmpl %eax, %esi
cmovel %edx, %r8d
xorl %r8d, %edi
shrl %eax
addl %ecx, %ecx
cmpl %ecx, %eax
ja 0x6d53
leaq -0x6(%r12), %rdx
movq %r14, %rsi
callq 0x10692
notl %eax
movl %eax, 0x32(%rsp)
leaq 0x140(%rbx), %r14
movq 0x48(%rbx), %r15
leaq 0x50(%rbx), %r13
addq $0x68, %rbx
leaq 0xf(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %fs:-0x8, %rax
xorl %ebp, %ebp
testq %rax, %rax
movq %r12, 0x10(%rsp)
je 0x6dc1
movq 0x8(%rax), %rdi
jmp 0x6dc3
xorl %edi, %edi
movl $0xa8, %esi
callq 0x9b5c
movq %rax, %r12
movq %rax, 0x20(%rsp)
movl (%r13), %eax
movq %rbp, (%r12)
leaq 0x1064(%rip), %rcx      # 0x7e48
movq %rcx, 0x8(%r12)
movl %ebp, 0x10(%r12)
movups 0x30(%r15), %xmm0
movups %xmm0, 0x18(%r12)
movq %rbp, 0x28(%r12)
leaq 0x4707(%rip), %rcx      # 0xb50c
movq %rcx, 0x30(%r12)
movl %eax, 0x38(%r12)
leaq 0x30(%rsp), %rax
movq %rax, 0x40(%r12)
movq 0x10(%rsp), %rax
movq %rax, 0x48(%r12)
movups (%r14), %xmm0
movups 0xc(%r14), %xmm1
movups %xmm1, 0x5c(%r12)
movups %xmm0, 0x50(%r12)
movl %ebp, 0x6c(%r12)
leaq 0x78(%r12), %rdi
movq %rbx, %rsi
callq 0xaaaa
addq $0x28, %r15
movq %r12, 0x28(%rsp)
movl %ebp, (%rsp)
movq %r15, %rdi
movq %r13, %rsi
movl $0x1, %edx
movq %r12, %rcx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x9a3e
leaq 0x20(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
leaq 0x18(%rsp), %rdi
callq 0x804e
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6eb0
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x804e
movq %rbx, %rdi
callq 0x65e0
movq %rax, %rdi
callq 0x8333