// File: /workspace/github_c_makefile_star2_O1/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 0x63016(%rip), %rsi     # 0x1132d6
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 0x62e5f(%rip), %rsi     # 0x11317c
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 0xb04a7
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 0xb0416
movl 0xb0(%rsp), %ebp
jmp 0xb0425
movw $0x5, 0x198(%rsp)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %rbx, %rdi
movl %ebp, %esi
callq 0x62eaa
testl %ebp, %ebp
jle 0xb0481
xorl %r15d, %r15d
movl $0x400, %r12d           # imm = 0x400
leaq 0xa0(%rsp), %r14
movl %ebp, %r13d
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0xb0455
movq (%rax), %rsi
jmp 0xb0457
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 0xb0447
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 0xb04da
jmp 0xb04e1
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x59200
jmp 0xb0559
movq %rax, %rbx
jmp 0xb0559
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x59200
jmp 0xb04fa
jmp 0xb04f7
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x59200
jmp 0xb050b
jmp 0xb0508
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x59200
leaq 0x18(%rsp), %rdi
callq 0x58d60
jmp 0xb0532
movq %rax, %rbx
jmp 0xb0515
jmp 0xb052f
movq %rax, %rbx
jmp 0xb053a
jmp 0xb0549
movq %rax, %rbx
movq %rsp, %rdi
callq 0x59200
leaq 0xa0(%rsp), %rdi
callq 0x59200
jmp 0xb0563
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x555b0
leaq 0x70(%rsp), %rdi
callq 0x59178
movq %rbx, %rdi
callq 0x57090
nop