Compare current demand with fixed capacity and report remaining reserve.

reserve Reserve is the capacity left after current demand has been accounted for.
capacity status A small status branch separates comfortable, watch, and tight capacity states.

Capacity Reserve Reliability Report

demand
capacity_reserve_reliability_report.c
Replay: real traced execution (multi-file project)
#include <stdio.h>

int main(void) {
    int demand = 72;
    int capacity = 100;
    int reserve = capacity - demand;
    const char *status = "stable";

    if (reserve < 20) {
        status = "watch";
    }

    if (reserve < 10) {
        status = "tight";
    }

    printf("demand=%d\n", demand);
    printf("reserve=%d\n", reserve);
    printf("status=%s\n", status);
    return 0;
}
#include <stdio.h>

int main(void) {
    int demand = 88;
    int capacity = 100;
    int reserve = capacity - demand;
    const char *status = "stable";

    if (reserve < 20) {
        status = "watch";
    }

    if (reserve < 10) {
        status = "tight";
    }

    printf("demand=%d\n", demand);
    printf("reserve=%d\n", reserve);
    printf("status=%s\n", status);
    return 0;
}
#include <stdio.h>

int main(void) {
    int demand = 95;
    int capacity = 100;
    int reserve = capacity - demand;
    const char *status = "stable";

    if (reserve < 20) {
        status = "watch";
    }

    if (reserve < 10) {
        status = "tight";
    }

    printf("demand=%d\n", demand);
    printf("reserve=%d\n", reserve);
    printf("status=%s\n", status);
    return 0;
}
  1. demand ← 72, capacity ← 100, reserve ← 28, status ← stable

    3int main(void) {4    int demand→ 72 = 72; //@demand=88, 955    int capacity→ 100 = 100;6    int reserve→ 28 = capacity100 - demand72;7    const char *status→ stable = "stable";89    if (reserve < 20) {10        status = "watch";11    }1213    if (reserve < 10) {14        status = "tight";15    }1617    printf("demand=%d\n", demand72);18    printf("reserve=%d\n", reserve28);19    printf("status=%s\n", statusstable);20    return 0;21}
    outputdemand=72
    reserve=28
    status=stable
  1. demand ← 88, capacity ← 100, reserve ← 12, status ← stable

    3int main(void) {4    int demand→ 88 = 88;5    int capacity→ 100 = 100;6    int reserve→ 12 = capacity100 - demand88;7    const char *status→ stable = "stable";
  2. status ← watch

    9if (reserve12 < 20) {10    status→ watch = "watch";11}
  3. printf("demand=%d ", demand);

    17    printf("demand=%d\n", demand88);18    printf("reserve=%d\n", reserve12);19    printf("status=%s\n", statuswatch);20    return 0;21}
    outputdemand=88
    reserve=12
    status=watch
  1. demand ← 95, capacity ← 100, reserve ← 5, status ← stable

    3int main(void) {4    int demand→ 95 = 95;5    int capacity→ 100 = 100;6    int reserve→ 5 = capacity100 - demand95;7    const char *status→ stable = "stable";
  2. status ← watch

    9if (reserve5 < 20) {10    status→ watch = "watch";11}
  3. status ← tight

    13if (reserve5 < 10) {14    status→ tight = "tight";15}
  4. printf("demand=%d ", demand);

    17    printf("demand=%d\n", demand95);18    printf("reserve=%d\n", reserve5);19    printf("status=%s\n", statustight);20    return 0;21}
    outputdemand=95
    reserve=5
    status=tight