// File: errantlinguist[P]Forecast/src/console_weather/ForecastStreamReader.cpp
// Function: console_weather::ForecastStreamReader::read(std::istream&)
std::unique_ptr<forecast_io::Forecast> ForecastStreamReader::read(std::istream& input)
{
    // Create parsers
    std::unique_ptr<forecast_io::factories::ForecastFactory> pForecastFactory(
        new forecast_io::factories::ForecastFactory(measurementUnits));
    std::unique_ptr<forecast_io::factories::FlagsFactory> pFlagsFactory(
        new forecast_io::factories::FlagsFactory(measurementUnits));
    std::unique_ptr<forecast_io::parsers::ParserManager> pParserManager(
        new forecast_io::parsers::ParserManager(pForecastFactory.get(), pFlagsFactory.get()));

    forecast_io::parsers::NotifyingForecastParser& forecastParser =
        pParserManager->getForecastParser();
    json::TokenerParser tokenerParser(forecastParser);
    const std::streamsize bytesRead = tokenerParser.parse(input, pBuffer.get(),
                                      readBufferSize);
	std::unique_ptr<forecast_io::Forecast> result = nullptr;
	if (input.eof() && bytesRead > 0)
	{
		result = pForecastFactory->create();
	}

	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0xa0(%rbp)
movq %rdi, %rax
movq %rax, -0x98(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
movl $0x78, %edi
callq 0xa140
movq %rax, %rdi
movq -0x90(%rbp), %rax
movq %rdi, -0x88(%rbp)
movq (%rax), %rsi
callq 0x45aa0
movq -0x88(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x38590
movl $0xa0, %edi
callq 0xa140
movq %rax, -0x80(%rbp)
jmp 0x39576
movq -0x80(%rbp), %rdi
movq -0x90(%rbp), %rax
movq (%rax), %rsi
callq 0x455d0
movq -0x80(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x385c0
movl $0x348, %edi            # imm = 0x348
callq 0xa140
movq %rax, -0xa8(%rbp)
jmp 0x395a9
leaq -0x20(%rbp), %rdi
callq 0x385f0
movq %rax, -0xc0(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x38620
movq -0xc0(%rbp), %rsi
movq -0xa8(%rbp), %rdi
movq %rax, %rdx
callq 0x63d40
movq -0xa8(%rbp), %rsi
leaq -0x40(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x38650
movq -0xb8(%rbp), %rdi
callq 0x38680
movq %rax, %rdi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
movq %rax, -0xb0(%rbp)
jmp 0x39610
movq -0xb0(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x646c0
jmp 0x3962a
movq -0x90(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0xd0(%rbp)
addq $0x8, %rdi
callq 0xf6d0
movq -0xd0(%rbp), %rsi
movq %rax, %rdx
movq -0x90(%rbp), %rax
movl 0x10(%rax), %ecx
leaq -0x60(%rbp), %rdi
callq 0x64860
movq %rax, -0xc8(%rbp)
jmp 0x3966b
movq -0xa0(%rbp), %rdi
movq -0xc8(%rbp), %rax
movq %rax, -0x68(%rbp)
movb $0x0, -0x69(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x386a0
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0xa940
movb %al, -0xd1(%rbp)
jmp 0x396a5
movb -0xd1(%rbp), %al
testb $0x1, %al
jne 0x396b4
jmp 0x3974d
cmpq $0x0, -0x68(%rbp)
jle 0x3974d
leaq -0x20(%rbp), %rdi
callq 0x386e0
movq %rax, %rsi
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq -0x78(%rbp), %rdi
callq *%rax
jmp 0x396da
movq -0xa0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x38700
leaq -0x78(%rbp), %rdi
callq 0xded0
jmp 0x3974d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x397b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x397a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x397a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x39797
movq -0xa0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0xded0
jmp 0x39797
movb $0x1, -0x69(%rbp)
testb $0x1, -0x69(%rbp)
jne 0x39763
movq -0xa0(%rbp), %rdi
callq 0xded0
leaq -0x60(%rbp), %rdi
callq 0x64710
leaq -0x40(%rbp), %rdi
callq 0x38730
leaq -0x28(%rbp), %rdi
callq 0x38790
leaq -0x20(%rbp), %rdi
callq 0x387f0
movq -0x98(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
leaq -0x60(%rbp), %rdi
callq 0x64710
leaq -0x40(%rbp), %rdi
callq 0x38730
leaq -0x28(%rbp), %rdi
callq 0x38790
leaq -0x20(%rbp), %rdi
callq 0x387f0
movq -0x30(%rbp), %rdi
callq 0xa520
nopw %cs:(%rax,%rax)
nop