// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/net/protocols/protocol.cpp
// Function: smooth::Net::Protocols::Protocol::DownloadToBuffer(smooth::Buffer<unsigned char>&)
S::Int S::Net::Protocols::Protocol::DownloadToBuffer(Buffer<UnsignedByte> &destination)
{
	Math::RandomSeed();

	S::File	 downloadFile = S::System::System::GetTempDirectory().Append("download-").Append(Number((Int64) Math::Random() & 0x7FFFFFFF).ToHexString()).Append(".temp");
	Bool	 error = DownloadToFile(downloadFile);

	if (error) return Error();

	InStream	 in(STREAM_FILE, downloadFile, IS_READ);
	Int		 size = in.Size();

	destination.Resize(size);

	for (Int p = 0; p < size; p += 1024) in.InputData(destination + p, Math::Min(1024, size - p));

	in.Close();

	downloadFile.Delete();

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rsi, %rbx
movq %rdi, %r14
callq 0x568f0
leaq 0xa0(%rsp), %rdi
callq 0x59160
leaq 0x57d28(%rip), %rsi     # 0x102376
movq %rsp, %rdi
callq 0x58c40
leaq 0xa0(%rsp), %rdi
movq %rsp, %rsi
callq 0x573e0
movq %rax, %r15
callq 0x57090
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x5a3d0
leaq 0x58(%rsp), %rdi
leaq 0x18(%rsp), %rsi
pushq $-0x1
popq %rbp
movl %ebp, %edx
callq 0x589c0
leaq 0x58(%rsp), %rsi
movq %r15, %rdi
callq 0x573e0
movq %rax, %r15
leaq 0x57b71(%rip), %rsi     # 0x10221c
leaq 0x40(%rsp), %rdi
callq 0x58c40
leaq 0x40(%rsp), %rsi
movq %r15, %rdi
callq 0x573e0
movq %rax, %r15
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
callq 0x5a180
leaq 0x70(%rsp), %rdi
leaq 0x28(%rsp), %rdx
movq %r15, %rsi
callq 0x57940
leaq 0x28(%rsp), %rdi
callq 0x5a588
leaq 0x40(%rsp), %rdi
callq 0x5a588
leaq 0x58(%rsp), %rdi
callq 0x5a588
leaq 0x18(%rsp), %rdi
callq 0x5a0b0
movq %rsp, %rdi
callq 0x5a588
leaq 0xa0(%rsp), %rdi
callq 0x5a588
leaq 0xa0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x5a310
movq (%r14), %rax
leaq 0xa0(%rsp), %rsi
movq %r14, %rdi
callq *0x10(%rax)
movl %eax, %r14d
leaq 0xa0(%rsp), %rdi
callq 0x5a588
testl %r14d, %r14d
jne 0xaa826
movq %rsp, %rdi
leaq 0x70(%rsp), %rsi
callq 0x5a310
leaq 0xa0(%rsp), %rdi
pushq $0x3
popq %rsi
movq %rsp, %rdx
pushq $0x2
popq %rcx
callq 0x59a20
movq %rsp, %rdi
callq 0x5a588
cmpw $0x0, 0xa8(%rsp)
je 0xaa79b
movl 0xb0(%rsp), %ebp
jmp 0xaa7a8
movw $0x5, 0x198(%rsp)
pushq $-0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x63b3a
movslq %ebp, %r15
xorl %r12d, %r12d
movl $0x400, %r13d           # imm = 0x400
leaq 0xa0(%rsp), %r14
cmpq %r15, %r12
jge 0xaa800
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0xaa7d9
movq (%rax), %rsi
jmp 0xaa7db
xorl %esi, %esi
addq %r12, %rsi
cmpl %r13d, %ebp
movl $0x400, %edx            # imm = 0x400
cmovll %ebp, %edx
movq %r14, %rdi
callq 0x58100
addq $0x400, %r12            # imm = 0x400
addl $0xfffffc00, %ebp       # imm = 0xFFFFFC00
jmp 0xaa7c6
leaq 0xa0(%rsp), %rdi
callq 0x56340
leaq 0x70(%rsp), %rdi
callq 0x590f0
leaq 0xa0(%rsp), %rdi
callq 0x565f0
xorl %ebp, %ebp
leaq 0x70(%rsp), %rdi
callq 0x5a500
movl %ebp, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %rsp, %rdi
jmp 0xaa859
jmp 0xaa860
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x5a588
jmp 0xaa8d8
movq %rax, %rbx
jmp 0xaa8d8
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x5a588
jmp 0xaa879
jmp 0xaa876
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x5a588
jmp 0xaa88a
jmp 0xaa887
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x5a588
leaq 0x18(%rsp), %rdi
callq 0x5a0b0
jmp 0xaa8b1
movq %rax, %rbx
jmp 0xaa894
jmp 0xaa8ae
movq %rax, %rbx
jmp 0xaa8b9
jmp 0xaa8c8
movq %rax, %rbx
movq %rsp, %rdi
callq 0x5a588
leaq 0xa0(%rsp), %rdi
callq 0x5a588
jmp 0xaa8e2
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x565f0
leaq 0x70(%rsp), %rdi
callq 0x5a500
movq %rbx, %rdi
callq 0x58260