#include <stdint.h>

uint32_t light_apply_intensity(uint32_t original_color, float p) {
    if (p < 0) p = 0;
    if (p > 1) p = 1;

    uint32_t a = (original_color & 0xFF000000);
    uint32_t r = (original_color & 0x00FF0000) * p;
    uint32_t g = (original_color & 0x0000FF00) * p;
    uint32_t b = (original_color & 0x000000FF) * p;

    return (a | (r & 0x00FF0000) | (g & 0x0000FF00) | (b & 0x000000FF));
}