int qemu_egl_rendernode_open(void)

{

    DIR *dir;

    struct dirent *e;

    int r, fd;

    char *p;



    dir = opendir("/dev/dri");

    if (!dir) {

        return -1;

    }



    fd = -1;

    while ((e = readdir(dir))) {

        if (e->d_type != DT_CHR) {

            continue;

        }



        if (strncmp(e->d_name, "renderD", 7)) {

            continue;

        }



        r = asprintf(&p, "/dev/dri/%s", e->d_name);

        if (r < 0) {

            return -1;

        }



        r = open(p, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK);

        if (r < 0) {

            free(p);

            continue;

        }

        fd = r;

        free(p);

        break;

    }



    closedir(dir);

    if (fd < 0) {

        return -1;

    }

    return fd;

}

int qemu_egl_rendernode_open(void)

{

    DIR *dir;

    struct dirent *e;

    int r, fd;

    char *p;



    dir = opendir("/dev/dri");

    if (!dir) {

        return -1;

    }



    fd = -1;

    while ((e = readdir(dir))) {

        if (e->d_type != DT_CHR) {

            continue;

        }



        if (strncmp(e->d_name, "renderD", 7)) {

            continue;

        }



        r = asprintf(&p, "/dev/dri/%s", e->d_name);

        if (r < 0) {

            return -1;

        }



        r = open(p, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK);

        if (r < 0) {

            free(p);

            continue;

        }

        fd = r;

        free(p);

        break;

    }



    closedir(dir);

    if (fd < 0) {

        return -1;

    }

    return fd;

}

        r = asprintf(&p, "/dev/dri/%s", e->d_name);         if (r < 0) {             return -1;             free(p);         free(p);
int FUNC_0(void)

{

    DIR *dir;

    struct dirent *VAR_0;

    int VAR_1, VAR_2;

    char *VAR_3;



    dir = opendir("/dev/dri");

    if (!dir) {

        return -1;

    }



    VAR_2 = -1;

    while ((VAR_0 = readdir(dir))) {

        if (VAR_0->d_type != DT_CHR) {

            continue;

        }



        if (strncmp(VAR_0->d_name, "renderD", 7)) {

            continue;

        }



        VAR_1 = asprintf(&VAR_3, "/dev/dri/%s", VAR_0->d_name);

        if (VAR_1 < 0) {

            return -1;

        }



        VAR_1 = open(VAR_3, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK);

        if (VAR_1 < 0) {

            free(VAR_3);

            continue;

        }

        VAR_2 = VAR_1;

        free(VAR_3);

        break;

    }



    closedir(dir);

    if (VAR_2 < 0) {

        return -1;

    }

    return VAR_2;

}

int FUNC_0(void)
{ DIR *dir; struct dirent *VAR_0; int VAR_1, VAR_2; char *VAR_3; dir = opendir("/dev/dri"); if (!dir) { return -1; } VAR_2 = -1; while ((VAR_0 = readdir(dir))) { if (VAR_0->d_type != DT_CHR) { continue; } if (strncmp(VAR_0->d_name, "renderD", 7)) { continue; } VAR_1 = asprintf(&VAR_3, "/dev/dri/%s", VAR_0->d_name); if (VAR_1 < 0) { return -1; } VAR_1 = open(VAR_3, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK); if (VAR_1 < 0) { free(VAR_3); continue; } VAR_2 = VAR_1; free(VAR_3); break; } closedir(dir); if (VAR_2 < 0) { return -1; } return VAR_2; }