• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
          • Syntax-for-tools
          • Atc
          • Language
          • Representation
          • Transformation-tools
            • Simpadd0
            • Deftrans
            • Splitgso
            • Constant-propagation
            • Split-fn
            • Copy-fn
              • Copy-fn-extdecl
              • Copy-fn-filepath-transunit-map
              • Rename-fn-filepath-transunit-map
              • Copy-fn-fundef
              • Rename-fn-transunit-ensemble
              • Copy-fn-transunit-ensemble
              • Copy-fn-extdecl-list
              • Rename-fn-ident-list
              • Rename-fn-fundef
              • Rename-fn-extdecl-list
              • Rename-fn-extdecl
              • Copy-fn-transunit
              • Rename-fn-transunit
              • Rename-fn-ident
              • Rename-fn-const
              • Rename-fn-funcall-fun
            • Specialize
            • Split-all-gso
            • Rename
            • Utilities
          • Insertion-sort
          • Pack
        • Bv
        • Imp-language
        • Event-macros
        • Java
        • Bitcoin
        • Ethereum
        • Yul
        • Zcash
        • ACL2-programming-language
        • Prime-fields
        • Json
        • Syntheto
        • File-io-light
        • Cryptography
        • Number-theory
        • Lists-light
        • Axe
        • Builtins
        • Solidity
        • Helpers
        • Htclient
        • Typed-lists-light
        • Arithmetic-light
      • X86isa
      • Axe
      • Execloader
    • Math
    • Testing-utilities
  • Transformation-tools

Copy-fn

A C-to-C transformation to copy a function.

This transformation introduces a new function which is the duplicate of another.

For instance, consider the following C code:

int fibonacci(int x) {
  if (x <= 1) {
    return x;
  }
  return fibonacci(x - 1) + fibonacci(x - 2);
}

Copying fibonacci and creating a new function fib yields the following:

int fibonacci(int x) {
  if (x <= 1) {
    return x;
  }
  return fibonacci(x - 1) + fibonacci(x - 2);
}
int fib(int x) {
  if (x <= 1) {
    return x;
  }
  return fib(x - 1) + fib(x - 2);
}

This transformation is not likely to be useful in isolation. Most often it is an initial step before applying different transformations to the two duplicates.

Subtopics

Copy-fn-extdecl
Transform an external declaration.
Copy-fn-filepath-transunit-map
Transform a filepath.
Rename-fn-filepath-transunit-map
Copy-fn-fundef
Transform a function definition.
Rename-fn-transunit-ensemble
Transform a translation unit ensemble.
Copy-fn-transunit-ensemble
Transform a translation unit ensemble.
Copy-fn-extdecl-list
Transform a list of external declarations.
Rename-fn-ident-list
Rename-fn-fundef
Rename-fn-extdecl-list
Rename-fn-extdecl
Copy-fn-transunit
Transform a translation unit.
Rename-fn-transunit
Rename-fn-ident
Rename-fn-const
Rename-fn-funcall-fun
Rename a function within a funcall function expression.