nodes: 0, module; 1, function_definition; 2, function_name:_generate_a_indptr; 3, parameters; 4, block; 5, identifier:num_states; 6, identifier:s_indices; 7, identifier:out; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, expression_statement; 13, comment:"""
      Generate `a_indptr`; stored in `out`. `s_indices` is assumed to be
      in sorted order.
  
      Parameters
      ----------
      num_states : scalar(int)
  
      s_indices : ndarray(int, ndim=1)
  
      out : ndarray(int, ndim=1)
          Length must be num_states+1.
  
      """; 14, assignment; 15, assignment; 16, identifier:s; 17, call; 18, block; 19, assignment; 20, identifier:idx; 21, integer:0; 22, subscript; 23, integer:0; 24, identifier:range; 25, argument_list; 26, while_statement; 27, expression_statement; 28, subscript; 29, call; 30, identifier:out; 31, integer:0; 32, binary_operator:num_states-1; 33, parenthesized_expression; 34, block; 35, assignment; 36, identifier:out; 37, identifier:num_states; 38, identifier:len; 39, argument_list; 40, identifier:num_states; 41, integer:1; 42, comparison_operator:s_indices[idx] == s; 43, expression_statement; 44, subscript; 45, identifier:idx; 46, identifier:s_indices; 47, subscript; 48, identifier:s; 49, augmented_assignment; 50, identifier:out; 51, binary_operator:s+1; 52, identifier:s_indices; 53, identifier:idx; 54, identifier:idx; 55, integer:1; 56, identifier:s; 57, integer:1
code: def _generate_a_indptr(num_states, s_indices, out):
      """
      Generate `a_indptr`; stored in `out`. `s_indices` is assumed to be
      in sorted order.
  
      Parameters
      ----------
      num_states : scalar(int)
  
      s_indices : ndarray(int, ndim=1)
  
      out : ndarray(int, ndim=1)
          Length must be num_states+1.
  
      """
      idx = 0
      out[0] = 0
      for s in range(num_states-1):
          while(s_indices[idx] == s):
              idx += 1
          out[s+1] = idx
      out[num_states] = len(s_indices)