V. Kamakoti

110 papers A 15B 7Misc 24Journal 43Unranked 21
YearRankTypeTitle / Venue / Authors
2023 J jnl
IEEE Trans. Dependable Secur. Comput.
Gargi Mitra, Prasanna Karthik Vairam, Sandip Saha, Nitin Chandrachoodan, V. Kamakoti
2023 A conf
DSN
Sandip Saha, Sareena Karapoola, Chester Rebeiro, V. Kamakoti
2023 conf
PReMI
Kaushik Raghavan, B. Sivaselavan, V. Kamakoti
2022 J jnl
IEEE Trans. Computers
Prasanna Karthik Vairam, Pratyush Kumar, Chester Rebeiro, V. Kamakoti
2022 A conf
CIKM
Sareena Karapoola, Nikhilesh Singh, Chester Rebeiro, V. Kamakoti
2022 J jnl
CoRR
Gargi Mitra, Prasanna Karthik Vairam, Sandip Saha, Nitin Chandrachoodan, V. Kamakoti
2021 J jnl
ACM Trans. Archit. Code Optim.
Sugandha Tiwari, Neel Gala, Chester Rebeiro, V. Kamakoti
2019 A conf
ICCAD
Patanjali SLPSK, Prasanna Karthik Vairam, Chester Rebeiro, V. Kamakoti
2019 J jnl
CoRR
Sugandha Tiwari, Neel Gala, Chester Rebeiro, V. Kamakoti
2019 J jnl
IEEE Trans. Cogn. Commun. Netw.
Milan Patnaik, V. Kamakoti, Vashek Matyas, Vojtech Rehák
2018 J jnl
ACM J. Emerg. Technol. Comput. Syst.
Neel Gala, Sarada Krithivasan, Wei-Yu Tsai, Xueqing Li, Vijaykrishnan Narayanan, V. Kamakoti
2018 J jnl
J. Low Power Electron.
Patanjali SLPSK, Milan Patnaik, Seetal Potluri, V. Kamakoti
2017 conf
DFT
Gokulkrishnan Vadakkeveedu, V. Kamakoti, Nitin Chandrachoodan, Seetal Potluri
2017 J jnl
IEEE Trans. Very Large Scale Integr. Syst.
Neel Gala, Swagath Venkataramani, Anand Raghunathan, V. Kamakoti
2016 Misc conf
VLSID
Vikas Chauhan, Neel Gala, V. Kamakoti
2016 Misc ed.
ICISS
Indrajit Ray, Manoj Singh Gaur, Mauro Conti, Dheeraj Sanghi, V. Kamakoti
2016 J jnl
Comput. Commun.
N. Sathya Narayanan, Milan Patnaik, V. Kamakoti
2016 Misc conf
VLSID
Neel Gala, Arjun Menon, Rahul Bodduna, G. S. Madhusudan, V. Kamakoti
2016 A conf
ISLPED
Neel Gala, Swagath Venkataramani, Anand Raghunathan, V. Kamakoti
2015 J jnl
J. Low Power Electron.
Neel Gala, V. R. Devanathan, V. Visvanathan, V. Kamakoti
2015 J jnl
ACM Trans. Design Autom. Electr. Syst.
Seetal Potluri, Satya Trinadh, Ch. Sobhan Babu, V. Kamakoti, Nitin Chandrachoodan
2015 A conf
DATE
Satya Trinadh, Ch. Sobhan Babu, Shiv Govind Singh, Seetal Potluri, V. Kamakoti
2015 Misc conf
VLSID
Pavan Vithal Torvi, V. R. Devanathan, V. Kamakoti
2015 J jnl
Appl. Soft Comput.
L. Srivani, N. H. V. Krishna Giri, Shankar Ganesh, V. Kamakoti
2015 J jnl
ACM J. Emerg. Technol. Comput. Syst.
Milan Patnaik, Chidhambaranathan Rajamanikkam, Chirag Garg, Arnab Roy, V. R. Devanathan, Shankar Balachandran, V. Kamakoti
2015 conf
ATS
Sukrat Gupta, Neel Gala, G. S. Madhusudan, V. Kamakoti
2014 Misc conf
VLSID
Neel Gala, V. R. Devanathan, Karthik Srinivasan, V. Visvanathan, V. Kamakoti
2014 J jnl
J. Low Power Electron.
K. Shyamala, V. Kamakoti
2014 J jnl
J. Low Power Electron.
Satya Trinadh, Seetal Potluri, Shankar Balachandran, Ch. Sobhan Babu, V. Kamakoti
2013 J jnl
ACM J. Emerg. Technol. Comput. Syst.
Shri K. V. Srinivasan, V. Kamakoti, A. Bhattacharya
2013 J jnl
J. Low Power Electron.
Satya Trinadh, Seetal Potluri, Ch. Sobhan Babu, V. Kamakoti
2013 B conf
ETS
Seetal Potluri, Satya Trinadh, Roopashree Baskaran, Nitin Chandrachoodan, V. Kamakoti
2013 J jnl
J. Low Power Electron.
Virat Gandhi, V. R. Devanathan, V. Visvanathan, Milan Patnaik, V. Kamakoti
2012 J jnl
J. Electr. Comput. Eng.
Anish S. Kumar, M. Pawan Kumar, Srinivasan Murali, V. Kamakoti, Luca Benini, Giovanni De Micheli
2012 J jnl
J. Low Power Electron.
Seetal Potluri, Nitin Chandrachoodan, V. Kamakoti
2012 J jnl
J. Low Power Electron.
Rama Kumar Pasumarthi, V. R. Devanathan, V. Visvanathan, Seetal Potluri, V. Kamakoti
2011 conf
ISVLSI
Anish S. Kumar, M. Pawan Kumar, Srinivasan Murali, V. Kamakoti, Luca Benini, Giovanni De Micheli
2011 J jnl
Appl. Soft Comput.
Shoaib Mohammed, Sk. Noor Mahammad, V. Kamakoti
2011 conf
ISVLSI
Seetal Potluri, Nitin Chandrachoodan, V. Kamakoti
2011 J jnl
ACM SIGOPS Oper. Syst. Rev.
Karthik Raghavan, V. Kamakoti
2011 conf
ISED
S. Srinivasan, V. Kamakoti, A. Bhattacharya
2010 J jnl
IEEE Trans. Broadcast.
Kavish Seth, V. Kamakoti, S. Srinivasan
2010 Misc conf
VLSI Design
Lavanya Jagan, Camelia Hora, Bram Kruseman, Stefan Eichenberger, Ananta K. Majhi, V. Kamakoti
2009 Misc conf
VLSI Design
Lavanya Jagan, Ratan Deep Singh, V. Kamakoti, Ananta K. Majhi
2009 J jnl
ACM SIGOPS Oper. Syst. Rev.
Kunal Korgaonkar, K. George, M. Gautam, V. Kamakoti
2009 J jnl
J. Low Power Electron.
K. Shyamala, J. Vimalkumar, V. Kamakoti
2009 J jnl
J. Low Power Electron.
George Kurian, Narayana Rao, Virendra Patidar, V. Kamakoti, Srivaths Ravi
2008 J jnl
J. Low Power Electron.
V. R. Devanathan, C. P. Ravikumar, Rajat Mehrotra, V. Kamakoti
2008 J jnl
IEEE Trans. Very Large Scale Integr. Syst.
Siva Kumar Sastry Hari, Vishnu Vardhan Reddy Konda, V. Kamakoti, Vivekananda M. Vedula, K. S. Maneperambil
2007 J jnl
Appl. Soft Comput.
Siva Nageswara Rao Borra, Annamalai Muthukaruppan, Sivaprakasam Suresh, V. Kamakoti
2007 A conf
ITC
V. R. Devanathan, C. P. Ravikumar, V. Kamakoti
2007 J jnl
J. Low Power Electron.
K. Najeeb, Karthik Gururaj, V. Kamakoti, Vivekananda M. Vedula
2007 Misc conf
VLSI Design
K. Najeeb, Karthik Gururaj, V. Kamakoti, Vivekananda M. Vedula
2007 J jnl
CoRR
Ramachandran Pradeep, S. Vinay, Sanjay Burman, V. Kamakoti
2007 Misc conf
VTS
V. R. Devanathan, C. P. Ravikumar, V. Kamakoti
2007 A conf
DATE
V. R. Devanathan, C. P. Ravikumar, V. Kamakoti
2007 A conf
ITC
V. R. Devanathan, C. P. Ravikumar, Rajat Mehrotra, V. Kamakoti
2007 Misc conf
VTS
K. Najeeb, Vishnu Vardhan Reddy Konda, Siva Kumar Sastry Hari, V. Kamakoti, Vivekananda M. Vedula
2007 Misc conf
VLSI Design
V. R. Devanathan, C. P. Ravikumar, V. Kamakoti
2007 J jnl
Pattern Recognit. Lett.
A. Pavan Kumar, V. Kamakoti, Sukhendu Das
2007 J jnl
IEEE Des. Test Comput.
V. R. Devanathan, C. P. Ravikumar, V. Kamakoti
2006 Misc conf
VLSI Design
Vivek Garg, Vikram Chandrasekhar, Milagros Sashikánth, V. Kamakoti
2006 conf
ACM Great Lakes Symposium on VLSI
K. Najeeb, Vishal Gupta, V. Kamakoti, Madhu Mutyam
2006 J jnl
J. Low Power Electron.
V. R. Devanathan, C. P. Ravikumar, V. Kamakoti
2006 J jnl
J. Low Power Electron.
K. Najeeb, Vishal Gupta, V. Kamakoti, Madhu Mutyam
2006 Misc conf
VLSI Design
Kavish Seth, K. N. Viswajith, S. Srinivasan, V. Kamakoti
2005 conf
Asian Test Symposium
K. Uday Bhaskar, M. Prasanth, V. Kamakoti, Kailasnath Maneparambil
2005 Misc conf
VLSI Design
Chakka Siva Sai Prasanna, N. Sudha, V. Kamakoti
2005 Misc conf
VLSI Design
K. Uday Bhaskar, M. Prasanth, G. Chandramouli, V. Kamakoti
2005 conf
ASP-DAC
Vivek Garg, Vikram Chandrasekhar, Milagros Sashikánth, V. Kamakoti
2005 conf
ASP-DAC
Vivek Garg, Vikram Chandrasekhar, Milagros Sashikánth, V. Kamakoti
2005 conf
ASP-DAC
E. Syam Sundar Reddy, Vikram Chandrasekhar, Milagros Sashikánth, V. Kamakoti, Narayanan Vijaykrishnan
2005 Misc conf
VLSI Design
E. Syam Sundar Reddy, Vikram Chandrasekhar, Milagros Sashikánth, V. Kamakoti, Narayanan Vijaykrishnan
2005 A conf
FPGA
E. Syam Sundar Reddy, Vikram Chandrasekhar, Milagros Sashikánth, V. Kamakoti, Narayanan Vijaykrishnan
2005 A conf
DATE
Ramachandran Pradeep, S. Vinay, Sanjay Burman, V. Kamakoti
2005 A conf
IPDPS
E. Syam Sundar Reddy, Vikram Chandrasekhar, Milagros Sashikánth, V. Kamakoti, Narayanan Vijaykrishnan
2005 Misc conf
VLSI Design
R. Manimegalai, E. Siva Soumya, Vaishnavi Muralidharan, Balaraman Ravindran, V. Kamakoti, Dinesh Bhatia
2005 J jnl
Microprocess. Microsystems
L. Kalyan Kumar, Aditya S. Ramani, Amol J. Mupid, V. Kamakoti
2004 Misc conf
VLSI Design
P. Subrahmanya, R. Manimegalai, V. Kamakoti, Madhu Mutyam
2004 B conf
ICONIP
Chakka Siva Sai Prasanna, N. Sudha, V. Kamakoti
2004 Misc conf
VLSI Design
Kavish Seth, P. Rangarajan, S. Srinivasan, V. Kamakoti, V. Bala Kuteshwar
2004 conf
FPT
E. Syam Sundar Reddy, Vikram Chandrasekhar, Milagros Sashikánth, V. Kamakoti, Vijaykrishnan Narayanan
2004 conf
ICVGIP
A. Pavan Kumar, V. Kamakoti, Sukhendu Das
2004 conf
MICAI
Permandla Pratibha, Siva Nageswara Rao Borra, Annamalai Muthukaruppan, Sivaprakasam Suresh, V. Kamakoti
2004 B conf
ICONIP
A. Pavan Kumar, Sukhendu Das, V. Kamakoti
2004 A conf
IPDPS
A. Manoj Kumar, B. Jayaram, R. Manimegalai, V. Kamakoti
2004 B conf
FPL
R. Manimegalai, A. Manoj Kumar, B. Jayaram, V. Kamakoti
2004 A conf
DATE
A. Manoj Kumar, Jayaram Bobba, V. Kamakoti
2004 A conf
FPGA
A. Manoj Kumar, B. Jayaram, V. Kamakoti
2004 conf
FPT
R. Manimegalai, B. Jayaram, A. Manoj Kumar, V. Kamakoti
2003 conf
Asian Test Symposium
L. Kalyan Kumar, Amol J. Mupid, Aditya S. Ramani, V. Kamakoti
2003 conf
IICAI
Permandla Pratibha, Siva Nageswara Rao Borra, Annamalai Muthukaruppan, Sivaprakasam Suresh, V. Ganesh, V. Kamakoti
2003 A conf
IPDPS
Siva Nageswara Rao Borra, Annamalai Muthukaruppan, Sivaprakasam Suresh, V. Kamakoti
2003 B conf
IEEE Congress on Evolutionary Computation
Permandla Pratibha, Siva Nageswara Rao Borra, Annamalai Muthukaruppan, Sivaprakasam Suresh, V. Kamakoti
2003 conf
ISVLSI
M. Madhu, V. Srinivasa Murty, V. Kamakoti
2003 conf
VLSI
L. Kalyan Kumar, Aditya S. Ramani, Amol J. Mupid, V. Kamakoti, Sivaprakasam Suresh
2003 Misc conf
HiPC
B. Jayaram, A. Manoj Kumar, V. Kamakoti
2003 B conf
FPL
L. Kalyan Kumar, Amol J. Mupid, Aditya S. Ramani, V. Kamakoti
2002 conf
FPT
Annamalai Muthukaruppan, Sivaprakasam Suresh, V. Kamakoti
2001 Misc conf
INDOCRYPT
K. Srinathan, C. Pandu Rangan, V. Kamakoti
1999 J jnl
Parallel Comput.
V. Annamalai, C. S. Krishnamoorthy, V. Kamakoti
1998 Misc conf
COCOON
Thomas Graf, V. Kamakoti, N. S. Janaki Latha, C. Pandu Rangan
1997 Misc conf
HiPC
Thomas Graf, V. Kamakoti, N. S. Janaki Latha, C. Pandu Rangan
1997 B conf
ICPADS
V. Kamakoti, N. Balakrishnan
1997 J jnl
Inf. Process. Lett.
Thomas Graf, V. Kamakoti
1995 J jnl
Nord. J. Comput.
V. Kamakoti, Kamala Krithivasan, C. Pandu Rangan
1995 J jnl
J. Parallel Distributed Comput.
K. Arvind, V. Kamakoti, C. Pandu Rangan
1995 Misc conf
COCOON
V. Kamakoti, Kamala Krithivasan, C. Pandu Rangan
1994 conf
IFIP Congress (1)
P. Jagan Mohan, V. Kamakoti, C. Pandu Rangan
1992 J jnl
Inf. Process. Lett.
V. Kamakoti, C. Pandu Rangan
redb/extractors/decompiler/_archive/GhidraDecompilerScript-v2.java
← Index redb/extractors/decompiler/_archive/GhidraDecompilerScript-v2.java java
import ghidra.app.script.GhidraScript;
import ghidra.program.model.listing.*;
import ghidra.app.decompiler.*;
import ghidra.program.model.block.*;
import ghidra.program.model.symbol.*;
import ghidra.program.model.pcode.*;
import ghidra.program.model.address.*;
import org.json.JSONObject;
import org.json.JSONArray;
import java.security.MessageDigest;
import java.nio.charset.StandardCharsets;

public class GhidraDecompilerScript extends GhidraScript {
    private DecompInterface decompInterface;
    private BasicBlockModel basicBlockModel;

    @Override
    public void run() throws Exception {
        System.err.println("{\"debug\": \"Script starting\"}");

        // Get binary hash and filepath from arguments
        String[] args = getScriptArgs();
        if (args.length < 2) {
            System.err.println("{\"error\": \"Both SHA256 and filepath arguments are required\"}");
            return;
        }
        String sha256 = args[0];
        String filepath = args[1];

        // Add debug output after setup
        System.err.println("{\"debug\": \"Processing file: " + args[1] + "\"}");

        // Initialize analysis components
        setupDecompiler();
        basicBlockModel = new BasicBlockModel(currentProgram);

        // Create the main JSON object for output
        JSONObject output = new JSONObject();
        output.put("sha256", sha256);
        output.put("decompiled", new JSONArray());
        output.put("disassembled", new JSONArray());
        output.put("cfg", new JSONArray());

        // Process all functions
        FunctionIterator functions = currentProgram.getFunctionManager().getFunctions(true);
        for (Function function : functions) {
            processFunction(function, output);
        }

        System.err.println("{\"debug\": \"Preparing final output\"}");
        // Output the final JSON to stdout
        System.out.println(output.toString());
    }

    private void setupDecompiler() {
        decompInterface = new DecompInterface();
        DecompileOptions options = new DecompileOptions();
        decompInterface.setOptions(options);
        decompInterface.openProgram(currentProgram);
    }

    private void processFunction(Function function, JSONObject output) {
        try {
            Address entry = function.getEntryPoint();
            String functionName = function.getName();
            String functionAddress = entry.toString();

            // Process each analysis type independently
            boolean hasAnyResults = false;

            try {
                if (processDecompiledCode(function, output.getJSONArray("decompiled"),
                                        functionName, functionAddress)) {
                    hasAnyResults = true;
                }
            } catch (Exception e) {
                System.err.println(String.format(
                    "{\"error\": \"Decompilation failed for function %s: %s\"}",
                    functionName, e.getMessage().replace("\"", "'")));
            }

            try {
                if (processDisassembledCode(function, output.getJSONArray("disassembled"),
                                        functionName, functionAddress)) {
                    hasAnyResults = true;
                }
            } catch (Exception e) {
                System.err.println(String.format(
                    "{\"error\": \"Disassembly failed for function %s: %s\"}",
                    functionName, e.getMessage().replace("\"", "'")));
            }

            try {
                if (processCFG(function, output.getJSONArray("cfg"), functionAddress)) {
                    hasAnyResults = true;
                }
            } catch (Exception e) {
                System.err.println(String.format(
                    "{\"error\": \"CFG extraction failed for function %s: %s\"}",
                    functionName, e.getMessage().replace("\"", "'")));
            }

            if (!hasAnyResults) {
                System.err.println(String.format(
                    "{\"warning\": \"No results obtained for function %s\"}",
                    functionName));
            }

        } catch (Exception e) {
            System.err.println(String.format(
                "{\"error\": \"Failed to process function: %s\"}",
                e.getMessage().replace("\"", "'")));
        }
    }

    private boolean processDecompiledCode(Function function, JSONArray decompArray,
                                        String functionName, String functionAddress) {
        try {
            DecompileResults results = decompInterface.decompileFunction(function, 30, monitor);
            if (results == null || !results.decompileCompleted()) {
                System.err.println(String.format(
                    "{\"warning\": \"Decompilation incomplete for function %s\"}",
                    functionName));
                return false;
            }

            String decompiledCode = results.getDecompiledFunction().getC();
            if (decompiledCode == null || decompiledCode.trim().isEmpty()) {
                System.err.println(String.format(
                    "{\"warning\": \"Empty decompilation result for function %s\"}",
                    functionName));
                return false;
            }

            String contentHash = calculateHash(decompiledCode);

            JSONObject functionObj = new JSONObject();
            functionObj.put("decompiled_content_hash", contentHash);
            functionObj.put("decompiled_function_name", functionName);
            functionObj.put("decompiled_function_address", functionAddress);
            functionObj.put("decompiled_function", decompiledCode);

            decompArray.put(functionObj);
            return true;

        } catch (Exception e) {
            throw new RuntimeException("Decompilation error: " + e.getMessage(), e);
        }
    }

    private boolean processDisassembledCode(Function function, JSONArray disasmArray,
                                        String functionName, String functionAddress) {
        try {
            StringBuilder disassembly = new StringBuilder();
            StringBuilder normalized = new StringBuilder();
            int instructionCount = 0;
            boolean hasValidInstructions = false;

            Listing listing = currentProgram.getListing();
            AddressSetView functionBody = function.getBody();
            InstructionIterator instructions = listing.getInstructions(functionBody, true);

            while (instructions.hasNext()) {
                try {
                    Instruction instr = instructions.next();
                    if (instr != null) {
                        String disasmLine = instr.toString();
                        if (disasmLine != null && !disasmLine.trim().isEmpty()) {
                            disassembly.append(disasmLine).append("\n");
                            normalized.append(normalizeInstruction(disasmLine)).append("\n");
                            instructionCount++;
                            hasValidInstructions = true;
                        }
                    }
                } catch (Exception e) {
                    System.err.println(String.format(
                        "{\"warning\": \"Skipped invalid instruction in %s: %s\"}",
                        functionName, e.getMessage().replace("\"", "'")));
                }
            }

            if (!hasValidInstructions) {
                System.err.println(String.format(
                    "{\"warning\": \"No valid instructions found in function %s\"}",
                    functionName));
                return false;
            }

            String disassembledCode = disassembly.toString();
            String contentHash = calculateHash(disassembledCode);

            JSONObject functionObj = new JSONObject();
            functionObj.put("disassembled_content_hash", contentHash);
            functionObj.put("disassembled_function_name", functionName);
            functionObj.put("disassembled_function_address", functionAddress);
            functionObj.put("disassembled_function", disassembledCode);
            functionObj.put("normalized_disassembly", normalized.toString());
            functionObj.put("instruction_count", instructionCount);

            // Initialize similarity fields as null
            functionObj.put("minhash_signature", JSONObject.NULL);
            functionObj.put("opcode_frequency_vector", JSONObject.NULL);
            functionObj.put("api_calls_vector", JSONObject.NULL);
            functionObj.put("instruction_embedding", JSONObject.NULL);

            disasmArray.put(functionObj);
            return true;

        } catch (Exception e) {
            throw new RuntimeException("Disassembly error: " + e.getMessage(), e);
        }
    }

    private boolean processCFG(Function function, JSONArray cfgArray, String functionAddress) {
        try {
            CodeBlockIterator blocks = basicBlockModel.getCodeBlocksContaining(
                function.getBody(), monitor);

            boolean hasValidBlocks = false;

            while (blocks.hasNext()) {
                try {
                    CodeBlock block = blocks.next();
                    String blockInstructions = getBlockInstructions(block);

                    if (blockInstructions == null || blockInstructions.trim().isEmpty()) {
                        continue;
                    }

                    String blockId = calculateHash(blockInstructions);

                    JSONObject blockObj = new JSONObject();
                    blockObj.put("block_id", blockId);
                    blockObj.put("function_address", functionAddress);
                    blockObj.put("block_instructions", blockInstructions);

                    // Process successors with error handling
                    JSONArray successorAddresses = new JSONArray();
                    try {
                        CodeBlockReferenceIterator successors = block.getDestinations(monitor);
                        while (successors.hasNext()) {
                            try {
                                CodeBlockReference ref = successors.next();
                                if (ref != null && ref.getDestinationAddress() != null) {
                                    successorAddresses.put(ref.getDestinationAddress().toString());
                                }
                            } catch (Exception e) {
                                System.err.println(String.format(
                                    "{\"warning\": \"Skipped invalid successor in block %s: %s\"}",
                                    blockId, e.getMessage().replace("\"", "'")));
                            }
                        }
                    } catch (Exception e) {
                        System.err.println(String.format(
                            "{\"warning\": \"Error processing successors for block %s: %s\"}",
                            blockId, e.getMessage().replace("\"", "'")));
                    }

                    blockObj.put("successor_blocks", successorAddresses);
                    cfgArray.put(blockObj);
                    hasValidBlocks = true;

                } catch (Exception e) {
                    System.err.println(String.format(
                        "{\"warning\": \"Skipped invalid block in function %s: %s\"}",
                        functionAddress, e.getMessage().replace("\"", "'")));
                }
            }

            return hasValidBlocks;

        } catch (Exception e) {
            throw new RuntimeException("CFG extraction error: " + e.getMessage(), e);
        }
    }

    private String getBlockInstructions(CodeBlock block) {
        StringBuilder instructions = new StringBuilder();
        try {
            AddressIterator addresses = block.getAddresses(true);
            while (addresses.hasNext()) {
                try {
                    Address addr = addresses.next();
                    if (addr != null) {
                        Instruction instr = currentProgram.getListing().getInstructionAt(addr);
                        if (instr != null) {
                            instructions.append(instr.toString()).append("\n");
                        }
                    }
                } catch (Exception e) {
                    System.err.println(String.format(
                        "{\"warning\": \"Skipped invalid instruction at address %s: %s\"}",
                        addresses.next(), e.getMessage().replace("\"", "'")));
                }
            }
        } catch (Exception e) {
            System.err.println(String.format(
                "{\"warning\": \"Error getting block instructions: %s\"}",
                e.getMessage().replace("\"", "'")));
        }
        return instructions.toString();
    }

    private String normalizeInstruction(String instruction) {
        try {
            if (instruction == null || instruction.trim().isEmpty()) {
                return "";
            }
            return instruction.replaceAll("0x[0-9a-fA-F]+", "IMM")
                            .replaceAll("\\b\\d+\\b", "NUM")
                            .replaceAll("[\\[\\]\\+\\-\\*/%&|^]+", "_OP_");
        } catch (Exception e) {
            System.err.println(String.format(
                "{\"warning\": \"Error normalizing instruction: %s\"}",
                e.getMessage().replace("\"", "'")));
            return instruction;
        }
    }

    private String calculateHash(String content) {
        try {
            if (content == null || content.trim().isEmpty()) {
                return "";
            }
            MessageDigest digest = MessageDigest.getInstance("SHA-256");
            byte[] hash = digest.digest(content.getBytes(StandardCharsets.UTF_8));
            StringBuilder hexString = new StringBuilder();
            for (byte b : hash) {
                hexString.append(String.format("%02x", b));
            }
            return hexString.toString();
        } catch (Exception e) {
            System.err.println(String.format(
                "{\"error\": \"Error calculating hash: %s\"}",
                e.getMessage().replace("\"", "'")));
            return "";
        }
    }
}