	public void addPrimitiveDerivedSetOrGet(Type.Kind derivedTypeKind,
	                                        String derived,
	                                        String index,
	                                        Kind primitiveType,
	                                        String primitive,
	                                        boolean set) throws BackendException {
		List<String> indices = new LinkedList<String>();
		while(references.containsKey(derived)) {
			Map.Entry<String,List<String>> reference = references.get(derived);
			indices.addAll(reference.getValue());
			derived = reference.getKey();
		}
		switch(derivedTypeKind) {
			case ARRAY:
				indices.add(index);
				break;
			case STRUCT:
				DerivedType type = derivedTypes.get(derived);
				if(type instanceof LLVMBackendArrayType) {
					type = (DerivedType) ((LLVMBackendArrayType) type).getStorageType();
				}
				if(type instanceof LLVMBackendStructType) {
					List<Member> members = ((LLVMBackendStructType) type).getMembers();
					for(Member m: members) {
						if(m.getName().equals(index)) {
							indices.add(String.valueOf(members.indexOf(m)));
							break;
						}
					}
				}
				else {
					throw new BackendException("Unexpected final derived type: " + type.getClass().getName());
				}
				break;
			default:
				throw new BackendException("Unexpected derived type: " + derivedTypeKind.toString());
		}
		StringBuffer indexList = new StringBuffer();
		for(String i: indices) {
			indexList.append(", ");
			indexList.append(Module.getIRType(Type.Kind.LONG));
			indexList.append(" ");
			indexList.append(cdl(i, Type.Kind.LONG));
		}
		String primitiveIRType = Module.getIRType(primitiveType);
		DerivedType derivedType = derivedTypes.get(derived);
		String derivedIRType = "";
		if(derivedType instanceof LLVMBackendArrayType) {
			LLVMBackendArrayType derivedArType = (LLVMBackendArrayType) derivedType;
			derivedIRType = Module.getIRAType(derivedArType.getStorageType(), derivedArType.getDimensions());
			for(int idx = 0;
			    idx < derivedArType.getDimensions().size();
				idx++)
			{
				String dim = ""+derivedArType.getDimensions().get(idx);
				String elem= cdl(indices.get(idx),Type.Kind.LONG);
				gen("call void @aoob1(i64 " + elem + ", i64 " + dim + ")");
			}
		}
		else if(derivedType instanceof LLVMBackendStructType) {
			LLVMBackendStructType derivedStType = (LLVMBackendStructType) derivedType;
			derivedIRType = Module.getIRSType(derivedStType.getMembers());
		}
		else {
			throw new BackendException("Unexpected derived type: " + derivedType.getClass().getName());
		}
		if(set) {
			String derivedUseIdentifier1 = getUseIdentifierForVariable(derived);
			String derivedUseIdentifier2 = getUseIdentifierForVariable(derived);
			String derivedIdentifier = "%" + derived;
			primitive = cdl(primitive, primitiveType);
			gen(derivedUseIdentifier1 + " = getelementptr " + derivedIRType + "* " + derivedIdentifier + ", i64 0"
				+ indexList);
			gen("store " + primitiveIRType + " " + primitive + ", " + primitiveIRType + "* " + derivedUseIdentifier1);
		}
		else {
			String primitiveUseIdentifier = getUseIdentifierForVariable(primitive);
			String primitiveIdentifier = "%" + primitive;
			String derivedUseIdentifier = getUseIdentifierForVariable(derived);
			String derivedIdentifier = "%" + derived;
			gen(derivedUseIdentifier + " = getelementptr " + derivedIRType + "* " + derivedIdentifier + ", i64 0"
				+ indexList);
			gen(primitiveUseIdentifier + " = load " + primitiveIRType + "* " + derivedUseIdentifier);
			gen("store " + primitiveIRType + " " + primitiveUseIdentifier + ", " + primitiveIRType + "* " + primitiveIdentifier);
		}
	}

	public void addPrimitiveDerivedSetOrGet(Type.Kind derivedTypeKind,
	                                        String derived,
	                                        String index,
	                                        Kind primitiveType,
	                                        String primitive,
	                                        boolean set) throws BackendException {
		List<String> indices = new LinkedList<String>();
		while(references.containsKey(derived)) {
			Map.Entry<String,List<String>> reference = references.get(derived);
			indices.addAll(reference.getValue());
			derived = reference.getKey();
		}
		switch(derivedTypeKind) {
			case ARRAY:
				indices.add(index);
				break;
			case STRUCT:
				DerivedType type = derivedTypes.get(derived);
				if(type instanceof LLVMBackendArrayType) {
					type = (DerivedType) ((LLVMBackendArrayType) type).getStorageType();
				}
				if(type instanceof LLVMBackendStructType) {
					List<Member> members = ((LLVMBackendStructType) type).getMembers();
					for(Member m: members) {
						if(m.getName().equals(index)) {
							indices.add("#" + String.valueOf(members.indexOf(m)));
							break;
						}
					}
				}
				else {
					throw new BackendException("Unexpected final derived type: " + type.getClass().getName());
				}
				break;
			default:
				throw new BackendException("Unexpected derived type: " + derivedTypeKind.toString());
		}
		StringBuffer indexList = new StringBuffer();
		for(String i: indices) {
			indexList.append(", ");
			indexList.append(Module.getIRType(Type.Kind.LONG));
			indexList.append(" ");
			indexList.append(cdl(i, Type.Kind.LONG));
		}
		String primitiveIRType = Module.getIRType(primitiveType);
		DerivedType derivedType = derivedTypes.get(derived);
		String derivedIRType = "";
		if(derivedType instanceof LLVMBackendArrayType) {
			LLVMBackendArrayType derivedArType = (LLVMBackendArrayType) derivedType;
			derivedIRType = Module.getIRAType(derivedArType.getStorageType(), derivedArType.getDimensions());
			for(int idx = 0;
			    idx < derivedArType.getDimensions().size();
				idx++)
			{
				String dim = ""+derivedArType.getDimensions().get(idx);
				String elem= cdl(indices.get(idx),Type.Kind.LONG);
				gen("call void @aoob1(i64 " + elem + ", i64 " + dim + ")");
			}
		}
		else if(derivedType instanceof LLVMBackendStructType) {
			LLVMBackendStructType derivedStType = (LLVMBackendStructType) derivedType;
			derivedIRType = Module.getIRSType(derivedStType.getMembers());
		}
		else {
			throw new BackendException("Unexpected derived type: " + derivedType.getClass().getName());
		}
		if(set) {
			String derivedUseIdentifier1 = getUseIdentifierForVariable(derived);
			String derivedUseIdentifier2 = getUseIdentifierForVariable(derived);
			String derivedIdentifier = "%" + derived;
			primitive = cdl(primitive, primitiveType);
			gen(derivedUseIdentifier1 + " = getelementptr " + derivedIRType + "* " + derivedIdentifier + ", i64 0"
				+ indexList);
			gen("store " + primitiveIRType + " " + primitive + ", " + primitiveIRType + "* " + derivedUseIdentifier1);
		}
		else {
			String primitiveUseIdentifier = getUseIdentifierForVariable(primitive);
			String primitiveIdentifier = "%" + primitive;
			String derivedUseIdentifier = getUseIdentifierForVariable(derived);
			String derivedIdentifier = "%" + derived;
			gen(derivedUseIdentifier + " = getelementptr " + derivedIRType + "* " + derivedIdentifier + ", i64 0"
				+ indexList);
			gen(primitiveUseIdentifier + " = load " + primitiveIRType + "* " + derivedUseIdentifier);
			gen("store " + primitiveIRType + " " + primitiveUseIdentifier + ", " + primitiveIRType + "* " + primitiveIdentifier);
		}
	}
