// File: /workspace/github_c_makefile_star2_O3/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 0x55890
leaq 0xa0(%rsp), %rdi
callq 0x57ed0
leaq 0x62f84(%rip), %rsi     # 0x112486
movq %rsp, %rdi
callq 0x579f0
leaq 0xa0(%rsp), %rdi
movq %rsp, %rsi
callq 0x562f0
movq %rax, %r15
callq 0x55fc0
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x59050
leaq 0x58(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x57780
leaq 0x58(%rsp), %rsi
movq %r15, %rdi
callq 0x562f0
movq %rax, %r15
leaq 0x62dcd(%rip), %rsi     # 0x11232c
leaq 0x40(%rsp), %rdi
callq 0x579f0
leaq 0x40(%rsp), %rsi
movq %r15, %rdi
callq 0x562f0
movq %rax, %r15
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
callq 0x58e20
leaq 0x70(%rsp), %rdi
leaq 0x28(%rsp), %rdx
movq %r15, %rsi
callq 0x56800
leaq 0x28(%rsp), %rdi
callq 0x59200
leaq 0x40(%rsp), %rdi
callq 0x59200
leaq 0x58(%rsp), %rdi
callq 0x59200
leaq 0x18(%rsp), %rdi
callq 0x58d60
movq %rsp, %rdi
callq 0x59200
leaq 0xa0(%rsp), %rdi
callq 0x59200
leaq 0xa0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x58fa0
movq (%r14), %rax
leaq 0xa0(%rsp), %rsi
movq %r14, %rdi
callq *0x10(%rax)
movl %eax, %r14d
leaq 0xa0(%rsp), %rdi
callq 0x59200
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %r14d, %r14d
jne 0xaf6e9
movq %rsp, %rdi
leaq 0x70(%rsp), %rsi
callq 0x58fa0
leaq 0xa0(%rsp), %rdi
movq %rsp, %rdx
movl $0x3, %esi
movl $0x2, %ecx
callq 0x58730
movq %rsp, %rdi
callq 0x59200
cmpw $0x0, 0xa8(%rsp)
je 0xaf658
movl 0xb0(%rsp), %ebp
jmp 0xaf667
movw $0x5, 0x198(%rsp)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %rbx, %rdi
movl %ebp, %esi
callq 0x62f32
testl %ebp, %ebp
jle 0xaf6c3
xorl %r15d, %r15d
movl $0x400, %r12d           # imm = 0x400
leaq 0xa0(%rsp), %r14
movl %ebp, %r13d
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0xaf697
movq (%rax), %rsi
jmp 0xaf699
xorl %esi, %esi
addq %r15, %rsi
cmpl %r12d, %r13d
movl $0x400, %edx            # imm = 0x400
cmovll %r13d, %edx
movq %r14, %rdi
callq 0x56f50
addq $0x400, %r15            # imm = 0x400
addl $0xfffffc00, %r13d      # imm = 0xFFFFFC00
cmpl %r15d, %ebp
jg 0xaf689
leaq 0xa0(%rsp), %rdi
callq 0x55310
leaq 0x70(%rsp), %rdi
callq 0x57e60
leaq 0xa0(%rsp), %rdi
callq 0x555b0
xorl %ebp, %ebp
leaq 0x70(%rsp), %rdi
callq 0x59178
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 0xaf71c
jmp 0xaf723
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x59200
jmp 0xaf79b
movq %rax, %rbx
jmp 0xaf79b
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x59200
jmp 0xaf73c
jmp 0xaf739
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x59200
jmp 0xaf74d
jmp 0xaf74a
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x59200
leaq 0x18(%rsp), %rdi
callq 0x58d60
jmp 0xaf774
movq %rax, %rbx
jmp 0xaf757
jmp 0xaf771
movq %rax, %rbx
jmp 0xaf77c
jmp 0xaf78b
movq %rax, %rbx
movq %rsp, %rdi
callq 0x59200
leaq 0xa0(%rsp), %rdi
callq 0x59200
jmp 0xaf7a5
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x555b0
leaq 0x70(%rsp), %rdi
callq 0x59178
movq %rbx, %rdi
callq 0x57090
nop