digraph write_alac_residual {
  node [fontname="DejaVuSans"];
  edge [fontname="DejaVuSans"];
  ratio=fill;
  margin=0;
  size="4,4";

  init [shape=record,label="{total_entries|current_entry = 0}"];
  init -> read_current_length;
  read_current_length [shape=parallelogram,label="current_length = read 5"];
  read_current_length -> incr_current_length;
  incr_current_length [shape=rect,label="current_length = current_length + 1"];
  incr_current_length -> set_number_bits;
  set_number_bits [shape=rect,label="number_bits = ilog(total_entries - current_entry)"];
  set_number_bits -> read_number;
  read_number [shape=parallelogram,label="number = read number_bits"];
  read_number -> check_number;
  check_number [shape=diamond,label="is\nnumber > 0?"];
  check_number -> set_entry [label="YES"];
  check_number -> increment_current_length [label="NO"];
  set_entry [shape=rect,label="entry[current_entry] = current_length"];
  set_entry -> decrement_number;
  decrement_number [shape=record,label="{number = number - 1|current_entry = current_entry + 1}"];
  decrement_number -> check_number;
  increment_current_length [shape=rect,label="current_length = current_length + 1"];
  increment_current_length -> check_current_entry;
  check_current_entry [shape=diamond,label="is\ncurrent_entry < total_entries?"];
  check_current_entry -> set_number_bits [label="YES"];
  check_current_entry -> done [label="NO"];
  done [shape=record,label="done"];
}
