text: // Generated by CoffeeScript 1.9.2
  var SeussQueueCorrupt, fs, markers, roundbyte;
  
  fs = require('graceful-fs');
  
  markers = require('./markers');
  
  roundbyte = require('./roundbyte');
  
  SeussQueueCorrupt = require('./errors').SeussQueueCorrupt;
  
  module.exports = function(path) {
    var buffer, dequeues, i, j, k, l, length, marker, message, offset, ref, ref1, ref2, result, reverse;
    dequeues = 0;
    result = [];
    buffer = fs.readFileSync(path);
    offset = 0;
    while (offset < buffer.length) {
      marker = buffer.readUInt32BE(offset);
      offset += 4;
      if (marker === markers.noop) {
        break;
      }
      if (marker === markers.enqueue) {
        length = buffer.readUInt32BE(offset);
        offset += 4;
        message = buffer.toString('utf8', offset, offset + length);
        offset += length;
        offset = roundbyte(offset);
        result.push(JSON.parse(message));
      } else if (marker === markers.dequeue) {
        dequeues++;
      } else {
        throw new SeussQueueCorrupt();
      }
    }
    reverse = [];
    for (i = j = 0, ref = result.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
      reverse.push(result.pop());
    }
    for (i = k = 0, ref1 = dequeues; 0 <= ref1 ? k < ref1 : k > ref1; i = 0 <= ref1 ? ++k : --k) {
      reverse.pop();
    }
    for (i = l = 0, ref2 = reverse.length; 0 <= ref2 ? l < ref2 : l > ref2; i = 0 <= ref2 ? ++l : --l) {
      result.push(reverse.pop());
    }
    return result;
  };
  