xconfigErrorMsg

decompiled_code:
void xconfigErrorMsg(unsigned int a1, const char *a2, ...)
{
double v2; // xmm0_8
double v3; // xmm1_8
double v4; // xmm2_8
double v5; // xmm3_8
double v6; // xmm6_8
double v7; // xmm7_8
int v8; // ebx
size_t v9; // r14
char *i; // r15
int v11; // eax
double v12; // xmm4_8
double v13; // xmm5_8
char *v14; // r12
double v15; // xmm4_8
double v16; // xmm5_8
char *v17; // r12
double v18; // xmm4_8
double v19; // xmm5_8
char *v20; // r13
double v21; // xmm4_8
double v22; // xmm5_8
gcc_va_list arg; // [rsp+18h] [rbp-138h] BYREF
char s[64]; // [rsp+30h] [rbp-120h] BYREF
__int128 v25; // [rsp+A0h] [rbp-B0h]
__int128 v26; // [rsp+B0h] [rbp-A0h]
__int128 v27; // [rsp+C0h] [rbp-90h]
__int128 v28; // [rsp+D0h] [rbp-80h]
__int128 v29; // [rsp+E0h] [rbp-70h]
__int128 v30; // [rsp+F0h] [rbp-60h]
__int128 v31; // [rsp+100h] [rbp-50h]
__int128 v32; // [rsp+110h] [rbp-40h]

va_start(arg, a2);
*(double *)&v25 = va_arg(arg, double);
v2 = *(double *)&v25;
*(double *)&v26 = va_arg(arg, double);
v3 = *(double *)&v26;
*(double *)&v27 = va_arg(arg, double);
v4 = *(double *)&v27;
*(double *)&v28 = va_arg(arg, double);
v5 = *(double *)&v28;
*(double *)&v29 = va_arg(arg, double);
*(double *)&v30 = va_arg(arg, double);
*(double *)&v31 = va_arg(arg, double);
v6 = *(double *)&v31;
*(double *)&v32 = va_arg(arg, double);
v7 = *(double *)&v32;
va_end(arg);
v8 = 64;
v9 = 64LL;
for ( i = (char *)xconfigAlloc(0x40uLL); ; i = (char *)xconfigAlloc(v8) )
{
va_start(arg, a2);
v11 = vsnprintf(i, v9, a2, arg);
if ( v11 < (unsigned int)v8 )
break;
v8 += 64;
if ( v11 >= 0 )
v8 = v11 + 1;
free(i);
v9 = v8;
}
if ( a1 == 1 )
{
sprintf(s, "%d", configLineNo);
v17 = xconfigStrcat(
"Parse warning on line ",
(__int64)s,
v2,
v3,
v4,
v5,
v15,
v16,
v6,
v7,
" of section ",
configSection,
" in file ",
configPath,
".\n",
0LL);
}
else if ( a1 == 2 )
{
v17 = xconfigStrcat("Data incomplete in file ", configPath, v2, v3, v4, v5, v12, v13, v6, v7, ".\n", 0LL);
}
else
{
if ( a1 )
{
LABEL_9:
v14 = strdup(i);
xconfigPrint(a1, v14);
free(i);
free(v14);
return;
}
sprintf(s, "%d", configLineNo);
v17 = xconfigStrcat(
"Parse error on line ",
(__int64)s,
v2,
v3,
v4,
v5,
v21,
v22,
v6,
v7,
" of section ",
configSection,
" in file ",
configPath,
".\n");
}
if ( !v17 )
goto LABEL_9;
v20 = xconfigStrcat(v17, (__int64)i, v2, v3, v4, v5, v18, v19, v6, v7, 0LL);
xconfigPrint(a1, v20);
free(i);
free(v20);
free(v17);
}

canonical_decompiled_code:
void func3(unsigned int a1, const char *a2, ...)
{
double v2; // xmm0_8
double v3; // xmm1_8
double v4; // xmm2_8
double v5; // xmm3_8
double v6; // xmm6_8
double v7; // xmm7_8
int v8; // ebx
size_t v9; // r14
char *i; // r15
int v11; // eax
double v12; // xmm4_8
double v13; // xmm5_8
char *v14; // r12
double v15; // xmm4_8
double v16; // xmm5_8
char *v17; // r12
double v18; // xmm4_8
double v19; // xmm5_8
char *v20; // r13
double v21; // xmm4_8
double v22; // xmm5_8
gcc_va_list arg; // [rsp+18h] [rbp-138h] BYREF
char s[64]; // [rsp+30h] [rbp-120h] BYREF
__int128 v25; // [rsp+A0h] [rbp-B0h]
__int128 v26; // [rsp+B0h] [rbp-A0h]
__int128 v27; // [rsp+C0h] [rbp-90h]
__int128 v28; // [rsp+D0h] [rbp-80h]
__int128 v29; // [rsp+E0h] [rbp-70h]
__int128 v30; // [rsp+F0h] [rbp-60h]
__int128 v31; // [rsp+100h] [rbp-50h]
__int128 v32; // [rsp+110h] [rbp-40h]

va_start(arg, a2);
*(double *)&v25 = va_arg(arg, double);
v2 = *(double *)&v25;
*(double *)&v26 = va_arg(arg, double);
v3 = *(double *)&v26;
*(double *)&v27 = va_arg(arg, double);
v4 = *(double *)&v27;
*(double *)&v28 = va_arg(arg, double);
v5 = *(double *)&v28;
*(double *)&v29 = va_arg(arg, double);
*(double *)&v30 = va_arg(arg, double);
*(double *)&v31 = va_arg(arg, double);
v6 = *(double *)&v31;
*(double *)&v32 = va_arg(arg, double);
v7 = *(double *)&v32;
va_end(arg);
v8 = 64;
v9 = 64LL;
for ( i = (char *)func0(0x40uLL); ; i = (char *)func0(v8) )
{
va_start(arg, a2);
v11 = vsnprintf(i, v9, a2, arg);
if ( v11 < (unsigned int)v8 )
break;
v8 += 64;
if ( v11 >= 0 )
v8 = v11 + 1;
free(i);
v9 = v8;
}
if ( a1 == 1 )
{
sprintf(s, "%d", configLineNo);
v17 = func2(
"Parse warning on line ",
(__int64)s,
v2,
v3,
v4,
v5,
v15,
v16,
v6,
v7,
" of section ",
configSection,
" in file ",
configPath,
".\n",
0LL);
}
else if ( a1 == 2 )
{
v17 = func2("Data incomplete in file ", configPath, v2, v3, v4, v5, v12, v13, v6, v7, ".\n", 0LL);
}
else
{
if ( a1 )
{
LABEL_9:
v14 = strdup(i);
xconfigPrint(a1, v14);
free(i);
free(v14);
return;
}
sprintf(s, "%d", configLineNo);
v17 = func2(
"Parse error on line ",
(__int64)s,
v2,
v3,
v4,
v5,
v21,
v22,
v6,
v7,
" of section ",
configSection,
" in file ",
configPath,
".\n");
}
if ( !v17 )
goto LABEL_9;
v20 = func2(v17, (__int64)i, v2, v3, v4, v5, v18, v19, v6, v7, 0LL);
xconfigPrint(a1, v20);
free(i);
free(v20);
free(v17);
}

original_code:
void xconfigErrorMsg(MsgType t, char *fmt, ...)
{
    va_list ap;
    int len, current_len = 64;
    char *b, *pre = ((void *)0), *msg;
    char scratch[64];
    b = xconfigAlloc(current_len);
    while (1) {
        __builtin_va_start(ap,fmt);
        len = vsnprintf(b, current_len, fmt, ap);
        __builtin_va_end(ap);
        if ((len > -1) && (len < current_len)) {
            break;
        } else if (len > -1) {
            current_len = len + 1;
        } else {
            current_len += 64;
        }
        free(b);
        b = xconfigAlloc(current_len);
    }
    switch (t) {
    case ParseErrorMsg:
        sprintf(scratch, "%d", configLineNo);
        pre = xconfigStrcat("Parse error on line ", scratch, " of section ",
                         configSection, " in file ", configPath, ".\n", ((void *)0));
        break;
    case ParseWarningMsg:
        sprintf(scratch, "%d", configLineNo);
        pre = xconfigStrcat("Parse warning on line ", scratch, " of section ",
                         configSection, " in file ", configPath, ".\n", ((void *)0));
        break;
    case ValidationErrorMsg:
        pre = xconfigStrcat("Data incomplete in file ", configPath, ".\n", ((void *)0));
        break;
    case InternalErrorMsg: break;
    case WriteErrorMsg: break;
    case WarnMsg: break;
    case ErrorMsg: break;
    case DebugMsg: break;
    case UnknownMsg: break;
    }
    if (pre) {
        msg = xconfigStrcat(pre, b, ((void *)0));
    } else {
        msg = strdup(b);
    }
    xconfigPrint(t, msg);
    free(b);
    free(msg);
    if (pre) free(pre);
}

canonical_original_code:
void xconfigErrorMsg(enum MsgType t, char *fmt, ...)
{
    __builtin_va_list ap;
    int len; int current_len = 64;
    char *b; char *pre = ((void *)0); char *msg;
    char scratch[64];
    b = xconfigAlloc(current_len);
    while (1) {
        __builtin_va_start(ap,fmt);
        len = vsnprintf(b, current_len, fmt, ap);
        __builtin_va_end(ap);
        if ((len > -1) && (len < current_len)) {
            break;
        } else if (len > -1) {
            current_len = len + 1;
        } else {
            current_len += 64;
        }
        free(b);
        b = xconfigAlloc(current_len);
    }
    switch (t) {
    case ParseErrorMsg:
        sprintf(scratch, "%d", configLineNo);
        pre = xconfigStrcat("Parse error on line ", scratch, " of section ",
                         configSection, " in file ", configPath, ".\n", ((void *)0));
        break;
    case ParseWarningMsg:
        sprintf(scratch, "%d", configLineNo);
        pre = xconfigStrcat("Parse warning on line ", scratch, " of section ",
                         configSection, " in file ", configPath, ".\n", ((void *)0));
        break;
    case ValidationErrorMsg:
        pre = xconfigStrcat("Data incomplete in file ", configPath, ".\n", ((void *)0));
        break;
    case InternalErrorMsg: break;
    case WriteErrorMsg: break;
    case WarnMsg: break;
    case ErrorMsg: break;
    case DebugMsg: break;
    case UnknownMsg: break;
    }
    if (pre) {
        msg = xconfigStrcat(pre, b, ((void *)0));
    } else {
        msg = strdup(b);
    }
    xconfigPrint(t, msg);
    free(b);
    free(msg);
    if (pre) free(pre);
}

variable_types: enum MsgType { ParseErrorMsg=0, ParseWarningMsg=1, ValidationErrorMsg=2, InternalErrorMsg=3, WriteErrorMsg=4, WarnMsg=5, ErrorMsg=6, DebugMsg=7, UnknownMsg=8 }

variable_types:
fmt
char *

variable_types: len int

variable_types:
b
char *

variable_types:
pre
char *

variable_types:
msg
char *

variable_types:
scratch
char [64]


repo: NVIDIA/nvidia-settings

decompiled_code:
__int64 open_libegl()
{
void **v0; // rbx
__int64 result; // rax
char *v2; // rax
void *v3; // rdi

v0 = (void **)_libEGL;
if ( !_libEGL )
{
_libEGL = (void *)nvalloc(64LL);
v0 = (void **)_libEGL;
}
if ( *v0 )
goto LABEL_4;
*v0 = dlopen("libEGL.so.1", 1);
v0 = (void **)_libEGL;
if ( *(_QWORD *)_libEGL )
{
dlerror();
v0[2] = dlsym(*v0, "eglInitialize");
v2 = dlerror();
if ( !v2 )
{
dlerror();
v0[3] = dlsym(*v0, "eglTerminate");
v2 = dlerror();
if ( !v2 )
{
dlerror();
v0[4] = dlsym(*v0, "eglGetDisplay");
v2 = dlerror();
if ( !v2 )
{
dlerror();
v0[5] = dlsym(*v0, "eglQueryString");
v2 = dlerror();
if ( !v2 )
{
dlerror();
v0[6] = dlsym(*v0, "eglGetConfigs");
v2 = dlerror();
if ( !v2 )
{
dlerror();
v0[7] = dlsym(*v0, "eglGetConfigAttrib");
v2 = dlerror();
if ( !v2 )
{
LABEL_4:
++*((_DWORD *)v0 + 2);
return 1LL;
}
}
}
}
}
}
LABEL_8:
nv_error_msg("libEGL setup error : %s\n", v2);
v0 = (void **)_libEGL;
result = 0LL;
if ( !_libEGL )
return result;
goto LABEL_9;
}
v2 = dlerror();
if ( v2 )
goto LABEL_8;
LABEL_9:
if ( *v0 )
{
dlclose(*v0);
v3 = _libEGL;
*(_QWORD *)_libEGL = 0LL;
}
else
{
v3 = _libEGL;
}
free(v3);
result = 0LL;
_libEGL = 0LL;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
void **v0; // rbx
__int64 result; // rax
char *v2; // rax
void *v3; // rdi

v0 = (void **)_libEGL;
if ( !_libEGL )
{
_libEGL = (void *)nvalloc(64LL);
v0 = (void **)_libEGL;
}
if ( *v0 )
goto LABEL_4;
*v0 = dlopen("libEGL.so.1", 1);
v0 = (void **)_libEGL;
if ( *(_QWORD *)_libEGL )
{
dlerror();
v0[2] = dlsym(*v0, "eglInitialize");
v2 = dlerror();
if ( !v2 )
{
dlerror();
v0[3] = dlsym(*v0, "eglTerminate");
v2 = dlerror();
if ( !v2 )
{
dlerror();
v0[4] = dlsym(*v0, "eglGetDisplay");
v2 = dlerror();
if ( !v2 )
{
dlerror();
v0[5] = dlsym(*v0, "eglQueryString");
v2 = dlerror();
if ( !v2 )
{
dlerror();
v0[6] = dlsym(*v0, "eglGetConfigs");
v2 = dlerror();
if ( !v2 )
{
dlerror();
v0[7] = dlsym(*v0, "eglGetConfigAttrib");
v2 = dlerror();
if ( !v2 )
{
LABEL_4:
++*((_DWORD *)v0 + 2);
return 1LL;
}
}
}
}
}
}
LABEL_8:
nv_error_msg("libEGL setup error : %s\n", v2);
v0 = (void **)_libEGL;
result = 0LL;
if ( !_libEGL )
return result;
goto LABEL_9;
}
v2 = dlerror();
if ( v2 )
goto LABEL_8;
LABEL_9:
if ( *v0 )
{
dlclose(*v0);
v3 = _libEGL;
*(_QWORD *)_libEGL = 0LL;
}
else
{
v3 = _libEGL;
}
free(v3);
result = 0LL;
_libEGL = 0LL;
return result;
}

original_code:
static int open_libegl(void)
{
    const char *error_str = ((void *)0);
    if ( !__libEGL ) {
        __libEGL = nvalloc(sizeof(__libEGLInfo));
    }
    if ( __libEGL->handle ) {
        __libEGL->ref_count++;
        return 1;
    }
    __libEGL->handle = dlopen("libEGL.so.1", 0x00001);
    if ( !__libEGL->handle ) {
        error_str = dlerror();
        goto fail;
    }
    __libEGL->eglInitialize =
        ({ dlerror(); dlsym(__libEGL->handle, "eglInitialize"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libEGL->eglTerminate =
        ({ dlerror(); dlsym(__libEGL->handle, "eglTerminate"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libEGL->eglGetDisplay =
        ({ dlerror(); dlsym(__libEGL->handle, "eglGetDisplay"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libEGL->eglQueryString =
        ({ dlerror(); dlsym(__libEGL->handle, "eglQueryString"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libEGL->eglGetConfigs =
        ({ dlerror(); dlsym(__libEGL->handle, "eglGetConfigs"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libEGL->eglGetConfigAttrib =
        ({ dlerror(); dlsym(__libEGL->handle, "eglGetConfigAttrib"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libEGL->ref_count++;
    return 1;
 fail:
    if ( error_str ) {
        nv_error_msg("libEGL setup error : %s\n", error_str);
    }
    if ( __libEGL ) {
        if ( __libEGL->handle ) {
            dlclose(__libEGL->handle);
            __libEGL->handle = ((void *)0);
        }
        free(__libEGL);
        __libEGL = ((void *)0);
    }
    return 0;
}

canonical_original_code:
static int open_libegl()
{
    char *error_str = ((void *)0);
    if ( !__libEGL ) {
        __libEGL = nvalloc(sizeof(__libEGLInfo));
    }
    if ( __libEGL->handle ) {
        __libEGL->ref_count++;
        return 1;
    }
    __libEGL->handle = dlopen("libEGL.so.1", 0x00001);
    if ( !__libEGL->handle ) {
        error_str = dlerror();
        goto fail;
    }
    __libEGL->eglInitialize =
        ({ dlerror(); dlsym(__libEGL->handle, "eglInitialize"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libEGL->eglTerminate =
        ({ dlerror(); dlsym(__libEGL->handle, "eglTerminate"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libEGL->eglGetDisplay =
        ({ dlerror(); dlsym(__libEGL->handle, "eglGetDisplay"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libEGL->eglQueryString =
        ({ dlerror(); dlsym(__libEGL->handle, "eglQueryString"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libEGL->eglGetConfigs =
        ({ dlerror(); dlsym(__libEGL->handle, "eglGetConfigs"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libEGL->eglGetConfigAttrib =
        ({ dlerror(); dlsym(__libEGL->handle, "eglGetConfigAttrib"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libEGL->ref_count++;
    return 1;
 fail:
    if ( error_str ) {
        nv_error_msg("libEGL setup error : %s\n", error_str);
    }
    if ( __libEGL ) {
        if ( __libEGL->handle ) {
            dlclose(__libEGL->handle);
            __libEGL->handle = ((void *)0);
        }
        free(__libEGL);
        __libEGL = ((void *)0);
    }
    return 0;
}

return_type: int


decompiled_code:
void *close_libegl()
{
void *result; // rax
int v1; // edx
int v2; // edx

result = _libEGL;
if ( _libEGL )
{
if ( *(_QWORD *)_libEGL )
{
v1 = *((_DWORD *)_libEGL + 2);
if ( v1 )
{
v2 = v1 - 1;
*((_DWORD *)_libEGL + 2) = v2;
if ( !v2 )
result = (void *)sub_1F8();
}
}
}
return result;
}

canonical_decompiled_code:
void *func1()
{
void *result; // rax
int v1; // edx
int v2; // edx

result = _libEGL;
if ( _libEGL )
{
if ( *(_QWORD *)_libEGL )
{
v1 = *((_DWORD *)_libEGL + 2);
if ( v1 )
{
v2 = v1 - 1;
*((_DWORD *)_libEGL + 2) = v2;
if ( !v2 )
result = (void *)sub_1F8();
}
}
}
return result;
}

original_code:
static void close_libegl(void)
{
    if ( __libEGL && __libEGL->handle && __libEGL->ref_count ) {
        __libEGL->ref_count--;
        if ( __libEGL->ref_count == 0 ) {
            dlclose(__libEGL->handle);
            __libEGL->handle = ((void *)0);
            free(__libEGL);
            __libEGL = ((void *)0);
        }
    }
}

canonical_original_code:
static void close_libegl()
{
    if ( __libEGL && __libEGL->handle && __libEGL->ref_count ) {
        __libEGL->ref_count--;
        if ( __libEGL->ref_count == 0 ) {
            dlclose(__libEGL->handle);
            __libEGL->handle = ((void *)0);
            free(__libEGL);
            __libEGL = ((void *)0);
        }
    }
}

return_type: void


decompiled_code:
__int64 open_libxv()
{
void **v0; // rbx
__int64 result; // rax
char *v2; // rax
void *v3; // rdi

v0 = (void **)_libXv;
if ( !_libXv )
{
_libXv = (void *)nvalloc(32LL);
v0 = (void **)_libXv;
}
if ( *v0 )
goto LABEL_4;
*v0 = dlopen("libXv.so.1", 1);
v0 = (void **)_libXv;
if ( *(_QWORD *)_libXv )
{
dlerror();
v0[2] = dlsym(*v0, "XvQueryExtension");
v2 = dlerror();
if ( !v2 )
{
dlerror();
v0[3] = dlsym(*v0, "XvQueryAdaptors");
v2 = dlerror();
if ( !v2 )
{
v2 = dlerror();
if ( !v2 )
{
LABEL_4:
++*((_DWORD *)v0 + 2);
return 1LL;
}
}
}
LABEL_8:
nv_error_msg("libXv setup error : %s\n", v2);
v0 = (void **)_libXv;
result = 0LL;
if ( !_libXv )
return result;
goto LABEL_9;
}
v2 = dlerror();
if ( v2 )
goto LABEL_8;
LABEL_9:
if ( *v0 )
{
dlclose(*v0);
v3 = _libXv;
*(_QWORD *)_libXv = 0LL;
}
else
{
v3 = _libXv;
}
free(v3);
result = 0LL;
_libXv = 0LL;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
void **v0; // rbx
__int64 result; // rax
char *v2; // rax
void *v3; // rdi

v0 = (void **)_libXv;
if ( !_libXv )
{
_libXv = (void *)nvalloc(32LL);
v0 = (void **)_libXv;
}
if ( *v0 )
goto LABEL_4;
*v0 = dlopen("libXv.so.1", 1);
v0 = (void **)_libXv;
if ( *(_QWORD *)_libXv )
{
dlerror();
v0[2] = dlsym(*v0, "XvQueryExtension");
v2 = dlerror();
if ( !v2 )
{
dlerror();
v0[3] = dlsym(*v0, "XvQueryAdaptors");
v2 = dlerror();
if ( !v2 )
{
v2 = dlerror();
if ( !v2 )
{
LABEL_4:
++*((_DWORD *)v0 + 2);
return 1LL;
}
}
}
LABEL_8:
nv_error_msg("libXv setup error : %s\n", v2);
v0 = (void **)_libXv;
result = 0LL;
if ( !_libXv )
return result;
goto LABEL_9;
}
v2 = dlerror();
if ( v2 )
goto LABEL_8;
LABEL_9:
if ( *v0 )
{
dlclose(*v0);
v3 = _libXv;
*(_QWORD *)_libXv = 0LL;
}
else
{
v3 = _libXv;
}
free(v3);
result = 0LL;
_libXv = 0LL;
return result;
}

original_code:
static int open_libxv(void)
{
    const char *error_str = ((void *)0);
    if ( !__libXv ) {
        __libXv = nvalloc(sizeof(__libXvInfo));
    }
    if ( __libXv->handle ) {
        __libXv->ref_count++;
        return 1;
    }
    __libXv->handle = dlopen("libXv.so.1", 0x00001);
    if ( __libXv->handle == ((void *)0) ) {
        error_str = dlerror();
        goto fail;
    }
    __libXv->XvQueryExtension =
        ({ dlerror(); dlsym(__libXv->handle, "XvQueryExtension"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libXv->XvQueryAdaptors =
        ({ dlerror(); dlsym(__libXv->handle, "XvQueryAdaptors"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libXv->ref_count++;
    return 1;
 fail:
    if ( error_str ) {
        nv_error_msg("libXv setup error : %s\n", error_str);
    }
    if ( __libXv ) {
        if ( __libXv->handle ) {
            dlclose(__libXv->handle);
            __libXv->handle = ((void *)0);
        }
        free(__libXv);
        __libXv = ((void *)0);
    }
    return 0;
}

canonical_original_code:
static int open_libxv()
{
    char *error_str = ((void *)0);
    if ( !__libXv ) {
        __libXv = nvalloc(sizeof(__libXvInfo));
    }
    if ( __libXv->handle ) {
        __libXv->ref_count++;
        return 1;
    }
    __libXv->handle = dlopen("libXv.so.1", 0x00001);
    if ( __libXv->handle == ((void *)0) ) {
        error_str = dlerror();
        goto fail;
    }
    __libXv->XvQueryExtension =
        ({ dlerror(); dlsym(__libXv->handle, "XvQueryExtension"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libXv->XvQueryAdaptors =
        ({ dlerror(); dlsym(__libXv->handle, "XvQueryAdaptors"); });
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    if ((error_str = dlerror()) != ((void *)0)) goto fail;
    __libXv->ref_count++;
    return 1;
 fail:
    if ( error_str ) {
        nv_error_msg("libXv setup error : %s\n", error_str);
    }
    if ( __libXv ) {
        if ( __libXv->handle ) {
            dlclose(__libXv->handle);
            __libXv->handle = ((void *)0);
        }
        free(__libXv);
        __libXv = ((void *)0);
    }
    return 0;
}


decompiled_code:
void *close_libxv()
{
void *result; // rax
int v1; // edx
int v2; // edx

result = _libXv;
if ( _libXv )
{
if ( *(_QWORD *)_libXv )
{
v1 = *((_DWORD *)_libXv + 2);
if ( v1 )
{
v2 = v1 - 1;
*((_DWORD *)_libXv + 2) = v2;
if ( !v2 )
result = (void *)sub_178();
}
}
}
return result;
}

canonical_decompiled_code:
void *func1()
{
void *result; // rax
int v1; // edx
int v2; // edx

result = _libXv;
if ( _libXv )
{
if ( *(_QWORD *)_libXv )
{
v1 = *((_DWORD *)_libXv + 2);
if ( v1 )
{
v2 = v1 - 1;
*((_DWORD *)_libXv + 2) = v2;
if ( !v2 )
result = (void *)sub_178();
}
}
}
return result;
}

original_code:
static void close_libxv(void)
{
    if ( __libXv && __libXv->handle && __libXv->ref_count ) {
        __libXv->ref_count--;
        if ( __libXv->ref_count == 0 ) {
            dlclose(__libXv->handle);
            __libXv->handle = ((void *)0);
            free(__libXv);
            __libXv = ((void *)0);
        }
    }
}

canonical_original_code:
static void close_libxv()
{
    if ( __libXv && __libXv->handle && __libXv->ref_count ) {
        __libXv->ref_count--;
        if ( __libXv->ref_count == 0 ) {
            dlclose(__libXv->handle);
            __libXv->handle = ((void *)0);
            free(__libXv);
            __libXv = ((void *)0);
        }
    }
}


decompiled_code:
int do_help()
{
puts("usage:");
puts("-q: query system frame lock information.");
puts("-e: enable frame lock on system.");
puts("-d: disable frame lock on system.");
return putchar(10);
}

canonical_decompiled_code:
int func0()
{
puts("usage:");
puts("-q: query system frame lock information.");
puts("-e: enable frame lock on system.");
puts("-d: disable frame lock on system.");
return putchar(10);
}

original_code:
static void do_help(void)
{
    printf("usage:\n");
    printf("-q: query system frame lock information.\n");
    printf("-e: enable frame lock on system.\n");
    printf("-d: disable frame lock on system.\n");
    printf("\n");
}

canonical_original_code:
static void do_help()
{
    printf("usage:\n");
    printf("-q: query system frame lock information.\n");
    printf("-e: enable frame lock on system.\n");
    printf("-d: disable frame lock on system.\n");
    printf("\n");
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
Display *v3; // rax
Display *v4; // r13
int v5; // er12
char *v6; // rax
const char *v7; // r14
char *v8; // rax
char *v10; // rax
unsigned int v11; // [rsp+8h] [rbp-28h] BYREF
unsigned int v12[9]; // [rsp+Ch] [rbp-24h] BYREF

v3 = XOpenDisplay(0LL);
if ( v3 )
{
v4 = v3;
v5 = XNVCTRLQueryVersion(v3, &v11, v12);
if ( v5 == 1 )
{
v6 = XDisplayName(0LL);
printf("Using NV-CONTROL extension %d.%d on %s\n\n", v11, v12[0], v6);
if ( (int)v11 <= 0 || v11 == 1 && (int)v12[0] <= 8 )
{
puts(
"The NV-CONTROL X extension is too old. Version 1.9 or above is required for configuring Frame Lock via target types.");
}
else if ( argc <= 1 || (v7 = argv[1], !strcmp(v7, "-q")) )
{
v5 = 0;
do_query((__int64)v4);
}
else
{
v5 = strcmp(v7, "-e");
if ( v5 )
{
v5 = strcmp(v7, "-d");
if ( v5 )
{
do_help();
v5 = 0;
}
else
{
do_disable(v4);
}
}
else
{
do_enable(v4);
}
}
}
else
{
v8 = XDisplayName(0LL);
v5 = 1;
printf("The NV-CONTROL X extension does not exist on '%s'.\n", v8);
}
}
else
{
v5 = 1;
v10 = XDisplayName(0LL);
printf("Cannot open display '%s'.\n", v10);
}
return v5;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
Display *v3; // rax
Display *v4; // r13
int v5; // er12
char *v6; // rax
const char *v7; // r14
char *v8; // rax
char *v10; // rax
unsigned int v11; // [rsp+8h] [rbp-28h] BYREF
unsigned int v12[9]; // [rsp+Ch] [rbp-24h] BYREF

v3 = XOpenDisplay(0LL);
if ( v3 )
{
v4 = v3;
v5 = XNVCTRLQueryVersion(v3, &v11, v12);
if ( v5 == 1 )
{
v6 = XDisplayName(0LL);
printf("Using NV-CONTROL extension %d.%d on %s\n\n", v11, v12[0], v6);
if ( (int)v11 <= 0 || v11 == 1 && (int)v12[0] <= 8 )
{
puts(
"The NV-CONTROL X extension is too old. Version 1.9 or above is required for configuring Frame Lock via target types.");
}
else if ( argc <= 1 || (v7 = argv[1], !strcmp(v7, "-q")) )
{
v5 = 0;
func1((__int64)v4);
}
else
{
v5 = strcmp(v7, "-e");
if ( v5 )
{
v5 = strcmp(v7, "-d");
if ( v5 )
{
func0();
v5 = 0;
}
else
{
func3(v4);
}
}
else
{
func2(v4);
}
}
}
else
{
v8 = XDisplayName(0LL);
v5 = 1;
printf("The NV-CONTROL X extension does not exist on '%s'.\n", v8);
}
}
else
{
v5 = 1;
v10 = XDisplayName(0LL);
printf("Cannot open display '%s'.\n", v10);
}
return v5;
}

original_code:
int main(void)
{
    gen_manpage_opts_helper(__options);
    return 0;
}

canonical_original_code:
int main()
{
    gen_manpage_opts_helper(__options);
    return 0;
}


GetAttrTypeName

decompiled_code:
const char *__fastcall GetAttrTypeName(unsigned int a1)
{
const char *result; // rax

result = "Invalid Value";
if ( a1 <= 9 )
result = CSWTCH_33[a1];
return result;
}

canonical_decompiled_code:
const char *__fastcall func0(unsigned int a1)
{
const char *result; // rax

result = "Invalid Value";
if ( a1 <= 9 )
result = CSWTCH_33[a1];
return result;
}

original_code:
static const char *GetAttrTypeName(int value)
{
    switch (value) {
        case (0): return "ATTRIBUTE_TYPE_UNKNOWN";;
        case (1): return "ATTRIBUTE_TYPE_INTEGER";;
        case (2): return "ATTRIBUTE_TYPE_BITMASK";;
        case (3): return "ATTRIBUTE_TYPE_BOOL";;
        case (4): return "ATTRIBUTE_TYPE_RANGE";;
        case (5): return "ATTRIBUTE_TYPE_INT_BITS";;
        case (6): return "ATTRIBUTE_TYPE_64BIT_INTEGER";;
        case (7): return "ATTRIBUTE_TYPE_STRING";;
        case (8): return "ATTRIBUTE_TYPE_BINARY_DATA";;
        case (9): return "ATTRIBUTE_TYPE_STRING_OPERATION";;
    default:
        return "Invalid Value";
    }
}

canonical_original_code:
static char *GetAttrTypeName(int value)
{
    switch (value) {
        case (0): return "ATTRIBUTE_TYPE_UNKNOWN";;
        case (1): return "ATTRIBUTE_TYPE_INTEGER";;
        case (2): return "ATTRIBUTE_TYPE_BITMASK";;
        case (3): return "ATTRIBUTE_TYPE_BOOL";;
        case (4): return "ATTRIBUTE_TYPE_RANGE";;
        case (5): return "ATTRIBUTE_TYPE_INT_BITS";;
        case (6): return "ATTRIBUTE_TYPE_64BIT_INTEGER";;
        case (7): return "ATTRIBUTE_TYPE_STRING";;
        case (8): return "ATTRIBUTE_TYPE_BINARY_DATA";;
        case (9): return "ATTRIBUTE_TYPE_STRING_OPERATION";;
    default:
        return "Invalid Value";
    }
}

variable_types: value int

return_type: char *


original_code:
static void print_perms(NVCTRLAttributePermissionsRec *perms)
{
    printf("%c", (perms->permissions & 0x001) ? 'R' : '_');
    printf("%c", (perms->permissions & 0x002) ? 'W' : '_');
    printf("%c", (perms->permissions & 0x004) ? 'D' : '_');
    printf("%c", (perms->permissions & 0x008) ? 'G' : '_');
    printf("%c", (perms->permissions & 0x010) ? 'F' : '_');
    printf("%c", (perms->permissions & 0x020) ? 'X' : '_');
    printf("%c", (perms->permissions & 0x040) ? 'I' : '_');
    printf("%c", (perms->permissions & 0x200) ? 'C' : '_');
    printf("%c", (perms->permissions & 0x400) ? 'T' : '_');
    printf("%c", (perms->permissions & 0x800) ? '3' : '_');
}

canonical_original_code:
static void print_perms(struct _NVCTRLAttributePermissions *perms)
{
    printf("%c", (perms->permissions & 0x001) ? 'R' : '_');
    printf("%c", (perms->permissions & 0x002) ? 'W' : '_');
    printf("%c", (perms->permissions & 0x004) ? 'D' : '_');
    printf("%c", (perms->permissions & 0x008) ? 'G' : '_');
    printf("%c", (perms->permissions & 0x010) ? 'F' : '_');
    printf("%c", (perms->permissions & 0x020) ? 'X' : '_');
    printf("%c", (perms->permissions & 0x040) ? 'I' : '_');
    printf("%c", (perms->permissions & 0x200) ? 'C' : '_');
    printf("%c", (perms->permissions & 0x400) ? 'T' : '_');
    printf("%c", (perms->permissions & 0x800) ? '3' : '_');
}

variable_types: struct _NVCTRLAttributePermissions { int type; unsigned int permissions; } *


decompiled_code:
int __fastcall print_table_entry(unsigned int *a1, __int64 a2, const char *a3)
{
const char *v3; // r12
int result; // eax
const char *v5; // rax
const char *v6; // rax

v3 = a3;
result = a1[1];
if ( result )
{
printf(" (%3d) [Perms: ", a2);
print_perms((__int64)a1);
printf("] [ ");
v6 = GetAttrTypeName(*a1);
printf("%-32s", v6);
if ( !v3 )
v3 = "Unknown";
}
else
{
if ( !a3 )
return result;
printf(" (%3d) [Perms: ", a2);
print_perms((__int64)a1);
printf("] [ ");
v5 = GetAttrTypeName(*a1);
printf("%-32s", v5);
}
return printf("] - %s\n", v3);
}

canonical_decompiled_code:
int __fastcall func2(unsigned int *a1, __int64 a2, const char *a3)
{
const char *v3; // r12
int result; // eax
const char *v5; // rax
const char *v6; // rax

v3 = a3;
result = a1[1];
if ( result )
{
printf(" (%3d) [Perms: ", a2);
func1((__int64)a1);
printf("] [ ");
v6 = func0(*a1);
printf("%-32s", v6);
if ( !v3 )
v3 = "Unknown";
}
else
{
if ( !a3 )
return result;
printf(" (%3d) [Perms: ", a2);
func1((__int64)a1);
printf("] [ ");
v5 = func0(*a1);
printf("%-32s", v5);
}
return printf("] - %s\n", v3);
}

original_code:
static void print_table_entry(NVCTRLAttributePermissionsRec *perms,
                              const int index,
                              const char *name)
{
    if ((perms->permissions == 0) && (name == ((void *)0))) {
        return;
    }
    printf("  (%3d) [Perms: ", index);
    print_perms(perms);
    printf("] [ ");
    printf("%-32s", GetAttrTypeName(perms->type));
    printf("] - %s\n", name ? name : "Unknown");
}

canonical_original_code:
static void print_table_entry(struct _NVCTRLAttributePermissions *perms, int index, char *name)
{
    if ((perms->permissions == 0) && (name == ((void *)0))) {
        return;
    }
    printf("  (%3d) [Perms: ", index);
    print_perms(perms);
    printf("] [ ");
    printf("%-32s", GetAttrTypeName(perms->type));
    printf("] - %s\n", name ? name : "Unknown");
}

variable_types: index int

variable_types:
name
char *

user_defined_types: struct _NVCTRLAttributePermissions { int type; unsigned int permissions; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
Display *v3; // rax
Display *v4; // r12
int v5; // er13
char *v6; // rax
char *v8; // rax
int v9; // er13
unsigned int i; // ebx
__int64 v11; // rbx
const char *v12; // rdx
__int64 v13; // rsi
__int64 v14; // rbx
const char *v15; // rdx
__int64 v16; // rsi
__int64 v17; // rbx
const char *v18; // rdx
__int64 v19; // rsi
__int64 v20; // rbx
char *v21; // rax
unsigned int v22; // [rsp+0h] [rbp-40h] BYREF
unsigned int v23; // [rsp+4h] [rbp-3Ch] BYREF
unsigned int v24; // [rsp+8h] [rbp-38h] BYREF
unsigned int v25; // [rsp+Ch] [rbp-34h] BYREF
void *v26; // [rsp+10h] [rbp-30h] BYREF
__int64 v27[5]; // [rsp+18h] [rbp-28h] BYREF

v3 = XOpenDisplay(0LL);
if ( v3 )
{
v4 = v3;
v5 = XNVCTRLQueryExtension(v3, &v22, &v23);
if ( v5 == 1 )
{
if ( (unsigned int)XNVCTRLQueryVersion(v4, &v24, &v25) == 1 )
{
puts("NV-CONTROL X extension present");
printf(" version : %d.%d\n", v24, v25);
printf(" event base : %d\n", v22);
printf(" error base : %d\n", v23);
v9 = v4->nscreens;
if ( v9 > 0 )
{
for ( i = 0; i != v9; ++i )
{
if ( (unsigned int)XNVCTRLIsNvScreen(v4, i) )
{
printf("Screen %d supports the NV-CONTROL X extension\n", i);
if ( (unsigned int)XNVCTRLQueryStringAttribute(v4, i, 0LL, 0LL, &v26) )
{
printf(" GPU : %s\n", (const char *)v26);
XFree(v26);
}
if ( (unsigned int)XNVCTRLQueryStringAttribute(v4, i, 0LL, 1LL, &v26) )
{
printf(" VideoBIOS : %s\n", (const char *)v26);
XFree(v26);
}
if ( (unsigned int)XNVCTRLQueryStringAttribute(v4, i, 0LL, 3LL, &v26) )
{
printf(" Driver version : %s\n", (const char *)v26);
XFree(v26);
}
}
}
}
v11 = 0LL;
puts("Attributes (Integers):");
do
{
while ( 1 )
{
v27[0] = 0LL;
if ( (unsigned int)XNVCTRLQueryAttributePermissions(v4, (unsigned int)v11, v27) )
break;
if ( ++v11 == 443 )
goto LABEL_21;
}
v12 = (const char *)attr_int_table[v11];
v13 = (unsigned int)v11++;
print_table_entry((unsigned int *)v27, v13, v12);
}
while ( v11 != 443 );
LABEL_21:
v14 = 0LL;
puts("Attributes (Strings):");
do
{
while ( 1 )
{
v27[0] = 0LL;
if ( (unsigned int)XNVCTRLQueryStringAttributePermissions(v4, (unsigned int)v14, v27) )
break;
if ( ++v14 == 58 )
goto LABEL_25;
}
v15 = attr_str_table[v14];
v16 = (unsigned int)v14++;
print_table_entry((unsigned int *)v27, v16, v15);
}
while ( v14 != 58 );
LABEL_25:
v17 = 0LL;
puts("Attributes (Binary Data):");
do
{
while ( 1 )
{
v27[0] = 0LL;
if ( (unsigned int)XNVCTRLQueryBinaryDataAttributePermissions(v4, (unsigned int)v17, v27) )
break;
if ( ++v17 == 25 )
goto LABEL_29;
}
v18 = attr_bin_table[v17];
v19 = (unsigned int)v17++;
print_table_entry((unsigned int *)v27, v19, v18);
}
while ( v17 != 25 );
LABEL_29:
v20 = 0LL;
puts("Attributes (String Operations):");
do
{
v27[0] = 0LL;
if ( (unsigned int)XNVCTRLQueryStringOperationAttributePermissions(v4, (unsigned int)v20, v27) )
print_table_entry((unsigned int *)v27, (unsigned int)v20, attr_strop_table[v20]);
++v20;
}
while ( v20 != 6 );
v5 = 0;
XCloseDisplay(v4);
}
else
{
v6 = XDisplayName(0LL);
fprintf(stderr, "The NV-CONTROL X extension does not exist on '%s'.\n", v6);
}
}
else
{
v5 = 1;
v8 = XDisplayName(0LL);
fprintf(stderr, "The NV-CONTROL X extension does not exist on '%s'.\n", v8);
}
}
else
{
v5 = 1;
v21 = XDisplayName(0LL);
fprintf(stderr, "Cannot open display '%s'.\n", v21);
}
return v5;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
Display *v3; // rax
Display *v4; // r12
int v5; // er13
char *v6; // rax
char *v8; // rax
int v9; // er13
unsigned int i; // ebx
__int64 v11; // rbx
const char *v12; // rdx
__int64 v13; // rsi
__int64 v14; // rbx
const char *v15; // rdx
__int64 v16; // rsi
__int64 v17; // rbx
const char *v18; // rdx
__int64 v19; // rsi
__int64 v20; // rbx
char *v21; // rax
unsigned int v22; // [rsp+0h] [rbp-40h] BYREF
unsigned int v23; // [rsp+4h] [rbp-3Ch] BYREF
unsigned int v24; // [rsp+8h] [rbp-38h] BYREF
unsigned int v25; // [rsp+Ch] [rbp-34h] BYREF
void *v26; // [rsp+10h] [rbp-30h] BYREF
__int64 v27[5]; // [rsp+18h] [rbp-28h] BYREF

v3 = XOpenDisplay(0LL);
if ( v3 )
{
v4 = v3;
v5 = XNVCTRLQueryExtension(v3, &v22, &v23);
if ( v5 == 1 )
{
if ( (unsigned int)XNVCTRLQueryVersion(v4, &v24, &v25) == 1 )
{
puts("NV-CONTROL X extension present");
printf(" version : %d.%d\n", v24, v25);
printf(" event base : %d\n", v22);
printf(" error base : %d\n", v23);
v9 = v4->nscreens;
if ( v9 > 0 )
{
for ( i = 0; i != v9; ++i )
{
if ( (unsigned int)XNVCTRLIsNvScreen(v4, i) )
{
printf("Screen %d supports the NV-CONTROL X extension\n", i);
if ( (unsigned int)XNVCTRLQueryStringAttribute(v4, i, 0LL, 0LL, &v26) )
{
printf(" GPU : %s\n", (const char *)v26);
XFree(v26);
}
if ( (unsigned int)XNVCTRLQueryStringAttribute(v4, i, 0LL, 1LL, &v26) )
{
printf(" VideoBIOS : %s\n", (const char *)v26);
XFree(v26);
}
if ( (unsigned int)XNVCTRLQueryStringAttribute(v4, i, 0LL, 3LL, &v26) )
{
printf(" Driver version : %s\n", (const char *)v26);
XFree(v26);
}
}
}
}
v11 = 0LL;
puts("Attributes (Integers):");
do
{
while ( 1 )
{
v27[0] = 0LL;
if ( (unsigned int)XNVCTRLQueryAttributePermissions(v4, (unsigned int)v11, v27) )
break;
if ( ++v11 == 443 )
goto LABEL_21;
}
v12 = (const char *)attr_int_table[v11];
v13 = (unsigned int)v11++;
func2((unsigned int *)v27, v13, v12);
}
while ( v11 != 443 );
LABEL_21:
v14 = 0LL;
puts("Attributes (Strings):");
do
{
while ( 1 )
{
v27[0] = 0LL;
if ( (unsigned int)XNVCTRLQueryStringAttributePermissions(v4, (unsigned int)v14, v27) )
break;
if ( ++v14 == 58 )
goto LABEL_25;
}
v15 = attr_str_table[v14];
v16 = (unsigned int)v14++;
func2((unsigned int *)v27, v16, v15);
}
while ( v14 != 58 );
LABEL_25:
v17 = 0LL;
puts("Attributes (Binary Data):");
do
{
while ( 1 )
{
v27[0] = 0LL;
if ( (unsigned int)XNVCTRLQueryBinaryDataAttributePermissions(v4, (unsigned int)v17, v27) )
break;
if ( ++v17 == 25 )
goto LABEL_29;
}
v18 = attr_bin_table[v17];
v19 = (unsigned int)v17++;
func2((unsigned int *)v27, v19, v18);
}
while ( v17 != 25 );
LABEL_29:
v20 = 0LL;
puts("Attributes (String Operations):");
do
{
v27[0] = 0LL;
if ( (unsigned int)XNVCTRLQueryStringOperationAttributePermissions(v4, (unsigned int)v20, v27) )
func2((unsigned int *)v27, (unsigned int)v20, attr_strop_table[v20]);
++v20;
}
while ( v20 != 6 );
v5 = 0;
XCloseDisplay(v4);
}
else
{
v6 = XDisplayName(0LL);
fprintf(stderr, "The NV-CONTROL X extension does not exist on '%s'.\n", v6);
}
}
else
{
v5 = 1;
v8 = XDisplayName(0LL);
fprintf(stderr, "The NV-CONTROL X extension does not exist on '%s'.\n", v8);
}
}
else
{
v5 = 1;
v21 = XDisplayName(0LL);
fprintf(stderr, "Cannot open display '%s'.\n", v21);
}
return v5;
}


loadGL

decompiled_code:
__int64 loadGL()
{
__int64 (__fastcall *v0)(const char *); // rax
__int64 (__fastcall *v1)(const char *); // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 (__fastcall *v11)(const char *); // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rax
__int64 v21; // rax
__int64 v22; // rax
__int64 v23; // rax
__int64 v24; // rax
__int64 v25; // rax
__int64 v26; // rax
__int64 v27; // rax
__int64 v28; // rax
__int64 v29; // rax
__int64 v30; // rax
__int64 v31; // rax
__int64 v32; // rax
__int64 v33; // rax
__int64 v34; // rax
__int64 v35; // rax
__int64 v36; // rax
__int64 v37; // rax
__int64 v38; // rax
__int64 v39; // rax
__int64 v40; // rax
__int64 v41; // rax
__int64 v42; // rax
__int64 v43; // rax
__int64 v44; // rax
__int64 v45; // rax
__int64 v46; // rax
__int64 v47; // rax
__int64 v48; // rax
__int64 v49; // rax
__int64 v50; // rdx
__int64 result; // rax

v0 = (__int64 (__fastcall *)(const char *))dlopen("libGL.so.1", 1);
dGL[0] = v0;
if ( !v0 )
goto LABEL_53;
v1 = (__int64 (__fastcall *)(const char *))dlsym(v0, "glXGetProcAddress");
dGL[10] = v1;
if ( !v1 )
goto LABEL_53;
v2 = v1("glGetString");
dGL[1] = (__int64 (__fastcall *)(const char *))v2;
if ( !v2 )
{
fwrite("Failed to load glGetString\n", 1uLL, 0x1BuLL, stderr);
return 0LL;
}
v3 = dGL[10]("glGetIntegerv");
dGL[3] = (__int64 (__fastcall *)(const char *))v3;
if ( !v3 )
{
fwrite("Failed to load glGetIntegerv\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}
v4 = dGL[10]("glGetStringi");
dGL[2] = (__int64 (__fastcall *)(const char *))v4;
if ( !v4 )
{
fwrite("Failed to load glGetStringi\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v5 = dGL[10]("glXCreateNewContext");
dGL[4] = (__int64 (__fastcall *)(const char *))v5;
if ( !v5 )
{
fwrite("Failed to load glXCreateNewContext\n", 1uLL, 0x23uLL, stderr);
return 0LL;
}
v6 = dGL[10]("glXDestroyContext");
dGL[5] = (__int64 (__fastcall *)(const char *))v6;
if ( !v6 )
{
fwrite("Failed to load glXDestroyContext\n", 1uLL, 0x21uLL, stderr);
return 0LL;
}
v7 = dGL[10]("glXMakeContextCurrent");
dGL[6] = (__int64 (__fastcall *)(const char *))v7;
if ( !v7 )
{
fwrite("Failed to load glXMakeContextCurrent\n", 1uLL, 0x25uLL, stderr);
return 0LL;
}
v8 = dGL[10]("glXSwapBuffers");
dGL[7] = (__int64 (__fastcall *)(const char *))v8;
if ( !v8 )
{
fwrite("Failed to load glXSwapBuffers\n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
v9 = dGL[10]("glXChooseFBConfig");
dGL[8] = (__int64 (__fastcall *)(const char *))v9;
if ( !v9 )
{
fwrite("Failed to load glXChooseFBConfig\n", 1uLL, 0x21uLL, stderr);
return 0LL;
}
v10 = dGL[10]("glXGetFBConfigAttrib");
dGL[9] = (__int64 (__fastcall *)(const char *))v10;
if ( !v10 )
{
fwrite("Failed to load glXGetFBConfigAttrib\n", 1uLL, 0x24uLL, stderr);
return 0LL;
}
v11 = (__int64 (__fastcall *)(const char *))dGL[10]("glXGetProcAddress");
dGL[10] = v11;
if ( !v11 )
{
fwrite("Failed to load glXGetProcAddress\n", 1uLL, 0x21uLL, stderr);
return 0LL;
}
v12 = v11("glXCreateWindow");
dGL[11] = (__int64 (__fastcall *)(const char *))v12;
if ( !v12 )
{
fwrite("Failed to load glXCreateWindow\n", 1uLL, 0x1FuLL, stderr);
return 0LL;
}
v13 = dGL[10]("glXGetVisualFromFBConfig");
dGL[12] = (__int64 (__fastcall *)(const char *))v13;
if ( !v13 )
{
fwrite("Failed to load glXGetVisualFromFBConfig\n", 1uLL, 0x28uLL, stderr);
return 0LL;
}
v14 = dGL[10]("glBindTexture");
dGL[13] = (__int64 (__fastcall *)(const char *))v14;
if ( !v14 )
{
fwrite("Failed to load glBindTexture\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}
v15 = dGL[10]("glBlendFunc");
dGL[14] = (__int64 (__fastcall *)(const char *))v15;
if ( !v15 )
{
fwrite("Failed to load glBlendFunc\n", 1uLL, 0x1BuLL, stderr);
return 0LL;
}
v16 = dGL[10]("glClear");
dGL[15] = (__int64 (__fastcall *)(const char *))v16;
if ( !v16 )
{
fwrite("Failed to load glClear\n", 1uLL, 0x17uLL, stderr);
return 0LL;
}
v17 = dGL[10]("glClearColor");
dGL[16] = (__int64 (__fastcall *)(const char *))v17;
if ( !v17 )
{
fwrite("Failed to load glClearColor\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v18 = dGL[10]("glClearDepth");
dGL[17] = (__int64 (__fastcall *)(const char *))v18;
if ( !v18 )
{
fwrite("Failed to load glClearDepth\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v19 = dGL[10]("glDepthFunc");
dGL[18] = (__int64 (__fastcall *)(const char *))v19;
if ( !v19 )
{
fwrite("Failed to load glDepthFunc\n", 1uLL, 0x1BuLL, stderr);
return 0LL;
}
v20 = dGL[10]("glDepthMask");
dGL[19] = (__int64 (__fastcall *)(const char *))v20;
if ( !v20 )
{
fwrite("Failed to load glDepthMask\n", 1uLL, 0x1BuLL, stderr);
return 0LL;
}
v21 = dGL[10]("glDrawArrays");
dGL[20] = (__int64 (__fastcall *)(const char *))v21;
if ( !v21 )
{
fwrite("Failed to load glDrawArrays\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v22 = dGL[10]("glDrawBuffer");
dGL[21] = (__int64 (__fastcall *)(const char *))v22;
if ( !v22 )
{
fwrite("Failed to load glDrawBuffer\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v23 = dGL[10]("glEnable");
dGL[22] = (__int64 (__fastcall *)(const char *))v23;
if ( !v23 )
{
fwrite("Failed to load glEnable\n", 1uLL, 0x18uLL, stderr);
return 0LL;
}
v24 = dGL[10]("glGenTextures");
dGL[23] = (__int64 (__fastcall *)(const char *))v24;
if ( !v24 )
{
fwrite("Failed to load glGenTextures\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}
v25 = dGL[10]("glGetError");
dGL[24] = (__int64 (__fastcall *)(const char *))v25;
if ( !v25 )
{
fwrite("Failed to load glGetError\n", 1uLL, 0x1AuLL, stderr);
return 0LL;
}
v26 = dGL[10]("glPixelStorei");
dGL[25] = (__int64 (__fastcall *)(const char *))v26;
if ( !v26 )
{
fwrite("Failed to load glPixelStorei\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}
v27 = dGL[10]("glTexImage2D");
dGL[26] = (__int64 (__fastcall *)(const char *))v27;
if ( !v27 )
{
fwrite("Failed to load glTexImage2D\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v28 = dGL[10]("glTexParameteri");
dGL[27] = (__int64 (__fastcall *)(const char *))v28;
if ( !v28 )
{
fwrite("Failed to load glTexParameteri\n", 1uLL, 0x1FuLL, stderr);
return 0LL;
}
v29 = dGL[10]("glViewport");
dGL[28] = (__int64 (__fastcall *)(const char *))v29;
if ( !v29 )
{
fwrite("Failed to load glViewport\n", 1uLL, 0x1AuLL, stderr);
return 0LL;
}
v30 = dGL[10]("glAttachShader");
dGL[29] = (__int64 (__fastcall *)(const char *))v30;
if ( !v30 )
{
fwrite("Failed to load glAttachShader\n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
v31 = dGL[10]("glBindBuffer");
dGL[30] = (__int64 (__fastcall *)(const char *))v31;
if ( !v31 )
{
fwrite("Failed to load glBindBuffer\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v32 = dGL[10]("glBindVertexArray");
dGL[31] = (__int64 (__fastcall *)(const char *))v32;
if ( !v32 )
{
fwrite("Failed to load glBindVertexArray\n", 1uLL, 0x21uLL, stderr);
return 0LL;
}
v33 = dGL[10]("glBufferData");
dGL[32] = (__int64 (__fastcall *)(const char *))v33;
if ( !v33 )
{
fwrite("Failed to load glBufferData\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v34 = dGL[10]("glCompileShader");
dGL[33] = (__int64 (__fastcall *)(const char *))v34;
if ( !v34 )
{
fwrite("Failed to load glCompileShader\n", 1uLL, 0x1FuLL, stderr);
return 0LL;
}
v35 = dGL[10]("glCreateProgram");
dGL[34] = (__int64 (__fastcall *)(const char *))v35;
if ( !v35 )
{
fwrite("Failed to load glCreateProgram\n", 1uLL, 0x1FuLL, stderr);
return 0LL;
}
v36 = dGL[10]("glCreateShader");
dGL[35] = (__int64 (__fastcall *)(const char *))v36;
if ( !v36 )
{
fwrite("Failed to load glCreateShader\n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
v37 = dGL[10]("glDeleteShader");
dGL[36] = (__int64 (__fastcall *)(const char *))v37;
if ( !v37 )
{
fwrite("Failed to load glDeleteShader\n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
v38 = dGL[10]("glEnableVertexAttribArray");
dGL[37] = (__int64 (__fastcall *)(const char *))v38;
if ( !v38 )
{
fwrite("Failed to load glEnableVertexAttribArray\n", 1uLL, 0x29uLL, stderr);
return 0LL;
}
v39 = dGL[10]("glGenBuffers");
dGL[38] = (__int64 (__fastcall *)(const char *))v39;
if ( !v39 )
{
fwrite("Failed to load glGenBuffers\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v40 = dGL[10]("glGenVertexArrays");
dGL[39] = (__int64 (__fastcall *)(const char *))v40;
if ( !v40 )
{
fwrite("Failed to load glGenVertexArrays\n", 1uLL, 0x21uLL, stderr);
return 0LL;
}
v41 = dGL[10]("glGetProgramiv");
dGL[40] = (__int64 (__fastcall *)(const char *))v41;
if ( !v41 )
{
fwrite("Failed to load glGetProgramiv\n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
v42 = dGL[10]("glGetShaderInfoLog");
dGL[41] = (__int64 (__fastcall *)(const char *))v42;
if ( !v42 )
{
fwrite("Failed to load glGetShaderInfoLog\n", 1uLL, 0x22uLL, stderr);
return 0LL;
}
v43 = dGL[10]("glGetShaderiv");
dGL[42] = (__int64 (__fastcall *)(const char *))v43;
if ( !v43 )
{
fwrite("Failed to load glGetShaderiv\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}
v44 = dGL[10]("glLinkProgram");
dGL[43] = (__int64 (__fastcall *)(const char *))v44;
if ( !v44 )
{
fwrite("Failed to load glLinkProgram\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}
v45 = dGL[10]("glShaderSource");
dGL[44] = (__int64 (__fastcall *)(const char *))v45;
if ( !v45 )
{
fwrite("Failed to load glShaderSource\n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
v46 = dGL[10]("glUniform4f");
dGL[45] = (__int64 (__fastcall *)(const char *))v46;
if ( !v46 )
{
fwrite("Failed to load glUniform4f\n", 1uLL, 0x1BuLL, stderr);
return 0LL;
}
v47 = dGL[10]("glUniformMatrix4fv");
dGL[46] = (__int64 (__fastcall *)(const char *))v47;
if ( !v47 )
{
fwrite("Failed to load glUniformMatrix4fv\n", 1uLL, 0x22uLL, stderr);
return 0LL;
}
v48 = dGL[10]("glUseProgram");
dGL[47] = (__int64 (__fastcall *)(const char *))v48;
if ( !v48 )
{
fwrite("Failed to load glUseProgram\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v49 = dGL[10]("glVertexAttribPointer");
dGL[48] = (__int64 (__fastcall *)(const char *))v49;
if ( !v49 )
{
fwrite("Failed to load glVertexAttribPointer\n", 1uLL, 0x25uLL, stderr);
return 0LL;
}
v50 = dGL[10]("glGetUniformLocation");
dGL[49] = (__int64 (__fastcall *)(const char *))v50;
result = 1LL;
if ( !v50 )
{
fwrite("Failed to load glGetUniformLocation\n", 1uLL, 0x24uLL, stderr);
LABEL_53:
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 (__fastcall *v0)(const char *); // rax
__int64 (__fastcall *v1)(const char *); // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 (__fastcall *v11)(const char *); // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rax
__int64 v21; // rax
__int64 v22; // rax
__int64 v23; // rax
__int64 v24; // rax
__int64 v25; // rax
__int64 v26; // rax
__int64 v27; // rax
__int64 v28; // rax
__int64 v29; // rax
__int64 v30; // rax
__int64 v31; // rax
__int64 v32; // rax
__int64 v33; // rax
__int64 v34; // rax
__int64 v35; // rax
__int64 v36; // rax
__int64 v37; // rax
__int64 v38; // rax
__int64 v39; // rax
__int64 v40; // rax
__int64 v41; // rax
__int64 v42; // rax
__int64 v43; // rax
__int64 v44; // rax
__int64 v45; // rax
__int64 v46; // rax
__int64 v47; // rax
__int64 v48; // rax
__int64 v49; // rax
__int64 v50; // rdx
__int64 result; // rax

v0 = (__int64 (__fastcall *)(const char *))dlopen("libGL.so.1", 1);
dGL[0] = v0;
if ( !v0 )
goto LABEL_53;
v1 = (__int64 (__fastcall *)(const char *))dlsym(v0, "glXGetProcAddress");
dGL[10] = v1;
if ( !v1 )
goto LABEL_53;
v2 = v1("glGetString");
dGL[1] = (__int64 (__fastcall *)(const char *))v2;
if ( !v2 )
{
fwrite("Failed to load glGetString\n", 1uLL, 0x1BuLL, stderr);
return 0LL;
}
v3 = dGL[10]("glGetIntegerv");
dGL[3] = (__int64 (__fastcall *)(const char *))v3;
if ( !v3 )
{
fwrite("Failed to load glGetIntegerv\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}
v4 = dGL[10]("glGetStringi");
dGL[2] = (__int64 (__fastcall *)(const char *))v4;
if ( !v4 )
{
fwrite("Failed to load glGetStringi\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v5 = dGL[10]("glXCreateNewContext");
dGL[4] = (__int64 (__fastcall *)(const char *))v5;
if ( !v5 )
{
fwrite("Failed to load glXCreateNewContext\n", 1uLL, 0x23uLL, stderr);
return 0LL;
}
v6 = dGL[10]("glXDestroyContext");
dGL[5] = (__int64 (__fastcall *)(const char *))v6;
if ( !v6 )
{
fwrite("Failed to load glXDestroyContext\n", 1uLL, 0x21uLL, stderr);
return 0LL;
}
v7 = dGL[10]("glXMakeContextCurrent");
dGL[6] = (__int64 (__fastcall *)(const char *))v7;
if ( !v7 )
{
fwrite("Failed to load glXMakeContextCurrent\n", 1uLL, 0x25uLL, stderr);
return 0LL;
}
v8 = dGL[10]("glXSwapBuffers");
dGL[7] = (__int64 (__fastcall *)(const char *))v8;
if ( !v8 )
{
fwrite("Failed to load glXSwapBuffers\n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
v9 = dGL[10]("glXChooseFBConfig");
dGL[8] = (__int64 (__fastcall *)(const char *))v9;
if ( !v9 )
{
fwrite("Failed to load glXChooseFBConfig\n", 1uLL, 0x21uLL, stderr);
return 0LL;
}
v10 = dGL[10]("glXGetFBConfigAttrib");
dGL[9] = (__int64 (__fastcall *)(const char *))v10;
if ( !v10 )
{
fwrite("Failed to load glXGetFBConfigAttrib\n", 1uLL, 0x24uLL, stderr);
return 0LL;
}
v11 = (__int64 (__fastcall *)(const char *))dGL[10]("glXGetProcAddress");
dGL[10] = v11;
if ( !v11 )
{
fwrite("Failed to load glXGetProcAddress\n", 1uLL, 0x21uLL, stderr);
return 0LL;
}
v12 = v11("glXCreateWindow");
dGL[11] = (__int64 (__fastcall *)(const char *))v12;
if ( !v12 )
{
fwrite("Failed to load glXCreateWindow\n", 1uLL, 0x1FuLL, stderr);
return 0LL;
}
v13 = dGL[10]("glXGetVisualFromFBConfig");
dGL[12] = (__int64 (__fastcall *)(const char *))v13;
if ( !v13 )
{
fwrite("Failed to load glXGetVisualFromFBConfig\n", 1uLL, 0x28uLL, stderr);
return 0LL;
}
v14 = dGL[10]("glBindTexture");
dGL[13] = (__int64 (__fastcall *)(const char *))v14;
if ( !v14 )
{
fwrite("Failed to load glBindTexture\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}
v15 = dGL[10]("glBlendFunc");
dGL[14] = (__int64 (__fastcall *)(const char *))v15;
if ( !v15 )
{
fwrite("Failed to load glBlendFunc\n", 1uLL, 0x1BuLL, stderr);
return 0LL;
}
v16 = dGL[10]("glClear");
dGL[15] = (__int64 (__fastcall *)(const char *))v16;
if ( !v16 )
{
fwrite("Failed to load glClear\n", 1uLL, 0x17uLL, stderr);
return 0LL;
}
v17 = dGL[10]("glClearColor");
dGL[16] = (__int64 (__fastcall *)(const char *))v17;
if ( !v17 )
{
fwrite("Failed to load glClearColor\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v18 = dGL[10]("glClearDepth");
dGL[17] = (__int64 (__fastcall *)(const char *))v18;
if ( !v18 )
{
fwrite("Failed to load glClearDepth\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v19 = dGL[10]("glDepthFunc");
dGL[18] = (__int64 (__fastcall *)(const char *))v19;
if ( !v19 )
{
fwrite("Failed to load glDepthFunc\n", 1uLL, 0x1BuLL, stderr);
return 0LL;
}
v20 = dGL[10]("glDepthMask");
dGL[19] = (__int64 (__fastcall *)(const char *))v20;
if ( !v20 )
{
fwrite("Failed to load glDepthMask\n", 1uLL, 0x1BuLL, stderr);
return 0LL;
}
v21 = dGL[10]("glDrawArrays");
dGL[20] = (__int64 (__fastcall *)(const char *))v21;
if ( !v21 )
{
fwrite("Failed to load glDrawArrays\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v22 = dGL[10]("glDrawBuffer");
dGL[21] = (__int64 (__fastcall *)(const char *))v22;
if ( !v22 )
{
fwrite("Failed to load glDrawBuffer\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v23 = dGL[10]("glEnable");
dGL[22] = (__int64 (__fastcall *)(const char *))v23;
if ( !v23 )
{
fwrite("Failed to load glEnable\n", 1uLL, 0x18uLL, stderr);
return 0LL;
}
v24 = dGL[10]("glGenTextures");
dGL[23] = (__int64 (__fastcall *)(const char *))v24;
if ( !v24 )
{
fwrite("Failed to load glGenTextures\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}
v25 = dGL[10]("glGetError");
dGL[24] = (__int64 (__fastcall *)(const char *))v25;
if ( !v25 )
{
fwrite("Failed to load glGetError\n", 1uLL, 0x1AuLL, stderr);
return 0LL;
}
v26 = dGL[10]("glPixelStorei");
dGL[25] = (__int64 (__fastcall *)(const char *))v26;
if ( !v26 )
{
fwrite("Failed to load glPixelStorei\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}
v27 = dGL[10]("glTexImage2D");
dGL[26] = (__int64 (__fastcall *)(const char *))v27;
if ( !v27 )
{
fwrite("Failed to load glTexImage2D\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v28 = dGL[10]("glTexParameteri");
dGL[27] = (__int64 (__fastcall *)(const char *))v28;
if ( !v28 )
{
fwrite("Failed to load glTexParameteri\n", 1uLL, 0x1FuLL, stderr);
return 0LL;
}
v29 = dGL[10]("glViewport");
dGL[28] = (__int64 (__fastcall *)(const char *))v29;
if ( !v29 )
{
fwrite("Failed to load glViewport\n", 1uLL, 0x1AuLL, stderr);
return 0LL;
}
v30 = dGL[10]("glAttachShader");
dGL[29] = (__int64 (__fastcall *)(const char *))v30;
if ( !v30 )
{
fwrite("Failed to load glAttachShader\n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
v31 = dGL[10]("glBindBuffer");
dGL[30] = (__int64 (__fastcall *)(const char *))v31;
if ( !v31 )
{
fwrite("Failed to load glBindBuffer\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v32 = dGL[10]("glBindVertexArray");
dGL[31] = (__int64 (__fastcall *)(const char *))v32;
if ( !v32 )
{
fwrite("Failed to load glBindVertexArray\n", 1uLL, 0x21uLL, stderr);
return 0LL;
}
v33 = dGL[10]("glBufferData");
dGL[32] = (__int64 (__fastcall *)(const char *))v33;
if ( !v33 )
{
fwrite("Failed to load glBufferData\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v34 = dGL[10]("glCompileShader");
dGL[33] = (__int64 (__fastcall *)(const char *))v34;
if ( !v34 )
{
fwrite("Failed to load glCompileShader\n", 1uLL, 0x1FuLL, stderr);
return 0LL;
}
v35 = dGL[10]("glCreateProgram");
dGL[34] = (__int64 (__fastcall *)(const char *))v35;
if ( !v35 )
{
fwrite("Failed to load glCreateProgram\n", 1uLL, 0x1FuLL, stderr);
return 0LL;
}
v36 = dGL[10]("glCreateShader");
dGL[35] = (__int64 (__fastcall *)(const char *))v36;
if ( !v36 )
{
fwrite("Failed to load glCreateShader\n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
v37 = dGL[10]("glDeleteShader");
dGL[36] = (__int64 (__fastcall *)(const char *))v37;
if ( !v37 )
{
fwrite("Failed to load glDeleteShader\n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
v38 = dGL[10]("glEnableVertexAttribArray");
dGL[37] = (__int64 (__fastcall *)(const char *))v38;
if ( !v38 )
{
fwrite("Failed to load glEnableVertexAttribArray\n", 1uLL, 0x29uLL, stderr);
return 0LL;
}
v39 = dGL[10]("glGenBuffers");
dGL[38] = (__int64 (__fastcall *)(const char *))v39;
if ( !v39 )
{
fwrite("Failed to load glGenBuffers\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v40 = dGL[10]("glGenVertexArrays");
dGL[39] = (__int64 (__fastcall *)(const char *))v40;
if ( !v40 )
{
fwrite("Failed to load glGenVertexArrays\n", 1uLL, 0x21uLL, stderr);
return 0LL;
}
v41 = dGL[10]("glGetProgramiv");
dGL[40] = (__int64 (__fastcall *)(const char *))v41;
if ( !v41 )
{
fwrite("Failed to load glGetProgramiv\n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
v42 = dGL[10]("glGetShaderInfoLog");
dGL[41] = (__int64 (__fastcall *)(const char *))v42;
if ( !v42 )
{
fwrite("Failed to load glGetShaderInfoLog\n", 1uLL, 0x22uLL, stderr);
return 0LL;
}
v43 = dGL[10]("glGetShaderiv");
dGL[42] = (__int64 (__fastcall *)(const char *))v43;
if ( !v43 )
{
fwrite("Failed to load glGetShaderiv\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}
v44 = dGL[10]("glLinkProgram");
dGL[43] = (__int64 (__fastcall *)(const char *))v44;
if ( !v44 )
{
fwrite("Failed to load glLinkProgram\n", 1uLL, 0x1DuLL, stderr);
return 0LL;
}
v45 = dGL[10]("glShaderSource");
dGL[44] = (__int64 (__fastcall *)(const char *))v45;
if ( !v45 )
{
fwrite("Failed to load glShaderSource\n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
v46 = dGL[10]("glUniform4f");
dGL[45] = (__int64 (__fastcall *)(const char *))v46;
if ( !v46 )
{
fwrite("Failed to load glUniform4f\n", 1uLL, 0x1BuLL, stderr);
return 0LL;
}
v47 = dGL[10]("glUniformMatrix4fv");
dGL[46] = (__int64 (__fastcall *)(const char *))v47;
if ( !v47 )
{
fwrite("Failed to load glUniformMatrix4fv\n", 1uLL, 0x22uLL, stderr);
return 0LL;
}
v48 = dGL[10]("glUseProgram");
dGL[47] = (__int64 (__fastcall *)(const char *))v48;
if ( !v48 )
{
fwrite("Failed to load glUseProgram\n", 1uLL, 0x1CuLL, stderr);
return 0LL;
}
v49 = dGL[10]("glVertexAttribPointer");
dGL[48] = (__int64 (__fastcall *)(const char *))v49;
if ( !v49 )
{
fwrite("Failed to load glVertexAttribPointer\n", 1uLL, 0x25uLL, stderr);
return 0LL;
}
v50 = dGL[10]("glGetUniformLocation");
dGL[49] = (__int64 (__fastcall *)(const char *))v50;
result = 1LL;
if ( !v50 )
{
fwrite("Failed to load glGetUniformLocation\n", 1uLL, 0x24uLL, stderr);
LABEL_53:
result = 0LL;
}
return result;
}

original_code:
GLboolean loadGL(void)
{
    dGL.handle = dlopen("libGL.so.1", 0x00001);
    if (dGL.handle == ((void *)0)) {
        return 0;
    }
    dGL.glXGetProcAddress = dlsym(dGL.handle, "glXGetProcAddress");
    if (dGL.glXGetProcAddress == ((void *)0)) {
        return 0;
    }
    dGL.glGetString = dGL.glXGetProcAddress((const GLubyte *) "glGetString"); if (dGL.glGetString == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetString" "\n"); return 0; }
    dGL.glGetIntegerv = dGL.glXGetProcAddress((const GLubyte *) "glGetIntegerv"); if (dGL.glGetIntegerv == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetIntegerv" "\n"); return 0; }
    dGL.glGetStringi = dGL.glXGetProcAddress((const GLubyte *) "glGetStringi"); if (dGL.glGetStringi == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetStringi" "\n"); return 0; }
    dGL.glXCreateNewContext = dGL.glXGetProcAddress((const GLubyte *) "glXCreateNewContext"); if (dGL.glXCreateNewContext == ((void *)0)) { fprintf(stderr, "Failed to load " "glXCreateNewContext" "\n"); return 0; }
    dGL.glXDestroyContext = dGL.glXGetProcAddress((const GLubyte *) "glXDestroyContext"); if (dGL.glXDestroyContext == ((void *)0)) { fprintf(stderr, "Failed to load " "glXDestroyContext" "\n"); return 0; }
    dGL.glXMakeContextCurrent = dGL.glXGetProcAddress((const GLubyte *) "glXMakeContextCurrent"); if (dGL.glXMakeContextCurrent == ((void *)0)) { fprintf(stderr, "Failed to load " "glXMakeContextCurrent" "\n"); return 0; }
    dGL.glXSwapBuffers = dGL.glXGetProcAddress((const GLubyte *) "glXSwapBuffers"); if (dGL.glXSwapBuffers == ((void *)0)) { fprintf(stderr, "Failed to load " "glXSwapBuffers" "\n"); return 0; }
    dGL.glXChooseFBConfig = dGL.glXGetProcAddress((const GLubyte *) "glXChooseFBConfig"); if (dGL.glXChooseFBConfig == ((void *)0)) { fprintf(stderr, "Failed to load " "glXChooseFBConfig" "\n"); return 0; }
    dGL.glXGetFBConfigAttrib = dGL.glXGetProcAddress((const GLubyte *) "glXGetFBConfigAttrib"); if (dGL.glXGetFBConfigAttrib == ((void *)0)) { fprintf(stderr, "Failed to load " "glXGetFBConfigAttrib" "\n"); return 0; }
    dGL.glXGetProcAddress = dGL.glXGetProcAddress((const GLubyte *) "glXGetProcAddress"); if (dGL.glXGetProcAddress == ((void *)0)) { fprintf(stderr, "Failed to load " "glXGetProcAddress" "\n"); return 0; }
    dGL.glXCreateWindow = dGL.glXGetProcAddress((const GLubyte *) "glXCreateWindow"); if (dGL.glXCreateWindow == ((void *)0)) { fprintf(stderr, "Failed to load " "glXCreateWindow" "\n"); return 0; }
    dGL.glXGetVisualFromFBConfig = dGL.glXGetProcAddress((const GLubyte *) "glXGetVisualFromFBConfig"); if (dGL.glXGetVisualFromFBConfig == ((void *)0)) { fprintf(stderr, "Failed to load " "glXGetVisualFromFBConfig" "\n"); return 0; }
    dGL.glBindTexture = dGL.glXGetProcAddress((const GLubyte *) "glBindTexture"); if (dGL.glBindTexture == ((void *)0)) { fprintf(stderr, "Failed to load " "glBindTexture" "\n"); return 0; }
    dGL.glBlendFunc = dGL.glXGetProcAddress((const GLubyte *) "glBlendFunc"); if (dGL.glBlendFunc == ((void *)0)) { fprintf(stderr, "Failed to load " "glBlendFunc" "\n"); return 0; }
    dGL.glClear = dGL.glXGetProcAddress((const GLubyte *) "glClear"); if (dGL.glClear == ((void *)0)) { fprintf(stderr, "Failed to load " "glClear" "\n"); return 0; }
    dGL.glClearColor = dGL.glXGetProcAddress((const GLubyte *) "glClearColor"); if (dGL.glClearColor == ((void *)0)) { fprintf(stderr, "Failed to load " "glClearColor" "\n"); return 0; }
    dGL.glClearDepth = dGL.glXGetProcAddress((const GLubyte *) "glClearDepth"); if (dGL.glClearDepth == ((void *)0)) { fprintf(stderr, "Failed to load " "glClearDepth" "\n"); return 0; }
    dGL.glDepthFunc = dGL.glXGetProcAddress((const GLubyte *) "glDepthFunc"); if (dGL.glDepthFunc == ((void *)0)) { fprintf(stderr, "Failed to load " "glDepthFunc" "\n"); return 0; }
    dGL.glDepthMask = dGL.glXGetProcAddress((const GLubyte *) "glDepthMask"); if (dGL.glDepthMask == ((void *)0)) { fprintf(stderr, "Failed to load " "glDepthMask" "\n"); return 0; }
    dGL.glDrawArrays = dGL.glXGetProcAddress((const GLubyte *) "glDrawArrays"); if (dGL.glDrawArrays == ((void *)0)) { fprintf(stderr, "Failed to load " "glDrawArrays" "\n"); return 0; }
    dGL.glDrawBuffer = dGL.glXGetProcAddress((const GLubyte *) "glDrawBuffer"); if (dGL.glDrawBuffer == ((void *)0)) { fprintf(stderr, "Failed to load " "glDrawBuffer" "\n"); return 0; }
    dGL.glEnable = dGL.glXGetProcAddress((const GLubyte *) "glEnable"); if (dGL.glEnable == ((void *)0)) { fprintf(stderr, "Failed to load " "glEnable" "\n"); return 0; }
    dGL.glGenTextures = dGL.glXGetProcAddress((const GLubyte *) "glGenTextures"); if (dGL.glGenTextures == ((void *)0)) { fprintf(stderr, "Failed to load " "glGenTextures" "\n"); return 0; }
    dGL.glGetError = dGL.glXGetProcAddress((const GLubyte *) "glGetError"); if (dGL.glGetError == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetError" "\n"); return 0; }
    dGL.glPixelStorei = dGL.glXGetProcAddress((const GLubyte *) "glPixelStorei"); if (dGL.glPixelStorei == ((void *)0)) { fprintf(stderr, "Failed to load " "glPixelStorei" "\n"); return 0; }
    dGL.glTexImage2D = dGL.glXGetProcAddress((const GLubyte *) "glTexImage2D"); if (dGL.glTexImage2D == ((void *)0)) { fprintf(stderr, "Failed to load " "glTexImage2D" "\n"); return 0; }
    dGL.glTexParameteri = dGL.glXGetProcAddress((const GLubyte *) "glTexParameteri"); if (dGL.glTexParameteri == ((void *)0)) { fprintf(stderr, "Failed to load " "glTexParameteri" "\n"); return 0; }
    dGL.glViewport = dGL.glXGetProcAddress((const GLubyte *) "glViewport"); if (dGL.glViewport == ((void *)0)) { fprintf(stderr, "Failed to load " "glViewport" "\n"); return 0; }
    dGL.glAttachShader = dGL.glXGetProcAddress((const GLubyte *) "glAttachShader"); if (dGL.glAttachShader == ((void *)0)) { fprintf(stderr, "Failed to load " "glAttachShader" "\n"); return 0; }
    dGL.glBindBuffer = dGL.glXGetProcAddress((const GLubyte *) "glBindBuffer"); if (dGL.glBindBuffer == ((void *)0)) { fprintf(stderr, "Failed to load " "glBindBuffer" "\n"); return 0; }
    dGL.glBindVertexArray = dGL.glXGetProcAddress((const GLubyte *) "glBindVertexArray"); if (dGL.glBindVertexArray == ((void *)0)) { fprintf(stderr, "Failed to load " "glBindVertexArray" "\n"); return 0; }
    dGL.glBufferData = dGL.glXGetProcAddress((const GLubyte *) "glBufferData"); if (dGL.glBufferData == ((void *)0)) { fprintf(stderr, "Failed to load " "glBufferData" "\n"); return 0; }
    dGL.glCompileShader = dGL.glXGetProcAddress((const GLubyte *) "glCompileShader"); if (dGL.glCompileShader == ((void *)0)) { fprintf(stderr, "Failed to load " "glCompileShader" "\n"); return 0; }
    dGL.glCreateProgram = dGL.glXGetProcAddress((const GLubyte *) "glCreateProgram"); if (dGL.glCreateProgram == ((void *)0)) { fprintf(stderr, "Failed to load " "glCreateProgram" "\n"); return 0; }
    dGL.glCreateShader = dGL.glXGetProcAddress((const GLubyte *) "glCreateShader"); if (dGL.glCreateShader == ((void *)0)) { fprintf(stderr, "Failed to load " "glCreateShader" "\n"); return 0; }
    dGL.glDeleteShader = dGL.glXGetProcAddress((const GLubyte *) "glDeleteShader"); if (dGL.glDeleteShader == ((void *)0)) { fprintf(stderr, "Failed to load " "glDeleteShader" "\n"); return 0; }
    dGL.glEnableVertexAttribArray = dGL.glXGetProcAddress((const GLubyte *) "glEnableVertexAttribArray"); if (dGL.glEnableVertexAttribArray == ((void *)0)) { fprintf(stderr, "Failed to load " "glEnableVertexAttribArray" "\n"); return 0; }
    dGL.glGenBuffers = dGL.glXGetProcAddress((const GLubyte *) "glGenBuffers"); if (dGL.glGenBuffers == ((void *)0)) { fprintf(stderr, "Failed to load " "glGenBuffers" "\n"); return 0; }
    dGL.glGenVertexArrays = dGL.glXGetProcAddress((const GLubyte *) "glGenVertexArrays"); if (dGL.glGenVertexArrays == ((void *)0)) { fprintf(stderr, "Failed to load " "glGenVertexArrays" "\n"); return 0; }
    dGL.glGetProgramiv = dGL.glXGetProcAddress((const GLubyte *) "glGetProgramiv"); if (dGL.glGetProgramiv == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetProgramiv" "\n"); return 0; }
    dGL.glGetShaderInfoLog = dGL.glXGetProcAddress((const GLubyte *) "glGetShaderInfoLog"); if (dGL.glGetShaderInfoLog == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetShaderInfoLog" "\n"); return 0; }
    dGL.glGetShaderiv = dGL.glXGetProcAddress((const GLubyte *) "glGetShaderiv"); if (dGL.glGetShaderiv == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetShaderiv" "\n"); return 0; }
    dGL.glLinkProgram = dGL.glXGetProcAddress((const GLubyte *) "glLinkProgram"); if (dGL.glLinkProgram == ((void *)0)) { fprintf(stderr, "Failed to load " "glLinkProgram" "\n"); return 0; }
    dGL.glShaderSource = dGL.glXGetProcAddress((const GLubyte *) "glShaderSource"); if (dGL.glShaderSource == ((void *)0)) { fprintf(stderr, "Failed to load " "glShaderSource" "\n"); return 0; }
    dGL.glUniform4f = dGL.glXGetProcAddress((const GLubyte *) "glUniform4f"); if (dGL.glUniform4f == ((void *)0)) { fprintf(stderr, "Failed to load " "glUniform4f" "\n"); return 0; }
    dGL.glUniformMatrix4fv = dGL.glXGetProcAddress((const GLubyte *) "glUniformMatrix4fv"); if (dGL.glUniformMatrix4fv == ((void *)0)) { fprintf(stderr, "Failed to load " "glUniformMatrix4fv" "\n"); return 0; }
    dGL.glUseProgram = dGL.glXGetProcAddress((const GLubyte *) "glUseProgram"); if (dGL.glUseProgram == ((void *)0)) { fprintf(stderr, "Failed to load " "glUseProgram" "\n"); return 0; }
    dGL.glVertexAttribPointer = dGL.glXGetProcAddress((const GLubyte *) "glVertexAttribPointer"); if (dGL.glVertexAttribPointer == ((void *)0)) { fprintf(stderr, "Failed to load " "glVertexAttribPointer" "\n"); return 0; }
    dGL.glGetUniformLocation = dGL.glXGetProcAddress((const GLubyte *) "glGetUniformLocation"); if (dGL.glGetUniformLocation == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetUniformLocation" "\n"); return 0; }
    return 1;
}

canonical_original_code:
unsigned char loadGL()
{
    dGL.handle = dlopen("libGL.so.1", 0x00001);
    if (dGL.handle == ((void *)0)) {
        return 0;
    }
    dGL.glXGetProcAddress = dlsym(dGL.handle, "glXGetProcAddress");
    if (dGL.glXGetProcAddress == ((void *)0)) {
        return 0;
    }
    dGL.glGetString = dGL.glXGetProcAddress((unsigned char *) "glGetString"); if (dGL.glGetString == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetString" "\n"); return 0; }
    dGL.glGetIntegerv = dGL.glXGetProcAddress((unsigned char *) "glGetIntegerv"); if (dGL.glGetIntegerv == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetIntegerv" "\n"); return 0; }
    dGL.glGetStringi = dGL.glXGetProcAddress((unsigned char *) "glGetStringi"); if (dGL.glGetStringi == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetStringi" "\n"); return 0; }
    dGL.glXCreateNewContext = dGL.glXGetProcAddress((unsigned char *) "glXCreateNewContext"); if (dGL.glXCreateNewContext == ((void *)0)) { fprintf(stderr, "Failed to load " "glXCreateNewContext" "\n"); return 0; }
    dGL.glXDestroyContext = dGL.glXGetProcAddress((unsigned char *) "glXDestroyContext"); if (dGL.glXDestroyContext == ((void *)0)) { fprintf(stderr, "Failed to load " "glXDestroyContext" "\n"); return 0; }
    dGL.glXMakeContextCurrent = dGL.glXGetProcAddress((unsigned char *) "glXMakeContextCurrent"); if (dGL.glXMakeContextCurrent == ((void *)0)) { fprintf(stderr, "Failed to load " "glXMakeContextCurrent" "\n"); return 0; }
    dGL.glXSwapBuffers = dGL.glXGetProcAddress((unsigned char *) "glXSwapBuffers"); if (dGL.glXSwapBuffers == ((void *)0)) { fprintf(stderr, "Failed to load " "glXSwapBuffers" "\n"); return 0; }
    dGL.glXChooseFBConfig = dGL.glXGetProcAddress((unsigned char *) "glXChooseFBConfig"); if (dGL.glXChooseFBConfig == ((void *)0)) { fprintf(stderr, "Failed to load " "glXChooseFBConfig" "\n"); return 0; }
    dGL.glXGetFBConfigAttrib = dGL.glXGetProcAddress((unsigned char *) "glXGetFBConfigAttrib"); if (dGL.glXGetFBConfigAttrib == ((void *)0)) { fprintf(stderr, "Failed to load " "glXGetFBConfigAttrib" "\n"); return 0; }
    dGL.glXGetProcAddress = dGL.glXGetProcAddress((unsigned char *) "glXGetProcAddress"); if (dGL.glXGetProcAddress == ((void *)0)) { fprintf(stderr, "Failed to load " "glXGetProcAddress" "\n"); return 0; }
    dGL.glXCreateWindow = dGL.glXGetProcAddress((unsigned char *) "glXCreateWindow"); if (dGL.glXCreateWindow == ((void *)0)) { fprintf(stderr, "Failed to load " "glXCreateWindow" "\n"); return 0; }
    dGL.glXGetVisualFromFBConfig = dGL.glXGetProcAddress((unsigned char *) "glXGetVisualFromFBConfig"); if (dGL.glXGetVisualFromFBConfig == ((void *)0)) { fprintf(stderr, "Failed to load " "glXGetVisualFromFBConfig" "\n"); return 0; }
    dGL.glBindTexture = dGL.glXGetProcAddress((unsigned char *) "glBindTexture"); if (dGL.glBindTexture == ((void *)0)) { fprintf(stderr, "Failed to load " "glBindTexture" "\n"); return 0; }
    dGL.glBlendFunc = dGL.glXGetProcAddress((unsigned char *) "glBlendFunc"); if (dGL.glBlendFunc == ((void *)0)) { fprintf(stderr, "Failed to load " "glBlendFunc" "\n"); return 0; }
    dGL.glClear = dGL.glXGetProcAddress((unsigned char *) "glClear"); if (dGL.glClear == ((void *)0)) { fprintf(stderr, "Failed to load " "glClear" "\n"); return 0; }
    dGL.glClearColor = dGL.glXGetProcAddress((unsigned char *) "glClearColor"); if (dGL.glClearColor == ((void *)0)) { fprintf(stderr, "Failed to load " "glClearColor" "\n"); return 0; }
    dGL.glClearDepth = dGL.glXGetProcAddress((unsigned char *) "glClearDepth"); if (dGL.glClearDepth == ((void *)0)) { fprintf(stderr, "Failed to load " "glClearDepth" "\n"); return 0; }
    dGL.glDepthFunc = dGL.glXGetProcAddress((unsigned char *) "glDepthFunc"); if (dGL.glDepthFunc == ((void *)0)) { fprintf(stderr, "Failed to load " "glDepthFunc" "\n"); return 0; }
    dGL.glDepthMask = dGL.glXGetProcAddress((unsigned char *) "glDepthMask"); if (dGL.glDepthMask == ((void *)0)) { fprintf(stderr, "Failed to load " "glDepthMask" "\n"); return 0; }
    dGL.glDrawArrays = dGL.glXGetProcAddress((unsigned char *) "glDrawArrays"); if (dGL.glDrawArrays == ((void *)0)) { fprintf(stderr, "Failed to load " "glDrawArrays" "\n"); return 0; }
    dGL.glDrawBuffer = dGL.glXGetProcAddress((unsigned char *) "glDrawBuffer"); if (dGL.glDrawBuffer == ((void *)0)) { fprintf(stderr, "Failed to load " "glDrawBuffer" "\n"); return 0; }
    dGL.glEnable = dGL.glXGetProcAddress((unsigned char *) "glEnable"); if (dGL.glEnable == ((void *)0)) { fprintf(stderr, "Failed to load " "glEnable" "\n"); return 0; }
    dGL.glGenTextures = dGL.glXGetProcAddress((unsigned char *) "glGenTextures"); if (dGL.glGenTextures == ((void *)0)) { fprintf(stderr, "Failed to load " "glGenTextures" "\n"); return 0; }
    dGL.glGetError = dGL.glXGetProcAddress((unsigned char *) "glGetError"); if (dGL.glGetError == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetError" "\n"); return 0; }
    dGL.glPixelStorei = dGL.glXGetProcAddress((unsigned char *) "glPixelStorei"); if (dGL.glPixelStorei == ((void *)0)) { fprintf(stderr, "Failed to load " "glPixelStorei" "\n"); return 0; }
    dGL.glTexImage2D = dGL.glXGetProcAddress((unsigned char *) "glTexImage2D"); if (dGL.glTexImage2D == ((void *)0)) { fprintf(stderr, "Failed to load " "glTexImage2D" "\n"); return 0; }
    dGL.glTexParameteri = dGL.glXGetProcAddress((unsigned char *) "glTexParameteri"); if (dGL.glTexParameteri == ((void *)0)) { fprintf(stderr, "Failed to load " "glTexParameteri" "\n"); return 0; }
    dGL.glViewport = dGL.glXGetProcAddress((unsigned char *) "glViewport"); if (dGL.glViewport == ((void *)0)) { fprintf(stderr, "Failed to load " "glViewport" "\n"); return 0; }
    dGL.glAttachShader = dGL.glXGetProcAddress((unsigned char *) "glAttachShader"); if (dGL.glAttachShader == ((void *)0)) { fprintf(stderr, "Failed to load " "glAttachShader" "\n"); return 0; }
    dGL.glBindBuffer = dGL.glXGetProcAddress((unsigned char *) "glBindBuffer"); if (dGL.glBindBuffer == ((void *)0)) { fprintf(stderr, "Failed to load " "glBindBuffer" "\n"); return 0; }
    dGL.glBindVertexArray = dGL.glXGetProcAddress((unsigned char *) "glBindVertexArray"); if (dGL.glBindVertexArray == ((void *)0)) { fprintf(stderr, "Failed to load " "glBindVertexArray" "\n"); return 0; }
    dGL.glBufferData = dGL.glXGetProcAddress((unsigned char *) "glBufferData"); if (dGL.glBufferData == ((void *)0)) { fprintf(stderr, "Failed to load " "glBufferData" "\n"); return 0; }
    dGL.glCompileShader = dGL.glXGetProcAddress((unsigned char *) "glCompileShader"); if (dGL.glCompileShader == ((void *)0)) { fprintf(stderr, "Failed to load " "glCompileShader" "\n"); return 0; }
    dGL.glCreateProgram = dGL.glXGetProcAddress((unsigned char *) "glCreateProgram"); if (dGL.glCreateProgram == ((void *)0)) { fprintf(stderr, "Failed to load " "glCreateProgram" "\n"); return 0; }
    dGL.glCreateShader = dGL.glXGetProcAddress((unsigned char *) "glCreateShader"); if (dGL.glCreateShader == ((void *)0)) { fprintf(stderr, "Failed to load " "glCreateShader" "\n"); return 0; }
    dGL.glDeleteShader = dGL.glXGetProcAddress((unsigned char *) "glDeleteShader"); if (dGL.glDeleteShader == ((void *)0)) { fprintf(stderr, "Failed to load " "glDeleteShader" "\n"); return 0; }
    dGL.glEnableVertexAttribArray = dGL.glXGetProcAddress((unsigned char *) "glEnableVertexAttribArray"); if (dGL.glEnableVertexAttribArray == ((void *)0)) { fprintf(stderr, "Failed to load " "glEnableVertexAttribArray" "\n"); return 0; }
    dGL.glGenBuffers = dGL.glXGetProcAddress((unsigned char *) "glGenBuffers"); if (dGL.glGenBuffers == ((void *)0)) { fprintf(stderr, "Failed to load " "glGenBuffers" "\n"); return 0; }
    dGL.glGenVertexArrays = dGL.glXGetProcAddress((unsigned char *) "glGenVertexArrays"); if (dGL.glGenVertexArrays == ((void *)0)) { fprintf(stderr, "Failed to load " "glGenVertexArrays" "\n"); return 0; }
    dGL.glGetProgramiv = dGL.glXGetProcAddress((unsigned char *) "glGetProgramiv"); if (dGL.glGetProgramiv == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetProgramiv" "\n"); return 0; }
    dGL.glGetShaderInfoLog = dGL.glXGetProcAddress((unsigned char *) "glGetShaderInfoLog"); if (dGL.glGetShaderInfoLog == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetShaderInfoLog" "\n"); return 0; }
    dGL.glGetShaderiv = dGL.glXGetProcAddress((unsigned char *) "glGetShaderiv"); if (dGL.glGetShaderiv == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetShaderiv" "\n"); return 0; }
    dGL.glLinkProgram = dGL.glXGetProcAddress((unsigned char *) "glLinkProgram"); if (dGL.glLinkProgram == ((void *)0)) { fprintf(stderr, "Failed to load " "glLinkProgram" "\n"); return 0; }
    dGL.glShaderSource = dGL.glXGetProcAddress((unsigned char *) "glShaderSource"); if (dGL.glShaderSource == ((void *)0)) { fprintf(stderr, "Failed to load " "glShaderSource" "\n"); return 0; }
    dGL.glUniform4f = dGL.glXGetProcAddress((unsigned char *) "glUniform4f"); if (dGL.glUniform4f == ((void *)0)) { fprintf(stderr, "Failed to load " "glUniform4f" "\n"); return 0; }
    dGL.glUniformMatrix4fv = dGL.glXGetProcAddress((unsigned char *) "glUniformMatrix4fv"); if (dGL.glUniformMatrix4fv == ((void *)0)) { fprintf(stderr, "Failed to load " "glUniformMatrix4fv" "\n"); return 0; }
    dGL.glUseProgram = dGL.glXGetProcAddress((unsigned char *) "glUseProgram"); if (dGL.glUseProgram == ((void *)0)) { fprintf(stderr, "Failed to load " "glUseProgram" "\n"); return 0; }
    dGL.glVertexAttribPointer = dGL.glXGetProcAddress((unsigned char *) "glVertexAttribPointer"); if (dGL.glVertexAttribPointer == ((void *)0)) { fprintf(stderr, "Failed to load " "glVertexAttribPointer" "\n"); return 0; }
    dGL.glGetUniformLocation = dGL.glXGetProcAddress((unsigned char *) "glGetUniformLocation"); if (dGL.glGetUniformLocation == ((void *)0)) { fprintf(stderr, "Failed to load " "glGetUniformLocation" "\n"); return 0; }
    return 1;
}

return_type: unsigned char


closeDynamicGL

decompiled_code:
int closeDynamicGL()
{
return dlclose(dGL[0]);
}

canonical_decompiled_code:
int func1()
{
return dlclose(dGL[0]);
}

original_code:
void closeDynamicGL(void)
{
    dlclose(dGL.handle);
}

canonical_original_code:
void closeDynamicGL()
{
    dlclose(dGL.handle);
}


decompiled_code:
const char *__fastcall get_transform_name(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 0:
result = "Normal";
break;
case 1:
result = "90";
break;
case 2:
result = "180";
break;
case 3:
result = "270";
break;
case 4:
result = "Flipped";
break;
case 5:
result = "Flipped 90";
break;
case 6:
result = "Flipped 180";
break;
case 7:
result = "Flipped 270";
break;
default:
result = "Unknown";
break;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func0(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 0:
result = "Normal";
break;
case 1:
result = "90";
break;
case 2:
result = "180";
break;
case 3:
result = "270";
break;
case 4:
result = "Flipped";
break;
case 5:
result = "Flipped 90";
break;
case 6:
result = "Flipped 180";
break;
case 7:
result = "Flipped 270";
break;
default:
result = "Unknown";
break;
}
return result;
}

original_code:
static const char *get_transform_name(int32_t transform)
{
    const char *transform_name = ((void *)0);
    switch (transform) {
        case WL_OUTPUT_TRANSFORM_NORMAL:
            transform_name = "Normal";
            break;
        case WL_OUTPUT_TRANSFORM_90:
            transform_name = "90";
            break;
        case WL_OUTPUT_TRANSFORM_180:
            transform_name = "180";
            break;
        case WL_OUTPUT_TRANSFORM_270:
            transform_name = "270";
            break;
        case WL_OUTPUT_TRANSFORM_FLIPPED:
            transform_name = "Flipped";
            break;
        case WL_OUTPUT_TRANSFORM_FLIPPED_90:
            transform_name = "Flipped 90";
            break;
        case WL_OUTPUT_TRANSFORM_FLIPPED_180:
            transform_name = "Flipped 180";
            break;
        case WL_OUTPUT_TRANSFORM_FLIPPED_270:
            transform_name = "Flipped 270";
            break;
        default:
            transform_name = "Unknown";
    }
    return transform_name;
}

canonical_original_code:
static char *get_transform_name(int transform)
{
    char *transform_name = ((void *)0);
    switch (transform) {
        case WL_OUTPUT_TRANSFORM_NORMAL:
            transform_name = "Normal";
            break;
        case WL_OUTPUT_TRANSFORM_90:
            transform_name = "90";
            break;
        case WL_OUTPUT_TRANSFORM_180:
            transform_name = "180";
            break;
        case WL_OUTPUT_TRANSFORM_270:
            transform_name = "270";
            break;
        case WL_OUTPUT_TRANSFORM_FLIPPED:
            transform_name = "Flipped";
            break;
        case WL_OUTPUT_TRANSFORM_FLIPPED_90:
            transform_name = "Flipped 90";
            break;
        case WL_OUTPUT_TRANSFORM_FLIPPED_180:
            transform_name = "Flipped 180";
            break;
        case WL_OUTPUT_TRANSFORM_FLIPPED_270:
            transform_name = "Flipped 270";
            break;
        default:
            transform_name = "Unknown";
    }
    return transform_name;
}

variable_types: transform int


decompiled_code:
__int64 get_wayland_display()
{
return wl_display_connect(0LL);
}

canonical_decompiled_code:
__int64 func11()
{
return wl_display_connect(0LL);
}

original_code:
void *get_wayland_display(void)
{
    return (void*) wl_display_connect(((void *)0));
}

canonical_original_code:
void *get_wayland_display()
{
    return (void *) wl_display_connect(((void *)0));
}

return_type: void *


decompiled_code:
__int64 __fastcall jsonp_malloc(__int64 a1)
{
__int64 result; // rax

if ( a1 )
result = do_malloc();
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 result; // rax

if ( a1 )
result = do_malloc();
else
result = 0LL;
return result;
}

original_code:
void *jsonp_malloc(size_t size)
{
    if(!size)
        return ((void *)0);
    return (*do_malloc)(size);
}

canonical_original_code:
void *jsonp_malloc(unsigned long size)
{
    if(!size)
        return ((void *)0);
    return (*do_malloc)(size);
}

variable_types:
size
unsigned long


decompiled_code:
__int64 __fastcall jsonp_free(__int64 a1)
{
__int64 result; // rax

if ( a1 )
result = do_free();
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 result; // rax

if ( a1 )
result = do_free();
return result;
}

original_code:
void jsonp_free(void *ptr)
{
    if(!ptr)
        return;
    (*do_free)(ptr);
}

variable_types:
ptr
void *


decompiled_code:
__int64 print_version()
{
nv_msg(0LL, &unk_7BB);
nv_msg(0LL, "nvidia-settings: version 535.54.03");
nv_msg(" ", "The NVIDIA Settings tool.");
nv_msg(0LL, &unk_7BB);
nv_msg(" ", "This program is used to configure the NVIDIA Linux graphics driver.");
nv_msg(" ", "For more detail, please see the nvidia-settings(1) man page.");
return nv_msg(0LL, &unk_7BB);
}

canonical_decompiled_code:
__int64 func0()
{
nv_msg(0LL, &unk_7BB);
nv_msg(0LL, "nvidia-settings: version 535.54.03");
nv_msg(" ", "The NVIDIA Settings tool.");
nv_msg(0LL, &unk_7BB);
nv_msg(" ", "This program is used to configure the NVIDIA Linux graphics driver.");
nv_msg(" ", "For more detail, please see the nvidia-settings(1) man page.");
return nv_msg(0LL, &unk_7BB);
}

original_code:
static void print_version(void)
{
    nv_msg(((void *)0), "");
    nv_msg(((void *)0), "nvidia-settings" ":  version " "535.54.03");
    nv_msg("  ", "The NVIDIA Settings tool.");
    nv_msg(((void *)0), "");
    nv_msg("  ", "This program is used to configure the "
           "NVIDIA Linux graphics driver.");
    nv_msg("  ", "For more detail, please see the nvidia-settings(1) "
           "man page.");
    nv_msg(((void *)0), "");
}

canonical_original_code:
static void print_version()
{
    nv_msg(((void *)0), "");
    nv_msg(((void *)0), "nvidia-settings" ":  version " "535.54.03");
    nv_msg("  ", "The NVIDIA Settings tool.");
    nv_msg(((void *)0), "");
    nv_msg("  ", "This program is used to configure the "
           "NVIDIA Linux graphics driver.");
    nv_msg("  ", "For more detail, please see the nvidia-settings(1) "
           "man page.");
    nv_msg(((void *)0), "");
}


decompiled_code:
__int64 print_help()
{
print_version();
nv_msg(0LL, &unk_7BB);
nv_msg(0LL, "nvidia-settings [options]");
nv_msg(0LL, &unk_7BB);
return nvgetopt_print_help(&_options, 0LL, print_help_helper);
}

canonical_decompiled_code:
__int64 func1()
{
func0();
nv_msg(0LL, &unk_7BB);
nv_msg(0LL, "nvidia-settings [options]");
nv_msg(0LL, &unk_7BB);
return nvgetopt_print_help(&_options, 0LL, print_help_helper);
}

original_code:
void print_help(void)
{
    print_version();
    nv_msg(((void *)0), "");
    nv_msg(((void *)0), "nvidia-settings [options]");
    nv_msg(((void *)0), "");
    nvgetopt_print_help(__options, 0, print_help_helper);
}

canonical_original_code:
void print_help()
{
    print_version();
    nv_msg(((void *)0), "");
    nv_msg(((void *)0), "nvidia-settings [options]");
    nv_msg(((void *)0), "");
    nvgetopt_print_help(__options, 0, print_help_helper);
}


decompiled_code:
__int64 __fastcall print_help_helper(const char *a1, const char *a2)
{
nv_msg(" ", "%s", a1);
nv_msg_preserve_whitespace(" ", "%s", a2);
return nv_msg(0LL, (const char *)&unk_7BB);
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, const char *a2)
{
nv_msg(" ", "%s", a1);
nv_msg_preserve_whitespace(" ", "%s", a2);
return nv_msg(0LL, (const char *)&unk_7BB);
}

original_code:
static void print_help_helper(const char *name, const char *description)
{
    nv_msg("  ", "%s", name);
    nv_msg_preserve_whitespace("      ", "%s", description);
    nv_msg(((void *)0), "");
}

canonical_original_code:
static void print_help_helper(char *name, char *description)
{
    nv_msg("  ", "%s", name);
    nv_msg_preserve_whitespace("      ", "%s", description);
    nv_msg(((void *)0), "");
}

variable_types:
description
char *


decompiled_code:
__int64 __fastcall print_attribute_help(char *s1)
{
int v1; // er14
__int64 result; // rax
int v3; // er13
char *v4; // rbx
int v5; // er12
unsigned int v6; // eax
char v7; // al
char v8; // al
const char *v9; // rdx
int v10; // eax
int v11; // [rsp+4h] [rbp-3Ch]
const char *v12; // [rsp+8h] [rbp-38h]

if ( !strcasecmp(s1, "all") )
{
v1 = 1;
nv_msg(0LL, (const char *)&unk_7BB);
result = attributeTableLen;
v3 = 1;
if ( attributeTableLen <= 0 )
return result;
}
else
{
v1 = strcasecmp(s1, "list");
if ( v1 )
{
nv_msg(0LL, (const char *)&unk_7BB);
if ( attributeTableLen <= 0 )
return nv_error_msg("Unrecognized attribute name '%s'.\n", s1);
v1 = 1;
v3 = 0;
}
else
{
result = nv_msg(0LL, (const char *)&unk_7BB);
v3 = 1;
if ( attributeTableLen <= 0 )
return result;
}
}
v11 = 0;
v4 = (char *)&attributeTable;
v5 = 0;
do
{
v9 = *(const char **)v4;
if ( v3 || (v12 = *(const char **)v4, v10 = strcasecmp(s1, *(const char **)v4), v9 = v12, !v10) )
{
if ( !v1 )
{
result = nv_msg(0LL, "%s", v9);
if ( !v3 )
return result;
LABEL_29:
v11 = v3;
goto LABEL_30;
}
nv_msg(0LL, "Attribute '%s':", v9);
v6 = *((_DWORD *)v4 + 3);
if ( v6 == 3 )
{
nv_msg(0LL, " - Attribute value is binary data.");
}
else if ( v6 > 3 )
{
if ( v6 == 4 )
{
nv_msg(0LL, " - Attribute value is a color.");
v7 = v4[16];
if ( (v7 & 1) == 0 )
{
LABEL_10:
if ( (v7 & 2) == 0 )
goto LABEL_11;
goto LABEL_41;
}
LABEL_40:
nv_msg(0LL, " - Is GUI attribute.");
v7 = v4[16];
if ( (v7 & 2) == 0 )
{
LABEL_11:
if ( (v7 & 8) == 0 )
goto LABEL_12;
goto LABEL_42;
}
LABEL_41:
nv_msg(0LL, " - Is Frame Lock attribute.");
v7 = v4[16];
if ( (v7 & 8) == 0 )
{
LABEL_12:
if ( (v7 & 0x10) == 0 )
goto LABEL_13;
LABEL_43:
nv_msg(0LL, " - Attribute not queried in 'query all'.");
LABEL_13:
if ( !*((_DWORD *)v4 + 3) )
{
v8 = v4[20];
if ( (v8 & 1) != 0 )
{
nv_msg(0LL, " - Attribute value is in units of Centihertz (1/100Hz).");
v8 = v4[20];
}
if ( (v8 & 2) != 0 )
{
nv_msg(0LL, " - Attribute value is in units of Milihertz (1/1000 Hz).");
v8 = v4[20];
}
if ( (v8 & 4) != 0 )
{
nv_msg(0LL, " - Attribute value is packed integer.");
v8 = v4[20];
}
if ( (v8 & 8) != 0 )
{
nv_msg(0LL, " - Attribute value is a display mask.");
v8 = v4[20];
}
if ( (v8 & 0x10) != 0 )
{
nv_msg(0LL, " - Attribute value is a display ID.");
v8 = v4[20];
}
if ( (v8 & 0x20) != 0 )
{
nv_msg(0LL, " - Attribute cannot be zero.");
v8 = v4[20];
}
if ( (v8 & 0x40) != 0 )
nv_msg(0LL, " - Attribute value is switch display.");
}
nv_msg(" ", "%s", *((const char **)v4 + 3));
result = nv_msg(0LL, (const char *)&unk_7BB);
if ( !v3 )
return result;
goto LABEL_29;
}
LABEL_42:
nv_msg(0LL, " - Attribute is not written to the rc file.");
if ( (v4[16] & 0x10) == 0 )
goto LABEL_13;
goto LABEL_43;
}
}
else if ( v6 )
{
nv_msg(0LL, " - Attribute value is a string.");
}
else
{
nv_msg(0LL, " - Attribute value is an integer.");
}
v7 = v4[16];
if ( (v7 & 1) == 0 )
goto LABEL_10;
goto LABEL_40;
}
LABEL_30:
++v5;
v4 += 32;
}
while ( v5 < attributeTableLen );
result = v3 | (unsigned int)v11;
if ( !(v3 | v11) )
return nv_error_msg("Unrecognized attribute name '%s'.\n", s1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s1)
{
int v1; // er14
__int64 result; // rax
int v3; // er13
char *v4; // rbx
int v5; // er12
unsigned int v6; // eax
char v7; // al
char v8; // al
const char *v9; // rdx
int v10; // eax
int v11; // [rsp+4h] [rbp-3Ch]
const char *v12; // [rsp+8h] [rbp-38h]

if ( !strcasecmp(s1, "all") )
{
v1 = 1;
nv_msg(0LL, (const char *)&unk_7BB);
result = attributeTableLen;
v3 = 1;
if ( attributeTableLen <= 0 )
return result;
}
else
{
v1 = strcasecmp(s1, "list");
if ( v1 )
{
nv_msg(0LL, (const char *)&unk_7BB);
if ( attributeTableLen <= 0 )
return nv_error_msg("Unrecognized attribute name '%s'.\n", s1);
v1 = 1;
v3 = 0;
}
else
{
result = nv_msg(0LL, (const char *)&unk_7BB);
v3 = 1;
if ( attributeTableLen <= 0 )
return result;
}
}
v11 = 0;
v4 = (char *)&attributeTable;
v5 = 0;
do
{
v9 = *(const char **)v4;
if ( v3 || (v12 = *(const char **)v4, v10 = strcasecmp(s1, *(const char **)v4), v9 = v12, !v10) )
{
if ( !v1 )
{
result = nv_msg(0LL, "%s", v9);
if ( !v3 )
return result;
LABEL_29:
v11 = v3;
goto LABEL_30;
}
nv_msg(0LL, "Attribute '%s':", v9);
v6 = *((_DWORD *)v4 + 3);
if ( v6 == 3 )
{
nv_msg(0LL, " - Attribute value is binary data.");
}
else if ( v6 > 3 )
{
if ( v6 == 4 )
{
nv_msg(0LL, " - Attribute value is a color.");
v7 = v4[16];
if ( (v7 & 1) == 0 )
{
LABEL_10:
if ( (v7 & 2) == 0 )
goto LABEL_11;
goto LABEL_41;
}
LABEL_40:
nv_msg(0LL, " - Is GUI attribute.");
v7 = v4[16];
if ( (v7 & 2) == 0 )
{
LABEL_11:
if ( (v7 & 8) == 0 )
goto LABEL_12;
goto LABEL_42;
}
LABEL_41:
nv_msg(0LL, " - Is Frame Lock attribute.");
v7 = v4[16];
if ( (v7 & 8) == 0 )
{
LABEL_12:
if ( (v7 & 0x10) == 0 )
goto LABEL_13;
LABEL_43:
nv_msg(0LL, " - Attribute not queried in 'query all'.");
LABEL_13:
if ( !*((_DWORD *)v4 + 3) )
{
v8 = v4[20];
if ( (v8 & 1) != 0 )
{
nv_msg(0LL, " - Attribute value is in units of Centihertz (1/100Hz).");
v8 = v4[20];
}
if ( (v8 & 2) != 0 )
{
nv_msg(0LL, " - Attribute value is in units of Milihertz (1/1000 Hz).");
v8 = v4[20];
}
if ( (v8 & 4) != 0 )
{
nv_msg(0LL, " - Attribute value is packed integer.");
v8 = v4[20];
}
if ( (v8 & 8) != 0 )
{
nv_msg(0LL, " - Attribute value is a display mask.");
v8 = v4[20];
}
if ( (v8 & 0x10) != 0 )
{
nv_msg(0LL, " - Attribute value is a display ID.");
v8 = v4[20];
}
if ( (v8 & 0x20) != 0 )
{
nv_msg(0LL, " - Attribute cannot be zero.");
v8 = v4[20];
}
if ( (v8 & 0x40) != 0 )
nv_msg(0LL, " - Attribute value is switch display.");
}
nv_msg(" ", "%s", *((const char **)v4 + 3));
result = nv_msg(0LL, (const char *)&unk_7BB);
if ( !v3 )
return result;
goto LABEL_29;
}
LABEL_42:
nv_msg(0LL, " - Attribute is not written to the rc file.");
if ( (v4[16] & 0x10) == 0 )
goto LABEL_13;
goto LABEL_43;
}
}
else if ( v6 )
{
nv_msg(0LL, " - Attribute value is a string.");
}
else
{
nv_msg(0LL, " - Attribute value is an integer.");
}
v7 = v4[16];
if ( (v7 & 1) == 0 )
goto LABEL_10;
goto LABEL_40;
}
LABEL_30:
++v5;
v4 += 32;
}
while ( v5 < attributeTableLen );
result = v3 | (unsigned int)v11;
if ( !(v3 | v11) )
return nv_error_msg("Unrecognized attribute name '%s'.\n", s1);
return result;
}

original_code:
static void print_attribute_help(const char *attr)
{
    int i;
    int found = 0;
    int list_all = 0;
    int show_desc = 1;
    if (!strcasecmp(attr, "all")) {
        list_all = 1;
    } else if (!strcasecmp(attr, "list")) {
        list_all = 1;
        show_desc = 0;
    }
    nv_msg(((void *)0), "");
    for (i = 0; i < attributeTableLen; i++) {
        const AttributeTableEntry *entry = attributeTable + i;
        if (list_all || !strcasecmp(attr, entry->name)) {
            if (show_desc) {
                nv_msg(((void *)0), "Attribute '%s':", entry->name);
                switch (entry->type) {
                case CTRL_ATTRIBUTE_TYPE_INTEGER:
                    nv_msg(((void *)0), "  - Attribute value is an integer.");
                    break;
                case CTRL_ATTRIBUTE_TYPE_STRING:
                case CTRL_ATTRIBUTE_TYPE_STRING_OPERATION:
                    nv_msg(((void *)0), "  - Attribute value is a string.");
                    break;
                case CTRL_ATTRIBUTE_TYPE_BINARY_DATA:
                    nv_msg(((void *)0), "  - Attribute value is binary data.");
                    break;
                case CTRL_ATTRIBUTE_TYPE_COLOR:
                    nv_msg(((void *)0), "  - Attribute value is a color.");
                    break;
                }
                if (entry->flags.is_gui_attribute) {
                    nv_msg(((void *)0), "  - Is GUI attribute.");
                }
                if (entry->flags.is_framelock_attribute) {
                    nv_msg(((void *)0), "  - Is Frame Lock attribute.");
                }
                if (entry->flags.no_config_write) {
                    nv_msg(((void *)0), "  - Attribute is not written to the rc file.");
                }
                if (entry->flags.no_query_all) {
                    nv_msg(((void *)0), "  - Attribute not queried in 'query all'.");
                }
                switch (entry->type) {
                case CTRL_ATTRIBUTE_TYPE_INTEGER:
                    if (entry->f.int_flags.is_100Hz) {
                        nv_msg(((void *)0), "  - Attribute value is in units of Centihertz "
                               "(1/100Hz).");
                    }
                    if (entry->f.int_flags.is_1000Hz) {
                        nv_msg(((void *)0), "  - Attribute value is in units of Milihertz "
                               "(1/1000 Hz).");
                    }
                    if (entry->f.int_flags.is_packed) {
                        nv_msg(((void *)0), "  - Attribute value is packed integer.");
                    }
                    if (entry->f.int_flags.is_display_mask) {
                        nv_msg(((void *)0), "  - Attribute value is a display mask.");
                    }
                    if (entry->f.int_flags.is_display_id) {
                        nv_msg(((void *)0), "  - Attribute value is a display ID.");
                    }
                    if (entry->f.int_flags.no_zero) {
                        nv_msg(((void *)0), "  - Attribute cannot be zero.");
                    }
                    if (entry->f.int_flags.is_switch_display) {
                        nv_msg(((void *)0), "  - Attribute value is switch display.");
                    }
                    break;
                case CTRL_ATTRIBUTE_TYPE_STRING:
                case CTRL_ATTRIBUTE_TYPE_COLOR:
                case CTRL_ATTRIBUTE_TYPE_STRING_OPERATION:
                case CTRL_ATTRIBUTE_TYPE_BINARY_DATA:
                    break;
                }
                nv_msg("  ", "%s", entry->desc);
                nv_msg(((void *)0), "");
            } else {
                nv_msg(((void *)0), "%s", entry->name);
            }
            found = 1;
            if (!list_all) break;
        }
    }
    if (!found && !list_all) {
        nv_error_msg("Unrecognized attribute name '%s'.\n", attr);
    }
}

canonical_original_code:
static void print_attribute_help(char *attr)
{
    int i;
    int found = 0;
    int list_all = 0;
    int show_desc = 1;
    if (!strcasecmp(attr, "all")) {
        list_all = 1;
    } else if (!strcasecmp(attr, "list")) {
        list_all = 1;
        show_desc = 0;
    }
    nv_msg(((void *)0), "");
    for (i = 0; i < attributeTableLen; i++) {
        struct _AttributeTableEntry *entry = attributeTable + i;
        if (list_all || !strcasecmp(attr, entry->name)) {
            if (show_desc) {
                nv_msg(((void *)0), "Attribute '%s':", entry->name);
                switch (entry->type) {
                case CTRL_ATTRIBUTE_TYPE_INTEGER:
                    nv_msg(((void *)0), "  - Attribute value is an integer.");
                    break;
                case CTRL_ATTRIBUTE_TYPE_STRING:
                case CTRL_ATTRIBUTE_TYPE_STRING_OPERATION:
                    nv_msg(((void *)0), "  - Attribute value is a string.");
                    break;
                case CTRL_ATTRIBUTE_TYPE_BINARY_DATA:
                    nv_msg(((void *)0), "  - Attribute value is binary data.");
                    break;
                case CTRL_ATTRIBUTE_TYPE_COLOR:
                    nv_msg(((void *)0), "  - Attribute value is a color.");
                    break;
                }
                if (entry->flags.is_gui_attribute) {
                    nv_msg(((void *)0), "  - Is GUI attribute.");
                }
                if (entry->flags.is_framelock_attribute) {
                    nv_msg(((void *)0), "  - Is Frame Lock attribute.");
                }
                if (entry->flags.no_config_write) {
                    nv_msg(((void *)0), "  - Attribute is not written to the rc file.");
                }
                if (entry->flags.no_query_all) {
                    nv_msg(((void *)0), "  - Attribute not queried in 'query all'.");
                }
                switch (entry->type) {
                case CTRL_ATTRIBUTE_TYPE_INTEGER:
                    if (entry->f.int_flags.is_100Hz) {
                        nv_msg(((void *)0), "  - Attribute value is in units of Centihertz "
                               "(1/100Hz).");
                    }
                    if (entry->f.int_flags.is_1000Hz) {
                        nv_msg(((void *)0), "  - Attribute value is in units of Milihertz "
                               "(1/1000 Hz).");
                    }
                    if (entry->f.int_flags.is_packed) {
                        nv_msg(((void *)0), "  - Attribute value is packed integer.");
                    }
                    if (entry->f.int_flags.is_display_mask) {
                        nv_msg(((void *)0), "  - Attribute value is a display mask.");
                    }
                    if (entry->f.int_flags.is_display_id) {
                        nv_msg(((void *)0), "  - Attribute value is a display ID.");
                    }
                    if (entry->f.int_flags.no_zero) {
                        nv_msg(((void *)0), "  - Attribute cannot be zero.");
                    }
                    if (entry->f.int_flags.is_switch_display) {
                        nv_msg(((void *)0), "  - Attribute value is switch display.");
                    }
                    break;
                case CTRL_ATTRIBUTE_TYPE_STRING:
                case CTRL_ATTRIBUTE_TYPE_COLOR:
                case CTRL_ATTRIBUTE_TYPE_STRING_OPERATION:
                case CTRL_ATTRIBUTE_TYPE_BINARY_DATA:
                    break;
                }
                nv_msg("  ", "%s", entry->desc);
                nv_msg(((void *)0), "");
            } else {
                nv_msg(((void *)0), "%s", entry->name);
            }
            found = 1;
            if (!list_all) break;
        }
    }
    if (!found && !list_all) {
        nv_error_msg("Unrecognized attribute name '%s'.\n", attr);
    }
}

variable_types:
attr
char *

variable_types: i int

variable_types: found int

variable_types: struct _AttributeTableEntry { char *name; int attr; enum CtrlAttributeType { CTRL_ATTRIBUTE_TYPE_INTEGER=0, CTRL_ATTRIBUTE_TYPE_STRING=1, CTRL_ATTRIBUTE_TYPE_STRING_OPERATION=2, CTRL_ATTRIBUTE_TYPE_BINARY_DATA=3, CTRL_ATTRIBUTE_TYPE_COLOR=4 } type; struct AttributeFlagsRec { int is_gui_attribute; int is_framelock_attribute; int hijack_display_device; int no_config_write; int no_query_all; } flags; union { struct AttributeIntFlagsRec { int is_100Hz; int is_1000Hz; int is_packed; int is_display_mask; int is_display_id; int no_zero; int is_switch_display; } int_flags; } f; char *desc; } *

user_defined_types: struct _AttributeTableEntry { char *name; int attr; enum CtrlAttributeType type; struct AttributeFlagsRec flags; union { struct AttributeIntFlagsRec int_flags; } f; char *desc; }


decompiled_code:
__int64 get_wayland_display()
{
return wl_display_connect();
}

canonical_decompiled_code:
__int64 func17()
{
return wl_display_connect();
}