// File: /workspace/github_cpp_makefile_star2_O2/bonetblai[P]mdp-engine/race/parsing.cc
// Function: grid_t::parse(std::ostream&, _IO_FILE*)
void grid_t::parse(ostream &os, FILE *is) {
    char buff[1024];
    if( fgets(buff, sizeof(buff), is) == NULL ) {
        os << "error reading file header" << endl;
        throw(0);
    } else {
        sscanf(buff, "dim: %u %u", &rows_, &cols_);
        if( (rows_ == 0) || (cols_ == 0) ) throw( 0 );
        assert((size_t)cols_ <= sizeof(buff));
        map_ = new char[rows_ * cols_];
    }

    // parse file
    for( size_t r = 0; r < (size_t)rows_; ++r ) {
        if( fgets(buff, sizeof(buff), is) == NULL ) {
            os << " error while reading row " << r << endl;
            throw(0);
        }
        for( size_t c = 0; c < (size_t)cols_; ++c ) {
            switch( buff[c] ) {
                case 's':
                    map_[r*cols_ + c] = Valid | Start;
                    starts_.push_back(r*cols_ + c);
                    break;
                case 'g':
                    map_[r*cols_ + c] = Valid | Goal;
                    goals_.push_back(r*cols_ + c);
                    break;
                case '.':
                    map_[r*cols_ + c] = Valid;
                    break;
                case 'x':
                    map_[r*cols_ + c] = Invalid;
                    break;
                default:
                    os << " error reading col " << c << " of row " << r << endl;
                    throw(0);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movq %rsi, %r14
movq %rdi, %r15
leaq 0x30(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %rdx, 0x20(%rsp)
callq 0x53a0
testq %rax, %rax
je 0x1cb42
leaq 0x10(%r15), %rdx
leaq 0x14(%r15), %r13
leaq 0x4442(%rip), %rsi      # 0x20dd7
leaq 0x30(%rsp), %rdi
movq %rdx, 0x18(%rsp)
movq %r13, %rcx
xorl %eax, %eax
callq 0x5260
movl 0x10(%r15), %ebx
testl %ebx, %ebx
je 0x1cb18
movl (%r13), %eax
testl %eax, %eax
je 0x1cb18
movq %r14, 0x10(%rsp)
cmpl $0x401, %eax            # imm = 0x401
jae 0x1cb53
imull %ebx, %eax
testl %eax, %eax
pushq $-0x1
popq %rcx
cmovnsl %eax, %ecx
movslq %ecx, %rdi
callq 0x5030
movq %rax, 0x8(%r15)
leaq 0x30(%r15), %rax
movq %rax, 0x28(%rsp)
leaq 0x18(%r15), %r14
xorl %ebp, %ebp
leaq 0xc(%rsp), %r12
movslq %ebx, %rax
cmpq %rax, %rbp
jae 0x1cac8
leaq 0x30(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq 0x20(%rsp), %rdx
callq 0x53a0
testq %rax, %rax
je 0x1cb34
xorl %ebx, %ebx
movslq (%r13), %rax
cmpq %rax, %rbx
jae 0x1cab9
movzbl 0x30(%rsp,%rbx), %ecx
cmpl $0x2e, %ecx
je 0x1ca7d
cmpl $0x67, %ecx
je 0x1ca8b
cmpl $0x78, %ecx
je 0x1ca6f
cmpl $0x73, %ecx
jne 0x1cada
imulq %rbp, %rax
addq 0x8(%r15), %rax
movb $0x3, (%rbx,%rax)
movl 0x14(%r15), %eax
imull %ebp, %eax
addl %ebx, %eax
movl %eax, 0xc(%rsp)
movq %r14, %rdi
jmp 0x1caa9
imulq %rbp, %rax
addq 0x8(%r15), %rax
movb $0x8, (%rbx,%rax)
jmp 0x1cab1
imulq %rbp, %rax
addq 0x8(%r15), %rax
movb $0x1, (%rbx,%rax)
jmp 0x1cab1
imulq %rbp, %rax
addq 0x8(%r15), %rax
movb $0x5, (%rbx,%rax)
movl 0x14(%r15), %eax
imull %ebp, %eax
addl %ebx, %eax
movl %eax, 0xc(%rsp)
movq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0x1cd70
incq %rbx
jmp 0x1ca27
incq %rbp
movq 0x18(%rsp), %rax
movl (%rax), %ebx
jmp 0x1c9fc
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x436a(%rip), %rsi      # 0x20e4b
movq 0x10(%rsp), %rdi
callq 0x5270
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5070
leaq 0x4362(%rip), %rsi      # 0x20e5f
movq %rax, %rdi
callq 0x5270
movq %rax, %rdi
movq %rbp, %rsi
callq 0x5070
movq %rax, %rdi
callq 0x5100
pushq $0x4
popq %rdi
callq 0x5110
andl $0x0, (%rax)
movq 0x1348e(%rip), %rsi     # 0x2ffb8
movq %rax, %rdi
xorl %edx, %edx
callq 0x5410
leaq 0x42f6(%rip), %rsi      # 0x20e31
movq 0x10(%rsp), %rdi
jmp 0x1cb00
leaq 0x4274(%rip), %rsi      # 0x20dbd
movq %r14, %rdi
callq 0x5270
jmp 0x1cb10
leaq 0x4288(%rip), %rdi      # 0x20de2
leaq 0x429f(%rip), %rsi      # 0x20e00
leaq 0x42a3(%rip), %rcx      # 0x20e0b
pushq $0x41
popq %rdx
callq 0x5170