void configure_alarms(char const *opt)

{

    int i;

    int cur = 0;

    int count = ARRAY_SIZE(alarm_timers) - 1;

    char *arg;

    char *name;

    struct qemu_alarm_timer tmp;



    if (!strcmp(opt, "?")) {

        show_available_alarms();

        exit(0);

    }



    arg = g_strdup(opt);



    /* Reorder the array */

    name = strtok(arg, ",");

    while (name) {

        for (i = 0; i < count && alarm_timers[i].name; i++) {

            if (!strcmp(alarm_timers[i].name, name))

                break;

        }



        if (i == count) {

            fprintf(stderr, "Unknown clock %s\n", name);

            goto next;

        }



        if (i < cur)

            /* Ignore */

            goto next;



	/* Swap */

        tmp = alarm_timers[i];

        alarm_timers[i] = alarm_timers[cur];

        alarm_timers[cur] = tmp;



        cur++;

next:

        name = strtok(NULL, ",");

    }



    g_free(arg);



    if (cur) {

        /* Disable remaining timers */

        for (i = cur; i < count; i++)

            alarm_timers[i].name = NULL;

    } else {

        show_available_alarms();

        exit(1);

    }

}

void configure_alarms(char const *opt)

{

    int i;

    int cur = 0;

    int count = ARRAY_SIZE(alarm_timers) - 1;

    char *arg;

    char *name;

    struct qemu_alarm_timer tmp;



    if (!strcmp(opt, "?")) {

        show_available_alarms();

        exit(0);

    }



    arg = g_strdup(opt);



    

    name = strtok(arg, ",");

    while (name) {

        for (i = 0; i < count && alarm_timers[i].name; i++) {

            if (!strcmp(alarm_timers[i].name, name))

                break;

        }



        if (i == count) {

            fprintf(stderr, "Unknown clock %s\n", name);

            goto next;

        }



        if (i < cur)

            

            goto next;



	

        tmp = alarm_timers[i];

        alarm_timers[i] = alarm_timers[cur];

        alarm_timers[cur] = tmp;



        cur++;

next:

        name = strtok(NULL, ",");

    }



    g_free(arg);



    if (cur) {

        

        for (i = cur; i < count; i++)

            alarm_timers[i].name = NULL;

    } else {

        show_available_alarms();

        exit(1);

    }

}

    if (!strcmp(opt, "?")) {
void FUNC_0(char const *VAR_0)

{

    int VAR_1;

    int VAR_2 = 0;

    int VAR_3 = ARRAY_SIZE(alarm_timers) - 1;

    char *VAR_4;

    char *VAR_5;

    struct qemu_alarm_timer VAR_6;



    if (!strcmp(VAR_0, "?")) {

        show_available_alarms();

        exit(0);

    }



    VAR_4 = g_strdup(VAR_0);



    

    VAR_5 = strtok(VAR_4, ",");

    while (VAR_5) {

        for (VAR_1 = 0; VAR_1 < VAR_3 && alarm_timers[VAR_1].VAR_5; VAR_1++) {

            if (!strcmp(alarm_timers[VAR_1].VAR_5, VAR_5))

                break;

        }



        if (VAR_1 == VAR_3) {

            fprintf(stderr, "Unknown clock %s\n", VAR_5);

            goto next;

        }



        if (VAR_1 < VAR_2)

            

            goto next;



	

        VAR_6 = alarm_timers[VAR_1];

        alarm_timers[VAR_1] = alarm_timers[VAR_2];

        alarm_timers[VAR_2] = VAR_6;



        VAR_2++;

next:

        VAR_5 = strtok(NULL, ",");

    }



    g_free(VAR_4);



    if (VAR_2) {

        

        for (VAR_1 = VAR_2; VAR_1 < VAR_3; VAR_1++)

            alarm_timers[VAR_1].VAR_5 = NULL;

    } else {

        show_available_alarms();

        exit(1);

    }

}

void FUNC_0(char const *VAR_0)
{ int VAR_1; int VAR_2 = 0; int VAR_3 = ARRAY_SIZE(alarm_timers) - 1; char *VAR_4; char *VAR_5; struct qemu_alarm_timer VAR_6; if (!strcmp(VAR_0, "?")) { show_available_alarms(); exit(0); } VAR_4 = g_strdup(VAR_0); VAR_5 = strtok(VAR_4, ","); while (VAR_5) { for (VAR_1 = 0; VAR_1 < VAR_3 && alarm_timers[VAR_1].VAR_5; VAR_1++) { if (!strcmp(alarm_timers[VAR_1].VAR_5, VAR_5))
break; } if (VAR_1 == VAR_3) { fprintf(stderr, "Unknown clock %s\n", VAR_5); goto next; } if (VAR_1 < VAR_2)
goto next; VAR_6 = alarm_timers[VAR_1]; alarm_timers[VAR_1] = alarm_timers[VAR_2]; alarm_timers[VAR_2] = VAR_6; VAR_2++; next:
VAR_5 = strtok(NULL, ","); } g_free(VAR_4); if (VAR_2) { for (VAR_1 = VAR_2; VAR_1 < VAR_3; VAR_1++) alarm_timers[VAR_1].VAR_5 = NULL; } else { show_available_alarms(); exit(1); } }