// File: gualtieromalde[P]owmread/owmread.C
// Function: readCoord(int)
Coord readCoord(int port)
{
    const std::string url_lat = "http://localhost:" + std::to_string(port) + "/json/position/latitude-deg";
    const std::string url_lon = "http://localhost:" + std::to_string(port) + "/json/position/longitude-deg";

    CURL* curlLat = curl_easy_init();

    curl_easy_setopt(curlLat, CURLOPT_URL, url_lat.c_str());
    curl_easy_setopt(curlLat, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
    curl_easy_setopt(curlLat, CURLOPT_TIMEOUT, 10);
    curl_easy_setopt(curlLat, CURLOPT_FOLLOWLOCATION, 1L);
    long httpCode(0);
    std::string httpDataLat;
    curl_easy_setopt(curlLat, CURLOPT_WRITEFUNCTION, WriteCallback);
    curl_easy_setopt(curlLat, CURLOPT_WRITEDATA, &httpDataLat);
    curl_easy_perform(curlLat);
    curl_easy_getinfo(curlLat, CURLINFO_RESPONSE_CODE, &httpCode);
    curl_easy_cleanup(curlLat);
    Json::Value jsonDataLat;
    Json::Reader jsonReaderLat;
    jsonReaderLat.parse(httpDataLat, jsonDataLat);   
    double lat = jsonDataLat["value"].asDouble();	     
    
     CURL* curlLon = curl_easy_init();

    curl_easy_setopt(curlLon, CURLOPT_URL, url_lon.c_str());
    curl_easy_setopt(curlLon, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
    curl_easy_setopt(curlLon, CURLOPT_TIMEOUT, 10);
    curl_easy_setopt(curlLon, CURLOPT_FOLLOWLOCATION, 1L);
    long httpCodeLon(0);
    std::string httpDataLon;
    curl_easy_setopt(curlLon, CURLOPT_WRITEFUNCTION, WriteCallback);
    curl_easy_setopt(curlLon, CURLOPT_WRITEDATA, &httpDataLon);
    curl_easy_perform(curlLon);
    curl_easy_getinfo(curlLon, CURLINFO_RESPONSE_CODE, &httpCodeLon);
    curl_easy_cleanup(curlLon);
    Json::Value jsonDataLon;
    Json::Reader jsonReaderLon;
    jsonReaderLon.parse(httpDataLon, jsonDataLon);   
    double lon = jsonDataLon["value"].asDouble();	     
    
    
    
    return Coord(lat,lon);
}

// Assembly:
subq $0x418, %rsp            # imm = 0x418
movl %edi, 0x404(%rsp)
movl 0x404(%rsp), %esi
leaq 0x3a0(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0xef70
movq 0x48(%rsp), %rdx
leaq 0x39428(%rip), %rsi     # 0x4667b
leaq 0x3c0(%rsp), %rdi
callq 0xf160
jmp 0xd262
leaq 0x39424(%rip), %rdx     # 0x4668d
leaq 0x3e0(%rsp), %rdi
leaq 0x3c0(%rsp), %rsi
callq 0xf0b0
jmp 0xd280
leaq 0x3c0(%rsp), %rdi
callq 0xac68
leaq 0x3a0(%rsp), %rdi
callq 0xac68
movl 0x404(%rsp), %esi
leaq 0x330(%rsp), %rdi
callq 0xef70
jmp 0xd2b0
leaq 0x393c4(%rip), %rsi     # 0x4667b
leaq 0x350(%rsp), %rdi
leaq 0x330(%rsp), %rdx
callq 0xf160
jmp 0xd2ce
leaq 0x393d4(%rip), %rdx     # 0x466a9
leaq 0x370(%rsp), %rdi
leaq 0x350(%rsp), %rsi
callq 0xf0b0
jmp 0xd2ec
leaq 0x350(%rsp), %rdi
callq 0xac68
leaq 0x330(%rsp), %rdi
callq 0xac68
callq 0xaa10
movq %rax, 0x40(%rsp)
jmp 0xd312
movq 0x40(%rsp), %rax
movq %rax, 0x328(%rsp)
movq 0x328(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x3e0(%rsp), %rdi
callq 0xa180
movq 0x38(%rsp), %rdi
movq %rax, %rdx
xorl %eax, %eax
movl $0x2712, %esi           # imm = 0x2712
callq 0xa8b0
jmp 0xd34f
movq 0x328(%rsp), %rdi
xorl %eax, %eax
movl $0x71, %esi
movl $0x1, %edx
callq 0xa8b0
jmp 0xd36a
movq 0x328(%rsp), %rdi
xorl %eax, %eax
movl $0xd, %esi
movl $0xa, %edx
callq 0xa8b0
jmp 0xd385
movq 0x328(%rsp), %rdi
xorl %eax, %eax
movl $0x34, %esi
movl $0x1, %edx
callq 0xa8b0
jmp 0xd3a0
movq $0x0, 0x320(%rsp)
leaq 0x300(%rsp), %rdi
callq 0xa390
movq 0x328(%rsp), %rdi
leaq -0x1768(%rip), %rdx     # 0xbc60
xorl %eax, %eax
movl $0x4e2b, %esi           # imm = 0x4E2B
callq 0xa8b0
jmp 0xd3d6
movq 0x328(%rsp), %rdi
xorl %eax, %eax
movl $0x2711, %esi           # imm = 0x2711
leaq 0x300(%rsp), %rdx
callq 0xa8b0
jmp 0xd3f4
movq 0x328(%rsp), %rdi
callq 0xa6d0
jmp 0xd403
movq 0x328(%rsp), %rdi
xorl %eax, %eax
movl $0x200002, %esi         # imm = 0x200002
leaq 0x320(%rsp), %rdx
callq 0xa9e0
jmp 0xd421
movq 0x328(%rsp), %rdi
callq 0xa1c0
jmp 0xd430
leaq 0x2d8(%rsp), %rdi
xorl %esi, %esi
callq 0x39080
jmp 0xd441
leaq 0x1c8(%rsp), %rdi
callq 0x2e210
jmp 0xd450
leaq 0x1c8(%rsp), %rdi
leaq 0x300(%rsp), %rsi
leaq 0x2d8(%rsp), %rdx
movl $0x1, %ecx
callq 0x2fe00
jmp 0xd474
leaq 0x3924b(%rip), %rsi     # 0x466c6
leaq 0x2d8(%rsp), %rdi
callq 0x3cca0
movq %rax, 0x30(%rsp)
jmp 0xd48f
movq 0x30(%rsp), %rdi
callq 0x37290
movsd %xmm0, 0x28(%rsp)
jmp 0xd4a1
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x1c0(%rsp)
callq 0xaa10
movq %rax, 0x20(%rsp)
jmp 0xd4bc
movq 0x20(%rsp), %rax
movq %rax, 0x1b8(%rsp)
movq 0x1b8(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x370(%rsp), %rdi
callq 0xa180
movq 0x18(%rsp), %rdi
movq %rax, %rdx
xorl %eax, %eax
movl $0x2712, %esi           # imm = 0x2712
callq 0xa8b0
jmp 0xd4f9
movq 0x1b8(%rsp), %rdi
xorl %eax, %eax
movl $0x71, %esi
movl $0x1, %edx
callq 0xa8b0
jmp 0xd514
movq 0x1b8(%rsp), %rdi
xorl %eax, %eax
movl $0xd, %esi
movl $0xa, %edx
callq 0xa8b0
jmp 0xd52f
movq 0x1b8(%rsp), %rdi
xorl %eax, %eax
movl $0x34, %esi
movl $0x1, %edx
callq 0xa8b0
jmp 0xd54a
movq $0x0, 0x1b0(%rsp)
leaq 0x190(%rsp), %rdi
callq 0xa390
movq 0x1b8(%rsp), %rdi
leaq -0x1912(%rip), %rdx     # 0xbc60
xorl %eax, %eax
movl $0x4e2b, %esi           # imm = 0x4E2B
callq 0xa8b0
jmp 0xd580
movq 0x1b8(%rsp), %rdi
xorl %eax, %eax
movl $0x2711, %esi           # imm = 0x2711
leaq 0x190(%rsp), %rdx
callq 0xa8b0
jmp 0xd59e
movq 0x1b8(%rsp), %rdi
callq 0xa6d0
jmp 0xd5ad
movq 0x1b8(%rsp), %rdi
xorl %eax, %eax
movl $0x200002, %esi         # imm = 0x200002
leaq 0x1b0(%rsp), %rdx
callq 0xa9e0
jmp 0xd5cb
movq 0x1b8(%rsp), %rdi
callq 0xa1c0
jmp 0xd5da
leaq 0x168(%rsp), %rdi
xorl %esi, %esi
callq 0x39080
jmp 0xd5eb
leaq 0x58(%rsp), %rdi
callq 0x2e210
jmp 0xd5f7
leaq 0x58(%rsp), %rdi
leaq 0x190(%rsp), %rsi
leaq 0x168(%rsp), %rdx
movl $0x1, %ecx
callq 0x2fe00
jmp 0xd618
leaq 0x390a7(%rip), %rsi     # 0x466c6
leaq 0x168(%rsp), %rdi
callq 0x3cca0
movq %rax, 0x10(%rsp)
jmp 0xd633
movq 0x10(%rsp), %rdi
callq 0x37290
movsd %xmm0, 0x8(%rsp)
jmp 0xd645
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0x1c0(%rsp), %xmm0
movsd 0x50(%rsp), %xmm1
leaq 0x408(%rsp), %rdi
callq 0xf1b0
jmp 0xd66f
leaq 0x58(%rsp), %rdi
callq 0xed10
leaq 0x168(%rsp), %rdi
callq 0x3a5a0
leaq 0x190(%rsp), %rdi
callq 0xac68
leaq 0x1c8(%rsp), %rdi
callq 0xed10
leaq 0x2d8(%rsp), %rdi
callq 0x3a5a0
leaq 0x300(%rsp), %rdi
callq 0xac68
leaq 0x370(%rsp), %rdi
callq 0xac68
leaq 0x3e0(%rsp), %rdi
callq 0xac68
movsd 0x408(%rsp), %xmm0
movsd 0x410(%rsp), %xmm1
addq $0x418, %rsp            # imm = 0x418
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0xd725
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
leaq 0x3c0(%rsp), %rdi
callq 0xac68
leaq 0x3a0(%rsp), %rdi
callq 0xac68
jmp 0xd89f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0xd892
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0xd787
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
leaq 0x350(%rsp), %rdi
callq 0xac68
leaq 0x330(%rsp), %rdi
callq 0xac68
jmp 0xd892
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0xd885
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0xd878
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0xd86b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0xd85e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0xd851
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0xd844
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
leaq 0x58(%rsp), %rdi
callq 0xed10
leaq 0x168(%rsp), %rdi
callq 0x3a5a0
leaq 0x190(%rsp), %rdi
callq 0xac68
leaq 0x1c8(%rsp), %rdi
callq 0xed10
leaq 0x2d8(%rsp), %rdi
callq 0x3a5a0
leaq 0x300(%rsp), %rdi
callq 0xac68
leaq 0x370(%rsp), %rdi
callq 0xac68
leaq 0x3e0(%rsp), %rdi
callq 0xac68
movq 0x398(%rsp), %rdi
callq 0xa670
nopl (%rax)