// Phase 95: json_loader escape loop (minimal)
// Purpose: Fixture extracted from MiniJsonLoader.read_quoted_from to exercise
//          Phase 94 derived body-local + conditional skip in JoinIR.

static box Main {
    main() {
        // Input mirrors the json_loader escape case
        local s = "\"hello\\\" world\""
        local pos = 0
        local i = pos
        if s.substring(i, i + 1) != "\"" { return "NG" }
        i = i + 1
        local out = ""
        local n = s.length()

        loop(i < n) {
            local ch = s.substring(i, i + 1)
            if ch == "\"" { break }

            if ch == "\\" {
                i = i + 1
                if i < n {
                    ch = s.substring(i, i + 1)
                }
            }

            out = out + ch
            i = i + 1
        }

        print(out)
        return "OK"
    }
}
