private static void outputActualSPACLCircuit(List<List<Gate>> gates, 
			String circuitName, int[] circuitInfo) {
		int sizeOfKey = circuitInfo[0];
		int sizeOfPlaintext = circuitInfo[1];
		int sizeOfCiphertext = circuitInfo[2];
		int heapSize = circuitInfo[3];
		int maxXOR = circuitInfo[4];
		int maxINV = circuitInfo[5];
		int maxAND = circuitInfo[6];
		String circuitMetaName = circuitName + ".spaclc";


		BufferedWriter bw;
		try {
			bw = new BufferedWriter(new OutputStreamWriter(
					new FileOutputStream(new File(circuitMetaName)), Charset.defaultCharset()));

			// Size of heap
			bw.write("  " + HEAP_SIZE + "(" + heapSize + ");");
			bw.newLine();
			bw.newLine();

			// Max_width specifications
			bw.write(max_width(XOR, maxXOR));
			bw.newLine();
			bw.write(max_width(INV, maxINV));
			bw.newLine();
			bw.write(max_width(AND, maxAND));
			bw.newLine();
			bw.write(max_width(PRIVATE_LOAD, sizeOfKey));
			bw.newLine();
			bw.write(max_width(PUBLIC_LOAD, sizeOfPlaintext));
			bw.newLine();
			bw.write(max_width(PUBLIC_STORE, sizeOfCiphertext));
			bw.newLine();
			bw.newLine();

			// Init key
			bw.write(begin_layer(PRIVATE_LOAD, sizeOfKey));
			bw.newLine();
			for (int i = 0; i < sizeOfKey; i++) { //Check which is key AND which is plaintext
				bw.write("    " + PRIVATE_LOAD + "(" + INPUT_1 +"[" + i + "]," + i + "," + i + ");");
				bw.newLine();
			}
			bw.write(end_layer(PRIVATE_LOAD, sizeOfKey));
			bw.newLine();
			bw.newLine();

			// Init plaintext
			bw.write(begin_layer(PUBLIC_LOAD, sizeOfPlaintext));
			bw.newLine();
			for (int i = 0; i < sizeOfPlaintext; i++) { //TODO Check which is key AND which is plaintext
				bw.write("    " + PUBLIC_LOAD + "(" + INPUT_2 +"[" + i + "]," + (sizeOfKey + i) + "," + i + ");");
				bw.newLine();
			}
			bw.write(end_layer(PUBLIC_LOAD, sizeOfPlaintext));
			bw.newLine();
			bw.newLine();

			// The layers
			int index = 0;
			for (List<Gate> list: gates) {
				Gate tester = list.get(0);
				int j = 0;
				String layerString = "";
				if (tester.isXOR()) {
					layerString = XOR;

				} else if (tester.isAND()) {
					layerString = AND;
				} else {
					layerString = INV;
				}
				bw.write(begin_layer(layerString, list.size()));
				bw.newLine();
				for (Gate g: list) {
					if (g.isAND()) {
						bw.write(getGateString(g, layerString, j++, index++));
					} else {
						bw.write(getGateString(g, layerString, j++));
					}
					bw.newLine();
				}
				bw.write(end_layer(layerString, list.size()));
				bw.newLine();
				bw.newLine();
			}

			// Write output
			bw.write(begin_layer(PUBLIC_STORE, sizeOfCiphertext));
			bw.newLine();
			for (int i = 0; i < sizeOfCiphertext; i++) {
				bw.write("    " + PUBLIC_STORE + "(" + OUTPUT +"[" + i  + "]," + (heapSize - sizeOfCiphertext + i) + "," + i + ");");
				bw.newLine();
			}
			bw.write(end_layer(PUBLIC_STORE, sizeOfCiphertext));
			//			bw.newLine();
			//
			//			bw.write("}");

			bw.close();
		} catch (IOException e) {

		}	
	}