// File: bonetblai[P]mdp-engine/ctp3/./graph.h
// Function: CTP::graph_t::parse(std::istream&)
bool parse(std::istream &is) {
        // read graph from file
        edge_list_.clear();
        at_.clear();

        std::string token;
        is >> token;
        if( token == "p" ) {
            int n_edges;
            is >> num_nodes_ >> n_edges;

            edges_ = new int[num_nodes_ * num_nodes_];
            for( int n1 = 0; n1 < num_nodes_; ++n1 ) {
                for( int n2 = 0; n2 < num_nodes_; ++n2 )
                    edges_[n1*num_nodes_ + n2] = -1;
            }

            at_.resize(num_nodes_);
            for( int e = 0; e < n_edges; ++e ) {
                is >> token;
                if( token == "e" ) {
                    int from, to, cost;
                    float prob;
                    is >> from >> to >> prob >> cost;
                    --from;
                    --to;
                    add_edge(edge_t(from, to, cost, prob));
                } else {
                    std::cout << "error reading input file: road doesn't start with 'e'." << std::endl;
                    return false;
                }
            }
        } else {
            std::cout << "error reading input file: file doesn't start with 'p'." << std::endl;
            return false;
        }

        // insert shortcut (s,t) edge
        if( with_shortcut_ ) {
            std::cout << "info: adding (s,t) shortcut w/ cost " << shortcut_cost_ << std::endl;
            add_edge(edge_t(0, num_nodes_ - 1, shortcut_cost_, 1.0));
        }

        std::cout << "info: #nodes=" << num_nodes_
                  << ", #edges=" << num_edges_
                  << ", degree=" << degree()
                  << std::endl;

        // compute optimistic shortest-paths to goal
        h_opt_ = new int[num_nodes_];
        in_queue_ = new int[num_nodes_];
        for( int node = 0; node < num_nodes_; ++node )
            h_opt_[node] = INT_MAX;

        std::priority_queue<std::pair<int, int>,
                            std::vector<std::pair<int, int> >,
                            open_list_cmp> queue;

        int goal = num_nodes_ - 1;
        h_opt_[goal] = 0;
        queue.push(std::make_pair(goal, 0));
        while( !queue.empty() ) {
            std::pair<int, int> p = queue.top();
            queue.pop();
            if( p.second <= h_opt_[p.first] ) {
                for( int i = 0, isz = at_[p.first].size(); i < isz; ++i ) {
                    const edge_t &e = edge_list_[at_[p.first][i]];
                    int cost = p.second + e.cost_;
                    int to = e.from_ == p.first ? e.to_ : e.from_;
                    if( cost < h_opt_[to] ) {
                        h_opt_[to] = cost;
                        queue.push(std::make_pair(to, cost));
                    }
                }
            }
        }

        return true;
    }

// Assembly:
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdi, 0x1b8(%rsp)
movq %rsi, 0x1b0(%rsp)
movq 0x1b8(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
addq $0x10, %rdi
callq 0xd8b0
movq 0xd0(%rsp), %rdi
addq $0x28, %rdi
callq 0xd8d0
leaq 0x190(%rsp), %rdi
movq %rdi, 0xd8(%rsp)
callq 0x6470
movq 0xd8(%rsp), %rsi
movq 0x1b0(%rsp), %rdi
callq 0x6410
jmp 0x86dd
leaq 0x550d2(%rip), %rsi     # 0x5d7b6
leaq 0x190(%rsp), %rdi
callq 0x8590
movb %al, 0xcf(%rsp)
jmp 0x86fa
movb 0xcf(%rsp), %al
testb $0x1, %al
jne 0x870a
jmp 0x89dc
movq 0xd0(%rsp), %rsi
movq 0x1b0(%rsp), %rdi
callq 0x61e0
movq %rax, 0xc0(%rsp)
jmp 0x8729
movq 0xc0(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0x61e0
jmp 0x8740
movq 0xd0(%rsp), %rax
movl (%rax), %eax
imull %eax, %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x6030
movq %rax, 0xb8(%rsp)
jmp 0x8762
movq 0xd0(%rsp), %rax
movq 0xb8(%rsp), %rcx
movq %rcx, 0x40(%rax)
movl $0x0, 0x17c(%rsp)
movq 0xd0(%rsp), %rcx
movl 0x17c(%rsp), %eax
cmpl (%rcx), %eax
jge 0x8821
movl $0x0, 0x178(%rsp)
movq 0xd0(%rsp), %rcx
movl 0x178(%rsp), %eax
cmpl (%rcx), %eax
jge 0x8809
movq 0xd0(%rsp), %rdx
movq 0x40(%rdx), %rax
movl 0x17c(%rsp), %ecx
imull (%rdx), %ecx
addl 0x178(%rsp), %ecx
movslq %ecx, %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl 0x178(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x178(%rsp)
jmp 0x87a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x8f29
jmp 0x880b
movl 0x17c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x17c(%rsp)
jmp 0x8781
movq 0xd0(%rsp), %rax
movq %rax, %rdi
addq $0x28, %rdi
movslq (%rax), %rsi
callq 0xd8f0
jmp 0x883a
movl $0x0, 0x174(%rsp)
movl 0x174(%rsp), %eax
cmpl 0x180(%rsp), %eax
jge 0x89da
movq 0x1b0(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x6410
jmp 0x8870
leaq 0x56fc1(%rip), %rsi     # 0x5f838
leaq 0x190(%rsp), %rdi
callq 0x8590
movb %al, 0xb7(%rsp)
jmp 0x888d
movb 0xb7(%rsp), %al
testb $0x1, %al
jne 0x889d
jmp 0x8977
movq 0x1b0(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0x61e0
movq %rax, 0xa8(%rsp)
jmp 0x88bc
movq 0xa8(%rsp), %rdi
leaq 0x16c(%rsp), %rsi
callq 0x61e0
movq %rax, 0xa0(%rsp)
jmp 0x88db
movq 0xa0(%rsp), %rdi
leaq 0x164(%rsp), %rsi
callq 0x60a0
movq %rax, 0x98(%rsp)
jmp 0x88fa
movq 0x98(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x61e0
jmp 0x8911
movl 0x170(%rsp), %eax
decl %eax
movl %eax, 0x170(%rsp)
movl 0x16c(%rsp), %eax
decl %eax
movl %eax, 0x16c(%rsp)
movl 0x170(%rsp), %esi
movl 0x16c(%rsp), %edx
movl 0x168(%rsp), %ecx
movss 0x164(%rsp), %xmm0
leaq 0x154(%rsp), %rdi
callq 0xda90
jmp 0x895e
movq 0xd0(%rsp), %rdi
leaq 0x154(%rsp), %rsi
callq 0xd990
jmp 0x8975
jmp 0x89c2
movq 0x7a652(%rip), %rdi     # 0x82fd0
leaq 0x54941(%rip), %rsi     # 0x5d2c6
callq 0x6330
movq %rax, 0x90(%rsp)
jmp 0x8994
movq 0x90(%rsp), %rdi
movq 0x7a615(%rip), %rsi     # 0x82fb8
callq 0x6370
jmp 0x89aa
movb $0x0, 0x1c7(%rsp)
movl $0x1, 0x150(%rsp)
jmp 0x8f0b
jmp 0x89c4
movl 0x174(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x174(%rsp)
jmp 0x8845
jmp 0x8a27
movq 0x7a5ed(%rip), %rdi     # 0x82fd0
leaq 0x54913(%rip), %rsi     # 0x5d2fd
callq 0x6330
movq %rax, 0x88(%rsp)
jmp 0x89f9
movq 0x88(%rsp), %rdi
movq 0x7a5b0(%rip), %rsi     # 0x82fb8
callq 0x6370
jmp 0x8a0f
movb $0x0, 0x1c7(%rsp)
movl $0x1, 0x150(%rsp)
jmp 0x8f0b
movq 0xd0(%rsp), %rax
testb $0x1, 0x8(%rax)
je 0x8ac9
movq 0x7a590(%rip), %rdi     # 0x82fd0
leaq 0x548ed(%rip), %rsi     # 0x5d334
callq 0x6330
movq %rax, 0x80(%rsp)
jmp 0x8a56
movq 0x80(%rsp), %rdi
movq 0xd0(%rsp), %rax
movl 0xc(%rax), %esi
callq 0x6510
movq %rax, 0x78(%rsp)
jmp 0x8a75
movq 0x78(%rsp), %rdi
movq 0x7a537(%rip), %rsi     # 0x82fb8
callq 0x6370
jmp 0x8a88
movq 0xd0(%rsp), %rax
movl (%rax), %edx
movl 0xc(%rax), %ecx
decl %edx
leaq 0x140(%rsp), %rdi
xorl %esi, %esi
movss 0x5455b(%rip), %xmm0    # 0x5d004
callq 0xda90
jmp 0x8ab0
movq 0xd0(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0xd990
jmp 0x8ac7
jmp 0x8ac9
movq 0x7a500(%rip), %rdi     # 0x82fd0
leaq 0x54882(%rip), %rsi     # 0x5d359
callq 0x6330
movq %rax, 0x70(%rsp)
jmp 0x8ae3
movq 0x70(%rsp), %rdi
movq 0xd0(%rsp), %rax
movl (%rax), %esi
callq 0x6510
movq %rax, 0x68(%rsp)
jmp 0x8afe
movq 0x68(%rsp), %rdi
leaq 0x5485d(%rip), %rsi     # 0x5d367
callq 0x6330
movq %rax, 0x60(%rsp)
jmp 0x8b16
movq 0x60(%rsp), %rdi
movq 0xd0(%rsp), %rax
movl 0x4(%rax), %esi
callq 0x6510
movq %rax, 0x58(%rsp)
jmp 0x8b32
movq 0x58(%rsp), %rdi
leaq 0x54833(%rip), %rsi     # 0x5d371
callq 0x6330
movq %rax, 0x50(%rsp)
jmp 0x8b4a
movq 0xd0(%rsp), %rdi
callq 0xdad0
movl %eax, 0x4c(%rsp)
jmp 0x8b5d
movl 0x4c(%rsp), %esi
movq 0x50(%rsp), %rdi
callq 0x6510
movq %rax, 0x40(%rsp)
jmp 0x8b72
movq 0x40(%rsp), %rdi
movq 0x7a43a(%rip), %rsi     # 0x82fb8
callq 0x6370
jmp 0x8b85
movq 0xd0(%rsp), %rax
movslq (%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x6030
movq %rax, 0x38(%rsp)
jmp 0x8bb2
movq 0xd0(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, 0x48(%rax)
movslq (%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x6030
movq %rax, 0x30(%rsp)
jmp 0x8be8
movq 0xd0(%rsp), %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0x50(%rax)
movl $0x0, 0x13c(%rsp)
movq 0xd0(%rsp), %rcx
movl 0x13c(%rsp), %eax
cmpl (%rcx), %eax
jge 0x8c45
movq 0xd0(%rsp), %rax
movq 0x48(%rax), %rax
movslq 0x13c(%rsp), %rcx
movl $0x7fffffff, (%rax,%rcx,4) # imm = 0x7FFFFFFF
movl 0x13c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x13c(%rsp)
jmp 0x8c04
leaq 0x118(%rsp), %rdi
callq 0xdb50
jmp 0x8c54
movq 0xd0(%rsp), %rax
movl (%rax), %ecx
decl %ecx
movl %ecx, 0x114(%rsp)
movq 0x48(%rax), %rax
movslq 0x114(%rsp), %rcx
movl $0x0, (%rax,%rcx,4)
movl $0x0, 0x108(%rsp)
leaq 0x114(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0xdbe0
movq %rax, 0x28(%rsp)
jmp 0x8ca1
movq 0x28(%rsp), %rax
movq %rax, 0x10c(%rsp)
leaq 0x118(%rsp), %rdi
leaq 0x10c(%rsp), %rsi
callq 0xdb80
jmp 0x8cc5
jmp 0x8cc7
leaq 0x118(%rsp), %rdi
callq 0xdc10
movb %al, 0x27(%rsp)
jmp 0x8cda
movb 0x27(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x8ce9
jmp 0x8eeb
leaq 0x118(%rsp), %rdi
callq 0xdc30
movq %rax, 0x18(%rsp)
jmp 0x8cfd
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x100(%rsp)
leaq 0x118(%rsp), %rdi
callq 0xdc40
jmp 0x8d1c
movq 0xd0(%rsp), %rcx
movl 0x104(%rsp), %eax
movq 0x48(%rcx), %rcx
movslq 0x100(%rsp), %rdx
cmpl (%rcx,%rdx,4), %eax
jg 0x8ee6
movq 0xd0(%rsp), %rdi
movl $0x0, 0xfc(%rsp)
addq $0x28, %rdi
movslq 0x100(%rsp), %rsi
callq 0xdc90
movq %rax, %rdi
callq 0xdcb0
movl %eax, 0xf8(%rsp)
movl 0xfc(%rsp), %eax
cmpl 0xf8(%rsp), %eax
jge 0x8ee4
movq 0xd0(%rsp), %rdi
movq %rdi, %rax
addq $0x10, %rax
movq %rax, 0x10(%rsp)
addq $0x28, %rdi
movslq 0x100(%rsp), %rsi
callq 0xdc90
movq %rax, %rdi
movslq 0xfc(%rsp), %rsi
callq 0xdcf0
movq 0x10(%rsp), %rdi
movslq (%rax), %rsi
callq 0xdcd0
movq %rax, 0xf0(%rsp)
movl 0x104(%rsp), %eax
movq 0xf0(%rsp), %rcx
addl 0x8(%rcx), %eax
movl %eax, 0xec(%rsp)
movq 0xf0(%rsp), %rax
movl (%rax), %eax
cmpl 0x100(%rsp), %eax
jne 0x8e0e
movq 0xf0(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0xc(%rsp)
jmp 0x8e1c
movq 0xf0(%rsp), %rax
movl (%rax), %eax
movl %eax, 0xc(%rsp)
movq 0xd0(%rsp), %rcx
movl 0xc(%rsp), %eax
movl %eax, 0xe8(%rsp)
movl 0xec(%rsp), %eax
movq 0x48(%rcx), %rcx
movslq 0xe8(%rsp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x8ecc
movq 0xd0(%rsp), %rax
movl 0xec(%rsp), %edx
movq 0x48(%rax), %rax
movslq 0xe8(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
leaq 0xe8(%rsp), %rdi
leaq 0xec(%rsp), %rsi
callq 0xdd10
movq %rax, (%rsp)
jmp 0x8e84
movq (%rsp), %rax
movq %rax, 0xe0(%rsp)
leaq 0x118(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0xdb80
jmp 0x8ea7
jmp 0x8ecc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0x118(%rsp), %rdi
callq 0xdd40
jmp 0x8f29
jmp 0x8ece
movl 0xfc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xfc(%rsp)
jmp 0x8d73
jmp 0x8ee6
jmp 0x8cc7
movb $0x1, 0x1c7(%rsp)
movl $0x1, 0x150(%rsp)
leaq 0x118(%rsp), %rdi
callq 0xdd40
leaq 0x190(%rsp), %rdi
callq 0x61f0
movb 0x1c7(%rsp), %al
andb $0x1, %al
addq $0x1c8, %rsp            # imm = 0x1C8
retq
leaq 0x190(%rsp), %rdi
callq 0x61f0
movq 0x188(%rsp), %rdi
callq 0x6520
nopw %cs:(%rax,%rax)
nopl (%rax)