Understand unfamiliar programming constructs-->

AI that reads and explains complex code naturally, like a human

Denigma explains code in conversational English.
Powered by machine learning.

Sample explanations

void I2C_Reset(void)
{
    // Release SCL and SDA lines and re-enable module
    //
    TWCR = 0;
    SetBit(TWCR, TWEA);
    SetBit(TWCR, TWEN);
}
Show explanation
  • The function is called "I2C_Reset" which means it resets the I2C bus.
  • The first line of code sets the value of a register to zero.
  • This register is named "TWCR".
  • It's important to note that this register has two bits: one for setting the clock rate (TWEA), and one for enabling/disabling the module (TWEEN).
  • After these two lines are executed, both bits will be set to zero.

  • The code sets the TWCR register to 0, which disables the module.
  • The code then releases the SCL and SDA lines of the I2C bus, re-enabling it.
FROM node

WORKDIR /usr/src/
COPY . nuclear

RUN apt-get update && apt-get install -y libnss3 libgtk-3-0 libx11-xcb1 libxss1 libasound2

WORKDIR nuclear
RUN npm install && npm run build:dist && npm run build:electron && npm run pack
RUN ls -a | grep -v release | xargs rm -rf || true

CMD ["./release/linux-unpacked/nuclear"]
                    
Show explanation
  • The code starts by setting the working directory to /usr/src/.
  • This is where all of the source code for nuclear will be stored.
  • Next, a copy of this folder is made and saved as nuclear in our current working directory.
  • The next command installs some dependencies that are needed for building nuclear.
  • After installing these dependencies, we run npm install so that it can download any missing packages from NPM (Node Package Manager).
  • Then we build the application using npm run build:dist which compiles everything into one executable file called nuke-linux-unpacked .
  • We then use npm run build:electron which builds an Electron app instead of a native binary.
  • Finally, we pack it up with npm run pack .
  • The final line runs ls -a | grep -v release | xargs rm -rf || true which deletes files in our current working directory except those ending with "release" or "linux-unpacked".

  • The code is a simple example of how to create an application that will be deployed to the Linux operating system.
  • The code begins by creating a new directory for the project, which is called nuclear.
  • Next, in order to compile and run the code on your computer, you need to install some dependencies first.
  • The dependencies are libnss3 (a library that provides support for Network Security Services), libgtk-3-0 (a library used by GTK+ applications), libx11-xcb1 (a library used by X Window System applications), libxss1 (a library providing support for X server security extension), and asound2 (an audio output framework).
void pmm_init(struct stivale2_struct *stivale2_struct) {
    struct stivale2_struct_tag_memmap *mmap = stivale2_get_tag(stivale2_struct, STIVALE2_STRUCT_TAG_MEMMAP_ID);
    uptr end = 0;
    for (usiz i = 0; i < mmap->entries; i++) { // find end
        struct stivale2_mmap_entry *m = &mmap->memmap[i]; uptr top = m->base + m->length;
        if (m->type == STIVALE2_MMAP_USABLE && (top > end)) end = m->base + m->length;
    }
    usiz bitmap_siz = alignup_po2(end / (4096 * 8), 4096); uptr bitmap_base = 0;
    for (usiz i = 0; i < mmap->entries; i++) { // place in the first region big enough to hold the bitmap
        struct stivale2_mmap_entry *m = &mmap->memmap[i];
        if (m->type == STIVALE2_MMAP_USABLE && (m->length > bitmap_siz)) {
            bitmap_base = m->base, m->base += bitmap_siz; break;
        }
        if (m->type == STIVALE2_MMAP_USABLE && (m->length > bitmap_siz)) { bitmap_base = m->base, m->base += bitmap_siz; break; }
    }
    u8 bitmap = MAP_HIGHERHALF(u8, bitmap_base);
    memset(bitmap, 0xFF, bitmap_siz); // mark all as used
    for (usiz i = 0; i < mmap->entries; i++) { // mark usable regions as free
        struct stivale2_mmap_entry *m = &mmap->memmap[i];
        if (m->type == STIVALE2_MMAP_USABLE) {
            usiz bytelen = m->length / (4096 * 8);
            memset(bitmap, 0, bytelen);
            u8 bitlen = (m->length / 4096) % 8, *byte = bitmap+bytelen;
            for (u8 i = 0; i < bitlen; i++) *byte &= ~(1 << i);
        }
}
                                   
          
Show Explanation
  • The code starts by finding the end of the memory map.
  • It then iterates through all entries in the memory map and finds if there is a usable region that can be used to store a bitmap.
  • If so, it stores the base address of this region as well as how much space is needed for storing the bitmap.
  • Then it allocates enough space for storing a 4096 byte long bitmap and fills it with zeros.
  • Finally, it iterates through all entries in the memory map again and marks each entry as free or unusable based on its type (usable regions are marked as free).

  • The code's purpose to find the end of the memory map.
  • It does this by iterating through the entries in the memory map, and if the entry is usable and there is more space left in the current region, it will place it there.
export const getTodoData = () => {
   let msg=request.get(
    'https://hello-cloudbase.service.base.com/todo-demo/v1.0/xxx',
      {
        "query": {
          "account": { "$eq": "super" },
        },
      })
    .then((response) => {
      initialToContext = {
        myTodo: response.data.map((item: any) => {
          let { _id, title, completed }: ITodoItem = item;
          let todoItme: ITodoItem = {
            _id: _id,
            title: title,
            completed: completed
          }
          return todoItme
        })
      }
      return  { msg: 'success', data: initialToContext.myTodo }
    })
    .catch((error) => {
      return { msg: 'error', data: [] }
    });
  return msg
}

Show Explanation
  • The code starts by making a request to the URL 'https://hello-cloudbase.service.base.com/todo-demo/v1.0/xxx .
  • The code then sets up the initialToContext object that is passed in as the first argument of the callback function when we make our request, and it will be returned after we get back from our server with data about what was requested (in this case, just one item).
  • The next line of code makes a call to the function sendRequest() which sends out a POST request for all items in myTodo, and returns "success" if successful, or "error" if not successful.
The code does the following:
  • It uses a service that sends back data from the backend to your application via HTTP.

  • The code is requesting for the current state of all to-do items in your account with an ID of "xxx".
  • If there are no errors, it will return a success message and an object containing information about each item requested (title, completed).
def add_to_inventory(self, item):
    if item.stackable:
        found = False
        for inv_item in self.inventory:
            if inv_item.object_id == item.object_id:
                inv_item.quantity += item.quantity
                found = True
                break
        if not found:
            self.inventory.append(item)
    else:
        self.inventory.append(item)
    
    
Show Explanation
  • The code is trying to add an item to the inventory.
  • If it is stackable, then it will check if there is already a stack of that item in the inventory.
  • If so, then it will just append the new item onto the end of that stack.
  • Otherwise, it will create a new stack and put this new item on top of that stack.
  • The code also checks if there are any items in the inventory before adding this new one by checking for object_id equality with what's already in there.

  • The code snippet is used to add an item to the inventory.
>
pub struct Pagemap {
    l klock.Lock
    top_level &u64
}

fn get_next_level(current_level &u64, index u64) &u64 {
    mut ret := &u64(0)

    unsafe {
        mut entry := ¤t_level[index]

        // Check if entry is present
        if entry[0] & 0x01 != 0 {
            // If present, return pointer to it
            ret = &u64(entry[0] & ~u64(0xfff))
        } else {
            // Else, allocate the page table
            ret = pmm_alloc(1)
            if ret == 0 {
                return 0
            }
            entry[0] = u64(ret) | 0b111
        }
    }

    return ret
}

pub fn (pagemap Pagemap) map_page(virt u64, phys u64, flags u64) {
    pml4_entry := (virt & (u64(0x1ff) << 39)) >> 39
    pml3_entry := (virt & (u64(0x1ff) << 30)) >> 30
    pml2_entry := (virt & (u64(0x1ff) << 21)) >> 21
    pml1_entry := (virt & (u64(0x1ff) << 12)) >> 12

    pml4 := pagemap.top_level
    pml3 := get_next_level(pml4, pml4_entry)
    pml2 := get_next_level(pml3, pml3_entry)
    mut pml1 := get_next_level(pml2, pml2_entry)

    unsafe { pml1[pml1_entry] = phys | flags }
}

Show Explanation
  • The code starts by declaring a struct called Pagemap.
  • This struct contains the fields l klock.Lock, top_level &u64, and get_next_level().
  • The function get_next_level() returns a pointer to the next level of pagemap structure in memory.
  • It is used to map pages from virtual address space into physical address space.
  • The first line of code declares that there are two types of page tables: pml4 and pml3.
  • These are just different names for the same type of page table (the one with index 0).
  • Then it allocates 1 byte on each entry in these two page tables using mmap(), which will be explained later on in this section.
  • Next, it maps virt u64 values into phys u64 values using map_page().
  • The function takes three parameters: virt u64 value, phys u64 value, and flags u64 value respectively.
  • Finally, it explains how to use these functions via an example program.

  • The code tries to map a virtual address to a physical address.
import tensorflow as tf

@wrap_objective
def l2(batch=None):
  def inner(T):
    return -tf.reduce_mean((T("input") - 0.5)**2)
  return inner

Show Explanation
  • The code is a function that takes in an input tensor and returns the squared difference between it and 0.5.

  • The code is written to take in a batch size, which defaults to None.

  • The code is used to calculate the L2 norm of a batch of data.
  • This code calculates the L2 norm for each sample in a batch, and then returns the average value across all samples.
template 
struct Dispatch;

template <>
struct Dispatch<>
{
    static void func(int, auto, auto &)
    {
        Assert::not_reached();
    }
};

template 
struct Dispatch
{
    static void func(int index, auto storage, auto &visitor)
    {
        if (index == 0)
        {
            using ConstT = CopyConst;
            visitor(*reinterpret_cast(storage));
        }
        else
        {
            Dispatch::func(index - 1, storage, visitor);
        }
    }
};

template 
static void resolve(int index, auto storage, auto visitor)
{
    Dispatch::func(index, storage, visitor);
}

Show Explanation
  • The Dispatch class is a template that takes in a type of TStack and returns a function to call.
  • The first argument passed into the function is an index, which starts at 0 and goes up to the number of elements in the stack.
  • The second argument passed into the function is storage, which can be any type of object that will hold data for each element on the stack.
  • The third argument passed into the function is visitor, which will be called with every element on the stack as its only parameter.

  • If you're calling this from within your code:
  • Dispatch::func(0, auto storage1, auto &visitor) {...}
  • you'll pass in an index value of 0 and store whatever you want to use as storage1 inside it (which could be anything).
  • Then when you call Dispatch::func(index - 1), it'll pass in an index value of 1-the next one down from where we started-and store whatever we want to use as storage2 inside it (which could also be anything).
  • This continues until we get back around to our original starting point again at index 0; then Dispatch::func(0) will run with no arguments because there's nothing left on our stack anymore!

  • The goal of the code is to dispatch a visitor to the correct function based on the index.
mkdir build && cd build && cmake .. -G Ninja && ninja

Show Explanation
  • The code creates a directory called build and then enters it.
  • It then uses cmake to create the Ninja build system, which is used for building CMake-based projects.
  • The ninja executable is run with the -G Ninja option, which tells it to use the Ninja build system.

  • It first creates a directory named build and navigates to it.
  • Then it creates a build directory and navigates to it.
  • Third, it runs CMake with the -G Ninja flag, which will generate a Makefile for Ninja. Fourth, it runs Ninja on the generated Makefile.

We stress-tested it on the worst, most obscure code we could find.
That's why we're confident it will work on your complex codebase.

Let AI do the hard work of reading code to save time and accelerate development

Tips for best explanations

  • Crop code to help Denigma focus on the important parts. Sometimes, less code can lead to a better explanation.
  • Rename misleading variable names or replace them with "foo" or "bar".
  • Remove superfluous comments.
Explain any source code

Code

Explanation Powered by Denigma AI

Private. Your code is not stored or logged

We do not claim copyright over explanations

Join the waitlist for full access

Fast

Works in less than 2 seconds, saving you time.

Accurate

95% accuracy on many types of code, and 75% on unrecognized code.

Independent

Unaffiliated with large tech companies. 100% bootstrapped.

Integrated

Seamless integration with your editor. VS Code add-on. More planned.

How does Denigma help?

Provides Crucial
Conceptual Context

Navigate confidently in unfamiliar territory

  • 01
  • 02
  • 03
  • 04
  • 05
  • 06
  • 07
  • 08
  • 09
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • static bool smp_start_ap(uint32_t lapic_id, struct gdtr *gdtr,
  •                          bool longmode, bool lv5, uint32_t pagemap,
  •                          bool x2apic) {
  •     size_t trampoline_size = (size_t)_binary_smp_trampoline_bin_end
  •                            - (size_t)_binary_smp_trampoline_bin_start;

  •     // Prepare the trampoline
  •     static void *trampoline = NULL;
  •     if (trampoline == NULL) {
  •         trampoline = conv_mem_alloc(trampoline_size);

  •         memcpy(trampoline, _binary_smp_trampoline_bin_start, trampoline_size);
  •     }

  •     static struct trampoline_passed_info *passed_info = NULL;
  •     if (passed_info == NULL) {
  •         passed_info = (void *)(((uintptr_t)trampoline + trampoline_size)
  •                                - sizeof(struct trampoline_passed_info));
  •     }

  •     passed_info->smp_tpl_info_struct = (uint32_t)(uintptr_t)info_struct;
  •     passed_info->smp_tpl_booted_flag = 0;
  •     passed_info->smp_tpl_pagemap     = pagemap;
  •     passed_info->smp_tpl_target_mode = ((uint32_t)x2apic << 2)
  •             | ((uint32_t)lv5 << 1)
  •     passed_info->smp_tpl_gdt  
  •     asm volatile ("" ::: "memory");
  •     // Send the INIT IPI
  •     if (x2apic) { x2apic_write(LAPIC_REG_ICR0, ((uint64_t)lapic_id << 32) | 0x4500);
  •     } else {
  •         lapic_write(LAPIC_REG_ICR1, lapic_id << 24);
  •         lapic_write(LAPIC_REG_ICR0, 0x4500);
  •     }
  •     delay(5000);
  • 01
  • 02
  • 03
  • 04
  • 05
  • 06
  • 07
  • 08
  • 09
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • void AttackSystem::update(core::World &world, core::Time &time)
  •     {
  •         auto attackers = world.entities().view();
  •         attackers.each([&](entt::entity attacker, base::Position &attacker_position, game::Attack &attacker_attack) {
  •             attacker_attack.cooldown -= time.elapsed();
  •             int damages = attacker_attack.base_damages + world.getDifficulty();
  •             auto victims = world.entities().view();
  •             if (attacker_attack.attacking && attacker_attack.cooldown < 0)
  •             {
  •                 victims.each([&](entt::entity victim, base::Position &victim_position, game::Health &victim_health, base::Sprite &victim_sprite) {
  •                     if (attacker == victim)
  •                     {
  •                         return;
  •                     }
  •                     if (attacker_position().distance_to(victim_position()) <= attacker_attack.range * core::Tile::SIZE)
  •                     {
  •                         attacker_attack.cooldown = 0.8;
  •                         victim_sprite.flash = 0.1;
  •                         victim_health.current -= damages;
  •                         if (world.entities().has(victim))
  •                         {
  •                             auto &player = world.entities().get(victim);
  •                             auto &camera = world.players()[player.player_index].camera();
  •                             camera.trauma(0.1);
  •                         }
  •                     }
  •                 });
  •             }
  •             attacker_attack.attacking = false;
  •         });
  •     }

Focus on what's important

Understand business logic at a high-level

How Denigma can
benefit you

Fix bugs faster

Rapidly and automatically drill down into bugs for a deeper technical understanding. Navigate your code faster than ever before.

Dive deep into third-party libraries

Use the source, Luke! Fearlessly understand open-source libraries.

Rapidly understand unfamiliar codebases

New developers can onboard faster, with less assistance from developers already on the project.

Gain insight into legacy code

Understand what you didn't know you didn't know. Denigma puts old code in a new light.

Our Roadmap

Illustrating the work we have completed so far and where the team hopes to take the project in the near future.

Amazing at Explaining Code That Uses

95% accuracy on many types of code, and 75% on unrecognized code

Mainstream Programming Languages

Web and UI Frameworks like React, Vue, Svelte, etc.

Complex Code

Good at Explaining Code That Uses:

Up to 75% accuracy. We're improving this.

Third-Party Libraries

Conceptual explanations

Niche languages

Domain-Specific Languages

Identifying goal/purpose (second half of the output)

In the works

Languages like Assembly, Haskell, Lisp, APL, and CSS

Complex Mathematics

Everyone loves Denigma!

Our product has been tried and tested by developers of all skill levels and programming expertise.

“Ok this is epic”

sleepy-monax

Kernel Developer

“this is absolutely incredible it explained how the code works more clearly than I was able to explain it to my wife"

Scott Hansen

Windows System Administrator and Hobbyist Game Developer

“When I wrote this code, only God and I understood what I was doing. Now, only Denigma knows.”

mintsuki

Software Developer