static void configure_alarms(char const *opt)

{

    int i;

    int cur = 0;

    int count = (sizeof(alarm_timers) / sizeof(*alarm_timers)) - 1;

    char *arg;

    char *name;



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

        show_available_alarms();

        exit(0);

    }



    arg = strdup(opt);



    /* Reorder the array */

    name = strtok(arg, ",");

    while (name) {

        struct qemu_alarm_timer tmp;



        for (i = 0; i < count; 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, ",");

    }



    free(arg);



    if (cur) {

	/* Disable remaining timers */

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

            alarm_timers[i].name = NULL;

    }



    /* debug */

    show_available_alarms();

}

static void configure_alarms(char const *opt)

{

    int i;

    int cur = 0;

    int count = (sizeof(alarm_timers) / sizeof(*alarm_timers)) - 1;

    char *arg;

    char *name;



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

        show_available_alarms();

        exit(0);

    }



    arg = strdup(opt);



    

    name = strtok(arg, ",");

    while (name) {

        struct qemu_alarm_timer tmp;



        for (i = 0; i < count; 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, ",");

    }



    free(arg);



    if (cur) {

	

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

            alarm_timers[i].name = NULL;

    }



    

    show_available_alarms();

}

static void FUNC_0(char const *VAR_0)

{

    int VAR_1;

    int VAR_2 = 0;

    int VAR_3 = (sizeof(alarm_timers) / sizeof(*alarm_timers)) - 1;

    char *VAR_4;

    char *VAR_5;



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

        show_available_alarms();

        exit(0);

    }



    VAR_4 = strdup(VAR_0);



    

    VAR_5 = strtok(VAR_4, ",");

    while (VAR_5) {

        struct qemu_alarm_timer VAR_6;



        for (VAR_1 = 0; VAR_1 < VAR_3; 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, ",");

    }



    free(VAR_4);



    if (VAR_2) {

	

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

            alarm_timers[VAR_1].VAR_5 = NULL;

    }



    

    show_available_alarms();

}

static void FUNC_0(char const *VAR_0)
{ int VAR_1; int VAR_2 = 0; int VAR_3 = (sizeof(alarm_timers) / sizeof(*alarm_timers)) - 1; char *VAR_4; char *VAR_5; if (!strcmp(VAR_0, "help")) { show_available_alarms(); exit(0); } VAR_4 = strdup(VAR_0); VAR_5 = strtok(VAR_4, ","); while (VAR_5) { struct qemu_alarm_timer VAR_6; for (VAR_1 = 0; VAR_1 < VAR_3; 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, ","); } free(VAR_4); if (VAR_2) { for (VAR_1 = VAR_2; VAR_1 < VAR_3; VAR_1++) alarm_timers[VAR_1].VAR_5 = NULL; } show_available_alarms(); }