public string Disassemble(Module module, DisassemblyOptions options)
        {
            m_sb.AppendLine("; SPIR-V");
            m_sb.Append("; Version: ").Append(module.Header.Version).AppendLine();
            if (module.Header.GeneratorName == null)
            {
                m_sb.Append("; Generator: unknown; ").Append(module.Header.GeneratorVersion).AppendLine();
            }
            else
            {
                m_sb.Append("; Generator: ").Append(module.Header.GeneratorVendor).Append(' ').
                Append(module.Header.GeneratorName).Append("; ").Append(module.Header.GeneratorVersion).AppendLine();
            }
            m_sb.Append("; Bound: ").Append(module.Header.Bound).AppendLine();
            m_sb.Append("; Schema: ").Append(module.Header.Reserved).AppendLine();

            var lines = new string[module.Instructions.Count + 1];

            lines[0] = m_sb.ToString();
            m_sb.Clear();

            for (var i = 0; i < module.Instructions.Count; i++)
            {
                var instruction = module.Instructions[i];
                PrintInstruction(m_sb, instruction, options);
                lines[i + 1] = m_sb.ToString();
                m_sb.Clear();
            }

            var longestPrefix = 0;

            for (var i = 0; i < lines.Length; i++)
            {
                var line = lines[i];
                longestPrefix = Math.Max(longestPrefix, line.IndexOf('='));
                if (longestPrefix > 50)
                {
                    longestPrefix = 50;
                    break;
                }
            }

            m_sb.Append(lines[0]);
            for (var i = 1; i < lines.Length; i++)
            {
                var line  = lines[i];
                var index = line.IndexOf('=');
                if (index == -1)
                {
                    m_sb.Append(' ', longestPrefix + 4);
                    m_sb.Append(line);
                }
                else
                {
                    var pad = Math.Max(0, longestPrefix - index);
                    m_sb.Append(' ', pad);
                    m_sb.Append(line, 0, index);
                    m_sb.Append('=');
                    m_sb.Append(line, index + 1, line.Length - index - 1);
                }
                m_sb.AppendLine();
            }

            var result = m_sb.ToString();

            m_sb.Clear();
            return(result);
        }
 public string Disassemble(Module module)
 {
     return(Disassemble(module, DisassemblyOptions.Default));
 }