// File: /workspace/github_c_makefile_star2_O0/lukexi[P]eglstreams-mini/src/egl.c
// Function: GetEglConfig
EGLConfig GetEglConfig(EGLDisplay eglDpy) {
    EGLint configAttribs[] = {
        EGL_SURFACE_TYPE, EGL_STREAM_BIT_KHR,
        EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
        EGL_RED_SIZE, 1,
        EGL_GREEN_SIZE, 1,
        EGL_BLUE_SIZE, 1,
        EGL_ALPHA_SIZE, 0,
        EGL_DEPTH_SIZE, 1,
        EGL_NONE,
    };

    const char *extensionString = eglQueryString(eglDpy, EGL_EXTENSIONS);

    /*
     * EGL_EXT_output_base and EGL_EXT_output_drm are needed to find
     * the EGLOutputLayer for the DRM KMS plane.
     */

    if (!ExtensionIsSupported(extensionString, "EGL_EXT_output_base")) {
        Fatal("EGL_EXT_output_base not found.\n");
    }

    if (!ExtensionIsSupported(extensionString, "EGL_EXT_output_drm")) {
        Fatal("EGL_EXT_output_drm not found.\n");
    }

    /*
     * EGL_KHR_stream, EGL_EXT_stream_consumer_egloutput, and
     * EGL_KHR_stream_producer_eglsurface are needed to create an
     * EGLStream connecting an EGLSurface and an EGLOutputLayer.
     */

    if (!ExtensionIsSupported(extensionString, "EGL_KHR_stream")) {
        Fatal("EGL_KHR_stream not found.\n");
    }

    if (!ExtensionIsSupported(extensionString,
                              "EGL_EXT_stream_consumer_egloutput")) {
        Fatal("EGL_EXT_stream_consumer_egloutput not found.\n");
    }

    if (!ExtensionIsSupported(extensionString,
                              "EGL_KHR_stream_producer_eglsurface")) {
        Fatal("EGL_KHR_stream_producer_eglsurface not found.\n");
    }

    /* Bind full OpenGL as EGL's client API. */

    eglBindAPI(EGL_OPENGL_API);

    /* Find a suitable EGL config. */
    EGLint n = 0;
    EGLConfig eglConfig;
    EGLBoolean ret = eglChooseConfig(eglDpy, configAttribs, &eglConfig, 1, &n);

    if (!ret || !n) {
        Fatal("eglChooseConfig() failed.\n");
    }

    return eglConfig;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
leaq -0x50(%rbp), %rdi
leaq 0x2e59(%rip), %rsi      # 0x60d0
movl $0x3c, %edx
callq 0x23c0
movq -0x8(%rbp), %rdi
movl $0x3055, %esi           # imm = 0x3055
callq 0x21d0
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
leaq 0x3223(%rip), %rsi      # 0x64c1
callq 0x2cf0
cmpl $0x0, %eax
jne 0x32b6
leaq 0x3226(%rip), %rdi      # 0x64d5
movb $0x0, %al
callq 0x4cf0
movq -0x58(%rbp), %rdi
leaq 0x3234(%rip), %rsi      # 0x64f5
callq 0x2cf0
cmpl $0x0, %eax
jne 0x32d9
leaq 0x3236(%rip), %rdi      # 0x6508
movb $0x0, %al
callq 0x4cf0
movq -0x58(%rbp), %rdi
leaq 0x3243(%rip), %rsi      # 0x6527
callq 0x2cf0
cmpl $0x0, %eax
jne 0x32fc
leaq 0x3241(%rip), %rdi      # 0x6536
movb $0x0, %al
callq 0x4cf0
movq -0x58(%rbp), %rdi
leaq 0x324a(%rip), %rsi      # 0x6551
callq 0x2cf0
cmpl $0x0, %eax
jne 0x331f
leaq 0x325b(%rip), %rdi      # 0x6573
movb $0x0, %al
callq 0x4cf0
movq -0x58(%rbp), %rdi
leaq 0x3277(%rip), %rsi      # 0x65a1
callq 0x2cf0
cmpl $0x0, %eax
jne 0x3342
leaq 0x3289(%rip), %rdi      # 0x65c4
movb $0x0, %al
callq 0x4cf0
movl $0x30a2, %edi           # imm = 0x30A2
callq 0x2380
movl $0x0, -0x5c(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x68(%rbp), %rdx
movl $0x1, %ecx
leaq -0x5c(%rbp), %r8
callq 0x2410
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
je 0x337c
cmpl $0x0, -0x5c(%rbp)
jne 0x338a
leaq 0x3270(%rip), %rdi      # 0x65f3
movb $0x0, %al
callq 0x4cf0
movq -0x68(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)