// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0x208, %rsp            # imm = 0x208
movsd %xmm1, 0x8(%rsp)
movsd %xmm0, 0x40(%rsp)
movq %rdi, %rbx
leaq 0xd8(%rsp), %r15
movq %r15, %rdi
callq 0x83d0
leaq 0x98(%rsp), %r14
movq %r14, %rdi
movsd 0x40(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movq %r15, %rsi
callq 0x8c25
leaq 0xd8(%rsp), %rdi
callq 0x8988
callq 0x87b0
movq %rax, %r15
movq 0x98(%rsp), %rdx
movq %rax, %rdi
movl $0x2712, %esi           # imm = 0x2712
xorl %eax, %eax
callq 0x86a0
pushq $0x71
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0x86a0
pushq $0xd
popq %rsi
pushq $0xa
popq %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0x86a0
pushq $0x34
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0x86a0
andq $0x0, 0x10(%rsp)
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x3fd(%rip), %rdx       # 0x936d
movq %r15, %rdi
movl $0x4e2b, %esi           # imm = 0x4E2B
xorl %eax, %eax
callq 0x86a0
leaq 0x78(%rsp), %rdx
movq %r15, %rdi
movl $0x2711, %esi           # imm = 0x2711
xorl %eax, %eax
callq 0x86a0
movq %r15, %rdi
callq 0x8510
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
movl $0x200002, %esi         # imm = 0x200002
xorl %eax, %eax
callq 0x8780
movq %r15, %rdi
callq 0x8130
cmpq $0x16, 0x10(%rsp)
jne 0x9002
movq 0x39012(%rip), %rdi     # 0x41fd8
leaq 0x274ee(%rip), %rsi     # 0x304bb
callq 0x8420
leaq 0x98(%rsp), %rsi
movq %rax, %rdi
callq 0x81e0
leaq 0x274e5(%rip), %rsi     # 0x304ce
movq %rax, %rdi
callq 0x8420
movq %rax, %rdi
callq 0x87e0
andl $0x0, 0x48(%rbx)
jmp 0x92eb
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x23040
leaq 0xf8(%rsp), %rdi
callq 0x181d0
leaq 0xc8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xf8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x18(%rsp), %rdx
pushq $0x1
popq %rcx
callq 0x19dc0
testb %al, %al
je 0x92a5
leaq 0x273f7(%rip), %rsi     # 0x3044f
leaq 0x18(%rsp), %rdi
callq 0x26c60
leaq 0x273eb(%rip), %rsi     # 0x30454
movq %rax, %rdi
callq 0x26c60
movq %rax, %rdi
callq 0x21250
movsd %xmm0, 0x8(%rsp)
leaq 0x273c9(%rip), %rsi     # 0x3044f
leaq 0x18(%rsp), %rdi
callq 0x26c60
leaq 0x273c2(%rip), %rsi     # 0x30459
movq %rax, %rdi
callq 0x26c60
movq %rax, %rdi
callq 0x21250
movapd %xmm0, 0x40(%rsp)
leaq 0x2739b(%rip), %rsi     # 0x3044f
leaq 0x18(%rsp), %rdi
callq 0x26c60
leaq 0x2739d(%rip), %rsi     # 0x30462
movq %rax, %rdi
callq 0x26c60
movq %rax, %rdi
callq 0x21250
movsd %xmm0, 0x70(%rsp)
leaq 0x27389(%rip), %rsi     # 0x3046b
leaq 0x18(%rsp), %rdi
callq 0x26c60
leaq 0x2737d(%rip), %rsi     # 0x30470
movq %rax, %rdi
callq 0x26c60
movq %rax, %rdi
callq 0x21250
movsd %xmm0, 0x68(%rsp)
leaq 0x2735b(%rip), %rsi     # 0x3046b
leaq 0x18(%rsp), %rdi
callq 0x26c60
leaq 0x27355(%rip), %rsi     # 0x30476
movq %rax, %rdi
callq 0x26c60
movq %rax, %rdi
callq 0x21250
movsd %xmm0, 0x60(%rsp)
leaq 0x2732d(%rip), %rsi     # 0x3046b
leaq 0x18(%rsp), %rdi
callq 0x26c60
leaq 0x274a3(%rip), %rsi     # 0x305f2
movq %rax, %rdi
callq 0x26c60
movq %rax, %rdi
callq 0x21250
movsd %xmm0, 0x58(%rsp)
leaq 0x2730f(%rip), %rsi     # 0x3047b
leaq 0x18(%rsp), %rdi
callq 0x26c60
movq %rax, %rdi
callq 0x219b0
movl $0x270f, %r15d          # imm = 0x270F
cmpl %r15d, %eax
cmovll %eax, %r15d
leaq 0x272f4(%rip), %rsi     # 0x30486
leaq 0x18(%rsp), %rdi
callq 0x26c60
leaq 0x272ea(%rip), %rsi     # 0x3048d
movq %rax, %rdi
callq 0x26c60
movq %rax, %rdi
callq 0x219b0
movl %eax, %ebp
leaq 0x272d5(%rip), %rsi     # 0x30491
leaq 0x18(%rsp), %rdi
callq 0x26c60
movq %rax, %rdi
xorl %esi, %esi
callq 0x26230
leaq 0x2779e(%rip), %rsi     # 0x30975
movq %rax, %rdi
callq 0x26c60
movq %rax, %rdi
callq 0x219b0
movsd 0x8(%rsp), %xmm3
addsd 0x26e23(%rip), %xmm3    # 0x30018
movsd 0x26e23(%rip), %xmm0    # 0x30020
movapd 0x40(%rsp), %xmm4
cmpltsd %xmm4, %xmm0
movsd 0x26e18(%rip), %xmm1    # 0x30028
movapd %xmm0, %xmm2
andpd %xmm1, %xmm2
andnpd %xmm4, %xmm0
orpd %xmm2, %xmm0
cmpltsd 0x26e07(%rip), %xmm4    # 0x30030
movapd %xmm4, %xmm2
andnpd %xmm0, %xmm2
andpd %xmm1, %xmm4
orpd %xmm2, %xmm4
movsd 0x26dc7(%rip), %xmm0    # 0x30008
movsd 0x70(%rsp), %xmm1
subsd %xmm1, %xmm0
mulsd 0x26dbd(%rip), %xmm0    # 0x30010
addsd %xmm3, %xmm0
movsd 0x68(%rsp), %xmm2
mulsd 0x26dd3(%rip), %xmm2    # 0x30038
movsd 0x60(%rsp), %xmm5
mulsd 0x26dc5(%rip), %xmm5    # 0x30038
cvttsd2si 0x58(%rsp), %ecx
movsd %xmm3, (%rbx)
movsd %xmm0, 0x8(%rbx)
movsd %xmm1, 0x10(%rbx)
movl %r15d, 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 0x92c7
movq 0x38d2c(%rip), %rdi     # 0x41fd8
leaq 0x271e6(%rip), %rsi     # 0x30499
callq 0x8420
movq %rax, %rdi
callq 0x87e0
movl $0x1, 0x48(%rbx)
leaq 0xb8(%rsp), %rdi
callq 0x8988
leaq 0xf8(%rsp), %rdi
callq 0xac88
leaq 0x18(%rsp), %rdi
callq 0x24560
leaq 0x78(%rsp), %rdi
callq 0x8988
leaq 0x98(%rsp), %rdi
callq 0x8988
movq %rbx, %rax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x9349
jmp 0x9327
movq %rax, %rbx
movq %r15, %r14
jmp 0x935d
movq %rax, %rbx
jmp 0x935d
movq %rax, %rbx
jmp 0x9353
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x8988
leaq 0xf8(%rsp), %rdi
callq 0xac88
leaq 0x18(%rsp), %rdi
callq 0x24560
leaq 0x78(%rsp), %rdi
callq 0x8988
movq %r14, %rdi
callq 0x8988
movq %rbx, %rdi
callq 0x84b0