// File: /workspace/github_cpp_makefile_star2_O3/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 0xc564
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 0x921e
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       # 0x977a
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 0x9362
movq 0x3acd7(%rip), %rdi     # 0x43fc8
leaq 0x2a1d7(%rip), %rsi     # 0x334cf
movl $0x12, %edx
callq 0x86e0
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
movq 0x3acb5(%rip), %rdi     # 0x43fc8
callq 0x86e0
movq %rax, %r14
leaq 0x2a1c0(%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 0x96c0
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x260c0
leaq 0xf0(%rsp), %rdi
callq 0x1b250
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 0x1ce40
testb %al, %al
je 0x9611
leaq 0x2a09f(%rip), %rsi     # 0x33463
leaq 0x18(%rsp), %rdi
callq 0x29ce0
leaq 0x2a093(%rip), %rsi     # 0x33468
movq %rax, %rdi
callq 0x29ce0
movq %rax, %rdi
callq 0x242d0
movsd %xmm0, 0x8(%rsp)
leaq 0x2a071(%rip), %rsi     # 0x33463
leaq 0x18(%rsp), %rdi
callq 0x29ce0
leaq 0x2a06a(%rip), %rsi     # 0x3346d
movq %rax, %rdi
callq 0x29ce0
movq %rax, %rdi
callq 0x242d0
movapd %xmm0, 0x40(%rsp)
leaq 0x2a043(%rip), %rsi     # 0x33463
leaq 0x18(%rsp), %rdi
callq 0x29ce0
leaq 0x2a045(%rip), %rsi     # 0x33476
movq %rax, %rdi
callq 0x29ce0
movq %rax, %rdi
callq 0x242d0
movsd %xmm0, 0x68(%rsp)
leaq 0x2a031(%rip), %rsi     # 0x3347f
leaq 0x18(%rsp), %rdi
callq 0x29ce0
leaq 0x2a025(%rip), %rsi     # 0x33484
movq %rax, %rdi
callq 0x29ce0
movq %rax, %rdi
callq 0x242d0
movsd %xmm0, 0x60(%rsp)
leaq 0x2a003(%rip), %rsi     # 0x3347f
leaq 0x18(%rsp), %rdi
callq 0x29ce0
leaq 0x29ffd(%rip), %rsi     # 0x3348a
movq %rax, %rdi
callq 0x29ce0
movq %rax, %rdi
callq 0x242d0
movsd %xmm0, 0x58(%rsp)
leaq 0x29fd5(%rip), %rsi     # 0x3347f
leaq 0x18(%rsp), %rdi
callq 0x29ce0
leaq 0x2a14b(%rip), %rsi     # 0x33606
movq %rax, %rdi
callq 0x29ce0
movq %rax, %rdi
callq 0x242d0
movsd %xmm0, 0x50(%rsp)
leaq 0x29fb7(%rip), %rsi     # 0x3348f
leaq 0x18(%rsp), %rdi
callq 0x29ce0
movq %rax, %rdi
callq 0x24a30
movl $0x270f, %r14d          # imm = 0x270F
cmpl %r14d, %eax
cmovll %eax, %r14d
leaq 0x29f9c(%rip), %rsi     # 0x3349a
leaq 0x18(%rsp), %rdi
callq 0x29ce0
leaq 0x29f92(%rip), %rsi     # 0x334a1
movq %rax, %rdi
callq 0x29ce0
movq %rax, %rdi
callq 0x24a30
movl %eax, %ebp
leaq 0x29f7d(%rip), %rsi     # 0x334a5
leaq 0x18(%rsp), %rdi
callq 0x29ce0
movq %rax, %rdi
xorl %esi, %esi
callq 0x292b0
leaq 0x2a446(%rip), %rsi     # 0x33989
movq %rax, %rdi
callq 0x29ce0
movq %rax, %rdi
callq 0x24a30
movsd 0x8(%rsp), %xmm3
addsd 0x29ab7(%rip), %xmm3    # 0x33018
movsd 0x29ab7(%rip), %xmm0    # 0x33020
movapd 0x40(%rsp), %xmm4
cmpltsd %xmm4, %xmm0
movsd 0x29aac(%rip), %xmm1    # 0x33028
movapd %xmm0, %xmm2
andpd %xmm1, %xmm2
andnpd %xmm4, %xmm0
orpd %xmm2, %xmm0
cmpltsd 0x29a9b(%rip), %xmm4    # 0x33030
movapd %xmm4, %xmm2
andnpd %xmm0, %xmm2
andpd %xmm1, %xmm4
orpd %xmm2, %xmm4
movsd 0x29a5b(%rip), %xmm0    # 0x33008
movsd 0x68(%rsp), %xmm1
subsd %xmm1, %xmm0
mulsd 0x29a51(%rip), %xmm0    # 0x33010
addsd %xmm3, %xmm0
movsd 0x60(%rsp), %xmm2
mulsd 0x29a67(%rip), %xmm2    # 0x33038
movsd 0x58(%rsp), %xmm5
mulsd 0x29a59(%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 0x965e
movq 0x3a9b0(%rip), %r14     # 0x43fc8
leaq 0x29e8e(%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 0x3a97e(%rip), %rdi     # 0x43fc8
callq 0x8360
movq %rax, %rdi
callq 0x82d0
movl $0x1, 0x48(%rbx)
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x9670
callq 0x8350
leaq 0x1e8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9686
callq 0x8350
leaq 0x1a0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x969c
callq 0x8350
leaq 0x140(%rsp), %rdi
callq 0xc604
leaq 0xf0(%rsp), %rdi
callq 0xc786
leaq 0x18(%rsp), %rdi
callq 0x275e0
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x96d2
callq 0x8350
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x96e8
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 0x9740
jmp 0x9719
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
cmpq %r15, %rdi
jne 0x976d
jmp 0x9772
movq %rax, %rbx
jmp 0x975c
movq %rax, %rbx
jmp 0x974a
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x9733
callq 0x8350
leaq 0xf0(%rsp), %rdi
callq 0xbfe2
leaq 0x18(%rsp), %rdi
callq 0x275e0
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x975c
callq 0x8350
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9772
callq 0x8350
movq %rbx, %rdi
callq 0x8440