1. A method of compressing instructions in a program, comprising: using a processor, coupled to a memory, to compile the program to produce binary data; extracting unique patterns of bits from the binary data; constructing a linear programming formulation or an integer programming problem based on the unique patterns of bits and a storage capacity for the unique patterns of bits that when solved will produce an optimum compression of the program for the storage capacity; solving the linear programming formulation or the integer programming problem to produce a solution, and compressing at least some of the instructions in the program based on the solution.