// File: /workspace/github_cpp_makefile_star2_O1/gualtieromalde[P]owmread/owmread.C
// Function: getWeather(double, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Weather getWeather(double lon, double lat, std::string myKey)
{
    
	
    Weather weather;
    const std::string url = getUrl(lon,lat,myKey);
    CURL* curl = curl_easy_init();

    // Set remote URL.
    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
    curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);
    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
    long httpCode(0);
    std::string httpData;
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &httpData);
    curl_easy_perform(curl);
    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
    curl_easy_cleanup(curl);

    if (httpCode != CURLE_HTTP_RETURNED_ERROR)
    {

        Json::Value jsonData;
        Json::Reader jsonReader;
	std::string err;
        if ( jsonReader.parse(httpData, jsonData)   ) 
        {

   	    weather.temperature = jsonData["main"]["temp"].asDouble() - kel_to_c;
            weather.pressure = jsonData["main"]["pressure"].asDouble();
	    /// set default pressure for absurd values
	    if(weather.pressure < 800 || weather.pressure > 1200) weather.pressure = 1013;
	    weather.relhum = jsonData["main"]["humidity"].asDouble();
	    weather.dewpoint = getDewPoint(weather.temperature, weather.relhum);

	    weather.wind.speed = jsonData["wind"]["speed"].asDouble() * ms_to_kt;
	    weather.wind.gust = jsonData["wind"]["gust"].asDouble() * ms_to_kt;
	    weather.wind.deg = jsonData["wind"]["deg"].asDouble();

	    weather.visibility = jsonData["visibility"].asInt();
	    if(weather.visibility>9999) weather.visibility=9999;

	    weather.cloudiness = jsonData["clouds"]["all"].asInt();
	    weather.code = jsonData["weather"][0]["id"].asInt();
	    //...
	    return weather;
        }
        else
        {
            std::cerr << "Could not parse HTTP data as JSON" << std::endl;
            return Weather(1);
       	} 
    }
    else
    {
        std::cerr << "Couldn't get from " << url << " - exiting" << std::endl;
        return Weather(0);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movsd %xmm1, 0x8(%rsp)
movsd %xmm0, 0x40(%rsp)
movq %rdi, %rbx
leaq 0xc0(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rsi), %rax
movq 0x8(%rsi), %rdx
addq %rax, %rdx
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0xc58e
leaq 0x70(%rsp), %rdi
movsd 0x40(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movq %r14, %rsi
callq 0x8bd5
movq 0xb0(%rsp), %rdi
cmpq %r15, %rdi
je 0x9220
callq 0x8350
callq 0x8700
movq %rax, %r14
movq 0x70(%rsp), %rdx
movq %rax, %rdi
movl $0x2712, %esi           # imm = 0x2712
xorl %eax, %eax
callq 0x85f0
movq %r14, %rdi
movl $0x71, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x85f0
movq %r14, %rdi
movl $0xd, %esi
movl $0xa, %edx
xorl %eax, %eax
callq 0x85f0
movl $0x1, %edx
movq %r14, %rdi
movl $0x34, %esi
xorl %eax, %eax
callq 0x85f0
xorl %eax, %eax
movq %rax, 0x10(%rsp)
leaq 0xa0(%rsp), %r15
movq %r15, -0x10(%r15)
movq %rax, -0x8(%r15)
movb $0x0, (%r15)
leaq 0x4e2(%rip), %rdx       # 0x977c
movq %r14, %rdi
movl $0x4e2b, %esi           # imm = 0x4E2B
xorl %eax, %eax
callq 0x85f0
leaq 0x90(%rsp), %rdx
movq %r14, %rdi
movl $0x2711, %esi           # imm = 0x2711
xorl %eax, %eax
callq 0x85f0
movq %r14, %rdi
callq 0x8490
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
movl $0x200002, %esi         # imm = 0x200002
xorl %eax, %eax
callq 0x86d0
movq %r14, %rdi
callq 0x80f0
cmpq $0x16, 0x10(%rsp)
jne 0x9364
movq 0x3ace5(%rip), %rdi     # 0x43fd8
leaq 0x2a1d5(%rip), %rsi     # 0x334cf
movl $0x12, %edx
callq 0x86e0
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
movq 0x3acc3(%rip), %rdi     # 0x43fd8
callq 0x86e0
movq %rax, %r14
leaq 0x2a1be(%rip), %rsi     # 0x334e2
movl $0xa, %edx
movq %rax, %rdi
callq 0x86e0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x8770
movsbl %al, %esi
movq %r14, %rdi
callq 0x8360
movq %rax, %rdi
callq 0x82d0
movl $0x0, 0x48(%rbx)
jmp 0x96c2
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x25fa0
leaq 0xf0(%rsp), %rdi
callq 0x1b130
leaq 0xe0(%rsp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
leaq 0xf0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movl $0x1, %ecx
callq 0x1cd20
testb %al, %al
je 0x9613
leaq 0x2a09d(%rip), %rsi     # 0x33463
leaq 0x18(%rsp), %rdi
callq 0x29bc0
leaq 0x2a091(%rip), %rsi     # 0x33468
movq %rax, %rdi
callq 0x29bc0
movq %rax, %rdi
callq 0x241b0
movsd %xmm0, 0x8(%rsp)
leaq 0x2a06f(%rip), %rsi     # 0x33463
leaq 0x18(%rsp), %rdi
callq 0x29bc0
leaq 0x2a068(%rip), %rsi     # 0x3346d
movq %rax, %rdi
callq 0x29bc0
movq %rax, %rdi
callq 0x241b0
movapd %xmm0, 0x40(%rsp)
leaq 0x2a041(%rip), %rsi     # 0x33463
leaq 0x18(%rsp), %rdi
callq 0x29bc0
leaq 0x2a043(%rip), %rsi     # 0x33476
movq %rax, %rdi
callq 0x29bc0
movq %rax, %rdi
callq 0x241b0
movsd %xmm0, 0x68(%rsp)
leaq 0x2a02f(%rip), %rsi     # 0x3347f
leaq 0x18(%rsp), %rdi
callq 0x29bc0
leaq 0x2a023(%rip), %rsi     # 0x33484
movq %rax, %rdi
callq 0x29bc0
movq %rax, %rdi
callq 0x241b0
movsd %xmm0, 0x60(%rsp)
leaq 0x2a001(%rip), %rsi     # 0x3347f
leaq 0x18(%rsp), %rdi
callq 0x29bc0
leaq 0x29ffb(%rip), %rsi     # 0x3348a
movq %rax, %rdi
callq 0x29bc0
movq %rax, %rdi
callq 0x241b0
movsd %xmm0, 0x58(%rsp)
leaq 0x29fd3(%rip), %rsi     # 0x3347f
leaq 0x18(%rsp), %rdi
callq 0x29bc0
leaq 0x2a149(%rip), %rsi     # 0x33606
movq %rax, %rdi
callq 0x29bc0
movq %rax, %rdi
callq 0x241b0
movsd %xmm0, 0x50(%rsp)
leaq 0x29fb5(%rip), %rsi     # 0x3348f
leaq 0x18(%rsp), %rdi
callq 0x29bc0
movq %rax, %rdi
callq 0x24910
movl $0x270f, %r14d          # imm = 0x270F
cmpl %r14d, %eax
cmovll %eax, %r14d
leaq 0x29f9a(%rip), %rsi     # 0x3349a
leaq 0x18(%rsp), %rdi
callq 0x29bc0
leaq 0x29f90(%rip), %rsi     # 0x334a1
movq %rax, %rdi
callq 0x29bc0
movq %rax, %rdi
callq 0x24910
movl %eax, %ebp
leaq 0x29f7b(%rip), %rsi     # 0x334a5
leaq 0x18(%rsp), %rdi
callq 0x29bc0
movq %rax, %rdi
xorl %esi, %esi
callq 0x29190
leaq 0x2a444(%rip), %rsi     # 0x33989
movq %rax, %rdi
callq 0x29bc0
movq %rax, %rdi
callq 0x24910
movsd 0x8(%rsp), %xmm3
addsd 0x29ab5(%rip), %xmm3    # 0x33018
movsd 0x29ab5(%rip), %xmm0    # 0x33020
movapd 0x40(%rsp), %xmm4
cmpltsd %xmm4, %xmm0
movsd 0x29aaa(%rip), %xmm1    # 0x33028
movapd %xmm0, %xmm2
andpd %xmm1, %xmm2
andnpd %xmm4, %xmm0
orpd %xmm2, %xmm0
cmpltsd 0x29a99(%rip), %xmm4    # 0x33030
movapd %xmm4, %xmm2
andnpd %xmm0, %xmm2
andpd %xmm1, %xmm4
orpd %xmm2, %xmm4
movsd 0x29a59(%rip), %xmm0    # 0x33008
movsd 0x68(%rsp), %xmm1
subsd %xmm1, %xmm0
mulsd 0x29a4f(%rip), %xmm0    # 0x33010
addsd %xmm3, %xmm0
movsd 0x60(%rsp), %xmm2
mulsd 0x29a65(%rip), %xmm2    # 0x33038
movsd 0x58(%rsp), %xmm5
mulsd 0x29a57(%rip), %xmm5    # 0x33038
cvttsd2si 0x50(%rsp), %ecx
movsd %xmm3, (%rbx)
movsd %xmm0, 0x8(%rbx)
movsd %xmm1, 0x10(%rbx)
movl %r14d, 0x18(%rbx)
movl %ebp, 0x1c(%rbx)
movl %eax, 0x20(%rbx)
movsd %xmm2, 0x28(%rbx)
movl %ecx, 0x30(%rbx)
movsd %xmm5, 0x38(%rbx)
movsd %xmm4, 0x40(%rbx)
jmp 0x9660
movq 0x3a9be(%rip), %r14     # 0x43fd8
leaq 0x29e8c(%rip), %rsi     # 0x334ad
movl $0x21, %edx
movq %r14, %rdi
callq 0x86e0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x8770
movsbl %al, %esi
movq 0x3a98c(%rip), %rdi     # 0x43fd8
callq 0x8360
movq %rax, %rdi
callq 0x82d0
movl $0x1, 0x48(%rbx)
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x9672
callq 0x8350
leaq 0x1e8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9688
callq 0x8350
leaq 0x1a0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x969e
callq 0x8350
leaq 0x140(%rsp), %rdi
callq 0xc62a
leaq 0xf0(%rsp), %rdi
callq 0xc7a0
leaq 0x18(%rsp), %rdi
callq 0x274c0
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x96d4
callq 0x8350
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x96ea
callq 0x8350
movq %rbx, %rax
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x9742
jmp 0x971b
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
cmpq %r15, %rdi
jne 0x976f
jmp 0x9774
movq %rax, %rbx
jmp 0x975e
movq %rax, %rbx
jmp 0x974c
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x9735
callq 0x8350
leaq 0xf0(%rsp), %rdi
callq 0xc00a
leaq 0x18(%rsp), %rdi
callq 0x274c0
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x975e
callq 0x8350
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9774
callq 0x8350
movq %rbx, %rdi
callq 0x8440