Repair a loader with leaks and a freed return value

Diagnose every resource/lifetime error in load_first below, including failed open, failed allocation, failed conversion and the success path. Replace it with int load_first(const char *path, int **out): the caller supplies a valid out pointer; on success it receives ownership of one allocated int, and on any failure *out remains NULL. Read only the first integer; trailing input is intentionally ignored. Numeric tokens supplied to %d are representable as int. Check stream errors and close results. Write a driver that prints value=k or load failed and frees a successful result. Never run the invalid original.

int *load_first(void) {
    FILE *f = fopen("config.txt", "r");
    int *p = malloc(sizeof *p);
    if (fscanf(f, "%d", p) != 1) return NULL;
    fclose(f);
    free(p);
    return p;
}

