private CodeFragment variableTypeConvert(Variable v, Type t, CodePosition p) {
        CodeFragment code = new CodeFragment();
        if (v.getType().equals(t)) {
            code.setType(t);
            code.setRegister(v.getRegister());
            return code;
        }

        String instruction = "";
        String register = this.generateNewRegister();

        if (t instanceof ListType) {
            ListType lt = (ListType) t;
            if (lt.getSubtype().equals(v.getType())) {
                code.addCode(
                    String.format(
                        "%s = call %s @createList%s(%s %s)\n",
                        register,
                        t.getCode(),
                        getFunctionSuffix(lt.getSubtype()),
                        BasicType.INT.getCode(),
                        "1"
                    )
                );

                code.addCode(
                    String.format(
                        "call %s @setListItem%s(%s %s, %s %s, %s %s)\n",
                        "void",
                        getFunctionSuffix(lt.getSubtype()),
                        t.getCode(),
                        register,
                        BasicType.INT.getCode(),
                        "0",
                        v.getType().getCode(),
                        v.getRegister()
                    )
                );
            } else if (v.getType() instanceof RangeType && ((RangeType)v.getType()).getSubtype().equals(lt.getSubtype())) {
                code.addCode(
                    String.format(
                        "%s = call %s @createListFromRange%s(%s %s)\n",
                        register,
                        t.getCode(),
                        getFunctionSuffix(lt.getSubtype()),
                        v.getType().getCode(),
                        v.getRegister()
                    )
                );
            }
        } else {
            if (v.getType().isInteger() && t.isInteger()) {
                if (Integer.parseInt(v.getType().getCode().substring(1)) <= Integer.parseInt(t.getCode().substring(1))) {
                    instruction = "zext";
                } else {
                    instruction = "trunc";
                }
            } else if (v.getType().isInteger()) {
                instruction = "sitofp";
            } else {
                throw new TypeMismatchException(p, v.getType(), t);
            }

            ST temp = new ST(
                    "<ret> = <instruction> <t1> <r> to <t2>\n"
            );

            temp.add("r", v.getRegister());
            temp.add("t1", v.getType().getCode());
            temp.add("t2", t.getCode());
            temp.add("instruction", instruction);
            temp.add("ret", register);
            code.addCode(temp.render());
        }

        code.setType(t);
        code.setRegister(register);
        return code;
    }