// File: /workspace/github_cpp_makefile_star2_O2/grisu48[P]geoJson/geoJson.cpp
// Function: processStream(std::istream&, std::ostream&)
static bool processStream(istream &in, ostream &out = cout) {
	out << setprecision(7);
	
    // Read stream to end
    stringstream buf;
    string text;
    while((getline(in, text)))
        buf << text << '\n';
    text = buf.str();
    
    
    // Parse GPX
    try {
        xml_document<> doc;                     // character type defaults to char
        doc.parse<0>((char*)text.c_str());      // 0 means default parse flags
        
        xml_node<> *node = doc.first_node("gpx");
        if(node == NULL) throw "No data";
        
        // Get GPX attributes
        map<string, string> attrs;              // GPX attributes
        for (xml_attribute<> *attr = node->first_attribute(); attr; attr = attr->next_attribute())
            attrs[attr->name()] = attr->value();

        vector<Coords> coords;

        // Read out tracks
        for (xml_node<> *child = node->first_node("trk"); child; child = child->next_sibling("trk"))
        {
            // Scan for track segments
            for (xml_node<> *seg = child->first_node("trkseg"); seg; seg = seg->next_sibling("trkseg")) {
                // And track points
                for (xml_node<> *pt = seg->first_node("trkpt"); pt; pt = pt->next_sibling("trkpt")) {
                    
                    Coords coord;
                    
                    for (xml_attribute<> *attr = pt->first_attribute(); attr; attr = attr->next_attribute()) {
                        string name = attr->name();
                        if(name == "lon")
                            coord.lon = ::atof(attr->value());
                        else if(name == "lat")
                            coord.lat = ::atof(attr->value());
                    }
                    for (xml_node<> *p = pt->first_node(); p; p = p->next_sibling()) {
                        string name = p->name();
                        if(name == "ele")
                            coord.ele = ::atof(p->value());
                        else if (name == "time")
                            coord.time = p->value();
                    }
                    
                    coords.push_back(coord);
                    
                }
            }
        }
        
        printGeoJson(out, coords);
        
    } catch (parse_error &e) {
        cerr << "Parse error: " << e.what() << endl;
        return false;
    } catch (const char* msg) {
        cerr << "Parse error: No GPX data" << endl;
        return false;
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x102f8, %rsp          # imm = 0x102F8
movq (%rsi), %rax
movq %rdi, %rbx
leaq 0xe8(%rsp), %rdi
movq %rsi, 0x8(%rsp)
movq -0x18(%rax), %rax
movq $0x7, 0x8(%rsi,%rax)
callq 0x2160
leaq 0x88(%rsp), %rax
leaq 0xf8(%rsp), %r14
leaq 0x78(%rsp), %r15
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
pushq $0xa
popq %rbp
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2060
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x295a
movq %r14, %rdi
movq %r15, %rsi
callq 0x21b0
movq %rax, %rdi
movl %ebp, %esi
callq 0x2210
jmp 0x292a
leaq 0x100(%rsp), %rsi
leaq 0x270(%rsp), %rdi
callq 0x22a0
leaq 0x78(%rsp), %rbx
leaq 0x270(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2220
movq %r14, %rdi
callq 0x20f0
vxorps %xmm0, %xmm0, %xmm0
andq $0x0, 0x20(%r14)
movq (%rbx), %rsi
leaq 0x102e8(%rsp), %rax
leaq 0x2e8(%rsp), %rcx
vmovaps %xmm0, (%r14)
andl $0x0, 0x28(%r14)
andq $0x0, 0x30(%r14)
andq $0x0, 0x40(%r14)
vmovups %xmm0, (%rax)
movq %rcx, -0x18(%rcx)
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
leaq 0x270(%rsp), %rdi
callq 0x31b6
leaq 0x28a3(%rip), %rsi      # 0x5286
leaq 0x270(%rsp), %rdi
pushq $0x1
popq %rcx
xorl %edx, %edx
callq 0x3284
testq %rax, %rax
je 0x300e
leaq 0xc0(%rsp), %rcx
leaq 0x67ad(%rip), %r12      # 0x91ba
leaq 0x38(%rsp), %r14
leaq 0x98(%rsp), %r15
leaq 0xb8(%rsp), %rbp
movq %rax, 0x18(%rsp)
andl $0x0, (%rcx)
andq $0x0, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
andq $0x0, 0x20(%rcx)
movq 0x40(%rax), %rbx
testq %rbx, %rbx
je 0x2a95
movq 0x8(%rbx), %r13
movq (%rbx), %rsi
testq %r13, %r13
cmoveq %r12, %r13
testq %rsi, %rsi
cmoveq %r12, %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x20d0
movq %rbp, %rdi
movq %r14, %rsi
callq 0x331c
movq %rax, %rdi
movq %r13, %rsi
callq 0x2300
movq %r14, %rdi
callq 0x20f0
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x2a90
movq 0x30(%rbx), %rax
movq %rax, %rbx
jmp 0x2a40
andq $0x0, 0x30(%rsp)
vxorps %xmm0, %xmm0, %xmm0
vmovaps %xmm0, 0x20(%rsp)
leaq 0x27e6(%rip), %rsi      # 0x5292
pushq $0x1
popq %rcx
movq 0x18(%rsp), %rdi
xorl %edx, %edx
callq 0x3284
movq %rax, %rbx
pushq $0x1
popq %rbp
leaq 0x98(%rsp), %r13
leaq 0x17(%rsp), %r14
leaq 0x27ce(%rip), %r15      # 0x52a3
testq %rbx, %rbx
je 0x2ceb
leaq 0x27b1(%rip), %rsi      # 0x5296
movq %rbx, %rdi
xorl %edx, %edx
movl %ebp, %ecx
callq 0x3284
movq %rbx, 0x70(%rsp)
testq %rax, %rax
je 0x2cd0
leaq 0x2797(%rip), %rsi      # 0x529d
movq %rax, 0x68(%rsp)
movq %rax, %rdi
xorl %edx, %edx
movl %ebp, %ecx
callq 0x3284
movq %rax, %rcx
testq %rcx, %rcx
je 0x2cb6
leaq 0x58(%rsp), %rax
andq $0x0, 0x38(%rsp)
andl $0x0, 0x40(%rsp)
movq %rcx, 0x18(%rsp)
movq %rax, 0x48(%rsp)
andq $0x0, 0x50(%rsp)
movb $0x0, 0x58(%rsp)
movq 0x40(%rcx), %rbx
testq %rbx, %rbx
je 0x2bdf
movq (%rbx), %rsi
testq %rsi, %rsi
cmoveq %r12, %rsi
movq %r13, %rdi
movq %r14, %rdx
callq 0x20d0
movq %r13, %rdi
movq %r15, %rsi
callq 0x31a8
testb %al, %al
je 0x2b95
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
cmoveq %r12, %rdi
callq 0x2230
vcvtsd2ss %xmm0, %xmm0, %xmm0
vmovss %xmm0, 0x38(%rsp)
jmp 0x2bc2
leaq 0x270b(%rip), %rsi      # 0x52a7
movq %r13, %rdi
callq 0x31a8
testb %al, %al
je 0x2bc2
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
cmoveq %r12, %rdi
callq 0x2230
vcvtsd2ss %xmm0, %xmm0, %xmm0
vmovss %xmm0, 0x3c(%rsp)
movq %r13, %rdi
callq 0x20f0
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x2bd7
movq 0x30(%rbx), %rax
movq %rax, %rbx
jmp 0x2b4c
movq 0x18(%rsp), %rax
movq 0x30(%rax), %rbx
testq %rbx, %rbx
je 0x2c7b
movq (%rbx), %rsi
testq %rsi, %rsi
cmoveq %r12, %rsi
movq %r13, %rdi
movq %r14, %rdx
callq 0x20d0
leaq 0x269e(%rip), %rsi      # 0x52ab
movq %r13, %rdi
callq 0x31a8
testb %al, %al
je 0x2c35
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
cmoveq %r12, %rdi
callq 0x2230
vcvtsd2ss %xmm0, %xmm0, %xmm0
vmovss %xmm0, 0x40(%rsp)
jmp 0x2c5d
leaq 0x2673(%rip), %rsi      # 0x52af
movq %r13, %rdi
callq 0x31a8
testb %al, %al
je 0x2c5d
movq 0x8(%rbx), %rsi
testq %rsi, %rsi
cmoveq %r12, %rsi
leaq 0x48(%rsp), %rdi
callq 0x2300
movq %r13, %rdi
callq 0x20f0
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl %ebp, %ecx
callq 0x3382
movq %rax, %rbx
jmp 0x2be8
leaq 0x20(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x3420
leaq 0x48(%rsp), %rdi
callq 0x20f0
movq 0x18(%rsp), %rdi
leaq 0x25fd(%rip), %rsi      # 0x529d
xorl %edx, %edx
movl %ebp, %ecx
callq 0x3382
movq 0x70(%rsp), %rbx
movq %rax, %rcx
jmp 0x2b1a
movq 0x68(%rsp), %rdi
leaq 0x25d4(%rip), %rsi      # 0x5296
xorl %edx, %edx
movl %ebp, %ecx
callq 0x3382
jmp 0x2af6
leaq 0x25bb(%rip), %rsi      # 0x5292
movq %rbx, %rdi
xorl %edx, %edx
movl %ebp, %ecx
callq 0x3382
movq %rax, %rbx
jmp 0x2ad5
movq 0x8(%rsp), %rdi
leaq 0x28dc(%rip), %rsi      # 0x55d3
callq 0x21d0
movq %rax, %rdi
callq 0x2100
leaq 0x288d(%rip), %rsi      # 0x5598
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x2100
leaq 0x2897(%rip), %rsi      # 0x55b9
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x2100
leaq 0x2892(%rip), %rsi      # 0x55cb
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x2100
leaq 0x2885(%rip), %rsi      # 0x55d5
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x2100
leaq 0x288d(%rip), %rsi      # 0x55f4
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x2100
leaq 0x2892(%rip), %rsi      # 0x5610
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x2100
movq 0x20(%rsp), %rbx
movb $0x1, %al
leaq 0x2655(%rip), %r14      # 0x53f1
leaq 0x288d(%rip), %r15      # 0x5630
cmpq 0x28(%rsp), %rbx
je 0x2dea
testb $0x1, %al
jne 0x2dbb
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x21d0
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x21d0
addq $0x10, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x21b0
movq %rax, %rdi
movq %r14, %rsi
callq 0x21d0
addq $0x20, %rbx
xorl %eax, %eax
jmp 0x2da3
movq 0x8(%rsp), %rdi
leaq 0x28f0(%rip), %rsi      # 0x56e6
callq 0x21d0
movq %rax, %rdi
callq 0x2100
movq 0x8(%rsp), %rdi
leaq 0x2824(%rip), %rsi      # 0x5633
callq 0x21d0
movq %rax, %rdi
callq 0x2100
movq 0x8(%rsp), %rdi
leaq 0x281a(%rip), %rsi      # 0x5642
callq 0x21d0
movq %rax, %rdi
callq 0x2100
movq 0x8(%rsp), %rdi
leaq 0x281b(%rip), %rsi      # 0x565c
callq 0x21d0
movq %rax, %rdi
callq 0x2100
movq 0x8(%rsp), %rdi
leaq 0x2828(%rip), %rsi      # 0x5682
callq 0x21d0
movq %rax, %rdi
callq 0x2100
movq 0x20(%rsp), %rbp
movb $0x1, %al
leaq 0x282e(%rip), %rbx      # 0x56a3
leaq 0x283d(%rip), %r14      # 0x56b9
leaq 0x276f(%rip), %r15      # 0x55f2
leaq 0x2848(%rip), %r12      # 0x56d2
leaq 0x279f(%rip), %r13      # 0x5630
cmpq 0x28(%rsp), %rbp
je 0x2f5e
testb $0x1, %al
jne 0x2eb5
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x2100
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x2100
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x21d0
vmovss (%rbp), %xmm0
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x2100
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x21d0
vmovss 0x4(%rbp), %xmm0
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x2100
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x21d0
vmovss 0x8(%rbp), %xmm0
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x2100
movq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x21d0
addq $0x30, %rbp
xorl %eax, %eax
jmp 0x2e91
movq 0x8(%rsp), %rdi
callq 0x2100
movq 0x8(%rsp), %rdi
leaq 0x2762(%rip), %rsi      # 0x56d6
callq 0x21d0
movq %rax, %rdi
callq 0x2100
movq 0x8(%rsp), %rdi
leaq 0x275b(%rip), %rsi      # 0x56e8
callq 0x21d0
movq %rax, %rdi
callq 0x2100
movq 0x8(%rsp), %rdi
leaq 0x2746(%rip), %rsi      # 0x56ec
callq 0x21d0
movq %rax, %rdi
callq 0x2100
movq 0x8(%rsp), %rdi
leaq 0x2723(%rip), %rsi      # 0x56e2
callq 0x21d0
movq %rax, %rdi
callq 0x2100
movq 0x8(%rsp), %rdi
leaq 0x271c(%rip), %rsi      # 0x56f4
callq 0x21d0
movq %rax, %rdi
callq 0x2100
leaq 0x20(%rsp), %rdi
callq 0x344c
leaq 0xb8(%rsp), %rdi
callq 0x4e32
leaq 0x2d0(%rsp), %rdi
callq 0x4e7c
jmp 0x3158
pushq $0x8
popq %rdi
callq 0x2110
leaq 0x226d(%rip), %rcx      # 0x528a
movq %rcx, (%rax)
movq 0x5f89(%rip), %rsi      # 0x8fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x22c0
jmp 0x3086
jmp 0x3037
jmp 0x3062
movq %rdx, %r14
movq %rax, %rbx
jmp 0x30ce
jmp 0x3086
jmp 0x3086
movq %rdx, %r14
movq %rax, %rbx
jmp 0x30c1
jmp 0x3086
leaq 0x38(%rsp), %rdi
movq %rdx, %r14
movq %rax, %rbx
callq 0x20f0
jmp 0x30c1
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x20f0
leaq 0xe8(%rsp), %rdi
callq 0x2180
movq %rbx, %rdi
callq 0x22e0
jmp 0x3086
movq %rdx, %r14
movq %rax, %rbx
jmp 0x30b7
jmp 0x30a7
leaq 0x98(%rsp), %rdi
movq %rdx, %r14
movq %rax, %rbx
callq 0x20f0
jmp 0x30ad
jmp 0x30a7
movq %rdx, %r14
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x20f0
leaq 0x20(%rsp), %rdi
callq 0x344c
leaq 0xb8(%rsp), %rdi
callq 0x4e32
leaq 0x2d0(%rsp), %rdi
callq 0x4e7c
cmpl $0x2, %r14d
jne 0x3126
movq %rbx, %rdi
callq 0x20e0
movq %rax, %rbx
movq 0x5efd(%rip), %rdi      # 0x8ff0
leaq 0x21d3(%rip), %rsi      # 0x52cd
callq 0x21d0
movq (%rbx), %r15
movq %rbx, %rdi
movq %rax, %r14
callq *0x10(%r15)
movq %r14, %rdi
movq %rax, %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x2100
callq 0x22b0
jmp 0x3158
cmpl $0x1, %r14d
jne 0x3065
movq %rbx, %rdi
callq 0x20e0
movq 0x5eb1(%rip), %rdi      # 0x8ff0
leaq 0x216e(%rip), %rsi      # 0x52b4
callq 0x21d0
movq %rax, %rdi
callq 0x2100
callq 0x22b0
leaq 0x78(%rsp), %rdi
callq 0x20f0
leaq 0xe8(%rsp), %rdi
callq 0x2180
addq $0x102f8, %rsp          # imm = 0x102F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3062
movq %rax, %rbx
callq 0x22b0
jmp 0x3065
movq %rax, %rbx
callq 0x22b0
jmp 0x3065
movq %rax, %rdi
callq 0x346d