loadGL

decompiled_code:
__int64 loadGL()
{
__int64 (__fastcall *v0)(const char *); // rdi
__int64 result; // rax
__int64 (__fastcall *v2)(const char *); // 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 v11; // rax
__int64 (__fastcall *v12)(const char *); // 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; // rax
__int64 v51; // rdx

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

canonical_decompiled_code:
__int64 func0()
{
__int64 (__fastcall *v0)(const char *); // rdi
__int64 result; // rax
__int64 (__fastcall *v2)(const char *); // 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 v11; // rax
__int64 (__fastcall *v12)(const char *); // 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; // rax
__int64 v51; // rdx

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

repo: NVIDIA/nvidia-settings

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);
}

return_type: void


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

return_type: char *


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

canonical_decompiled_code:
__int64 func12()
{
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_7FD);
nv_msg(0LL, "nvidia-settings: version 535.54.03");
nv_msg(" ", "The NVIDIA Settings tool.");
nv_msg(0LL, &unk_7FD);
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_7FD);
}

canonical_decompiled_code:
__int64 func0()
{
nv_msg(0LL, &unk_7FD);
nv_msg(0LL, "nvidia-settings: version 535.54.03");
nv_msg(" ", "The NVIDIA Settings tool.");
nv_msg(0LL, &unk_7FD);
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_7FD);
}

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_7FD);
nv_msg(0LL, "nvidia-settings [options]");
nv_msg(0LL, &unk_7FD);
return nvgetopt_print_help(&_options, 0LL, print_help_helper);
}

canonical_decompiled_code:
__int64 func1()
{
func0();
nv_msg(0LL, &unk_7FD);
nv_msg(0LL, "nvidia-settings [options]");
nv_msg(0LL, &unk_7FD);
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_7FD);
}

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_7FD);
}

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:
name
char *

variable_types:
description
char *


decompiled_code:
__int64 __fastcall print_attribute_help(char *s1)
{
__int64 result; // rax
int v2; // er15
int v3; // er14
int v4; // er13
const char **v5; // r12
unsigned int v6; // eax
int v7; // [rsp+18h] [rbp-38h]
int v8; // [rsp+1Ch] [rbp-34h]

if ( !strcasecmp(s1, "all") )
{
result = nv_msg(0LL, (const char *)&unk_7FD);
v2 = attributeTableLen;
v8 = 1;
v3 = 1;
if ( attributeTableLen <= 0 )
return result;
}
else
{
v8 = strcasecmp(s1, "list");
if ( v8 )
{
nv_msg(0LL, (const char *)&unk_7FD);
v2 = attributeTableLen;
v8 = 1;
v3 = 0;
if ( attributeTableLen <= 0 )
return nv_error_msg("Unrecognized attribute name '%s'.\n", s1);
}
else
{
result = nv_msg(0LL, (const char *)&unk_7FD);
v2 = attributeTableLen;
v3 = 1;
if ( attributeTableLen <= 0 )
return result;
}
}
v5 = (const char **)&attributeTable;
v7 = 0;
v4 = 0;
do
{
if ( v3 || !strcasecmp(s1, *v5) )
{
if ( v8 )
{
nv_msg(0LL, "Attribute '%s':", *v5);
v6 = *((_DWORD *)v5 + 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.");
}
else if ( v6 )
{
nv_msg(0LL, " - Attribute value is a string.");
}
else
{
nv_msg(0LL, " - Attribute value is an integer.");
}
if ( ((_BYTE)v5[2] & 1) != 0 )
nv_msg(0LL, " - Is GUI attribute.");
if ( ((_BYTE)v5[2] & 2) != 0 )
nv_msg(0LL, " - Is Frame Lock attribute.");
if ( ((_BYTE)v5[2] & 8) != 0 )
nv_msg(0LL, " - Attribute is not written to the rc file.");
if ( ((_BYTE)v5[2] & 0x10) != 0 )
nv_msg(0LL, " - Attribute not queried in 'query all'.");
if ( !*((_DWORD *)v5 + 3) )
{
if ( (*((_BYTE *)v5 + 20) & 1) != 0 )
nv_msg(0LL, " - Attribute value is in units of Centihertz (1/100Hz).");
if ( (*((_BYTE *)v5 + 20) & 2) != 0 )
nv_msg(0LL, " - Attribute value is in units of Milihertz (1/1000 Hz).");
if ( (*((_BYTE *)v5 + 20) & 4) != 0 )
nv_msg(0LL, " - Attribute value is packed integer.");
if ( (*((_BYTE *)v5 + 20) & 8) != 0 )
nv_msg(0LL, " - Attribute value is a display mask.");
if ( (*((_BYTE *)v5 + 20) & 0x10) != 0 )
nv_msg(0LL, " - Attribute value is a display ID.");
if ( (*((_BYTE *)v5 + 20) & 0x20) != 0 )
nv_msg(0LL, " - Attribute cannot be zero.");
if ( (*((_BYTE *)v5 + 20) & 0x40) != 0 )
nv_msg(0LL, " - Attribute value is switch display.");
}
nv_msg(" ", "%s", v5[3]);
result = nv_msg(0LL, (const char *)&unk_7FD);
}
else
{
result = nv_msg(0LL, "%s", *v5);
}
if ( !v3 )
return result;
v7 = v3;
}
++v4;
v5 += 4;
}
while ( v4 < v2 );
result = v3 | (unsigned int)v7;
if ( !(v3 | v7) )
return nv_error_msg("Unrecognized attribute name '%s'.\n", s1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s1)
{
__int64 result; // rax
int v2; // er15
int v3; // er14
int v4; // er13
const char **v5; // r12
unsigned int v6; // eax
int v7; // [rsp+18h] [rbp-38h]
int v8; // [rsp+1Ch] [rbp-34h]

if ( !strcasecmp(s1, "all") )
{
result = nv_msg(0LL, (const char *)&unk_7FD);
v2 = attributeTableLen;
v8 = 1;
v3 = 1;
if ( attributeTableLen <= 0 )
return result;
}
else
{
v8 = strcasecmp(s1, "list");
if ( v8 )
{
nv_msg(0LL, (const char *)&unk_7FD);
v2 = attributeTableLen;
v8 = 1;
v3 = 0;
if ( attributeTableLen <= 0 )
return nv_error_msg("Unrecognized attribute name '%s'.\n", s1);
}
else
{
result = nv_msg(0LL, (const char *)&unk_7FD);
v2 = attributeTableLen;
v3 = 1;
if ( attributeTableLen <= 0 )
return result;
}
}
v5 = (const char **)&attributeTable;
v7 = 0;
v4 = 0;
do
{
if ( v3 || !strcasecmp(s1, *v5) )
{
if ( v8 )
{
nv_msg(0LL, "Attribute '%s':", *v5);
v6 = *((_DWORD *)v5 + 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.");
}
else if ( v6 )
{
nv_msg(0LL, " - Attribute value is a string.");
}
else
{
nv_msg(0LL, " - Attribute value is an integer.");
}
if ( ((_BYTE)v5[2] & 1) != 0 )
nv_msg(0LL, " - Is GUI attribute.");
if ( ((_BYTE)v5[2] & 2) != 0 )
nv_msg(0LL, " - Is Frame Lock attribute.");
if ( ((_BYTE)v5[2] & 8) != 0 )
nv_msg(0LL, " - Attribute is not written to the rc file.");
if ( ((_BYTE)v5[2] & 0x10) != 0 )
nv_msg(0LL, " - Attribute not queried in 'query all'.");
if ( !*((_DWORD *)v5 + 3) )
{
if ( (*((_BYTE *)v5 + 20) & 1) != 0 )
nv_msg(0LL, " - Attribute value is in units of Centihertz (1/100Hz).");
if ( (*((_BYTE *)v5 + 20) & 2) != 0 )
nv_msg(0LL, " - Attribute value is in units of Milihertz (1/1000 Hz).");
if ( (*((_BYTE *)v5 + 20) & 4) != 0 )
nv_msg(0LL, " - Attribute value is packed integer.");
if ( (*((_BYTE *)v5 + 20) & 8) != 0 )
nv_msg(0LL, " - Attribute value is a display mask.");
if ( (*((_BYTE *)v5 + 20) & 0x10) != 0 )
nv_msg(0LL, " - Attribute value is a display ID.");
if ( (*((_BYTE *)v5 + 20) & 0x20) != 0 )
nv_msg(0LL, " - Attribute cannot be zero.");
if ( (*((_BYTE *)v5 + 20) & 0x40) != 0 )
nv_msg(0LL, " - Attribute value is switch display.");
}
nv_msg(" ", "%s", v5[3]);
result = nv_msg(0LL, (const char *)&unk_7FD);
}
else
{
result = nv_msg(0LL, "%s", *v5);
}
if ( !v3 )
return result;
v7 = v3;
}
++v4;
v5 += 4;
}
while ( v4 < v2 );
result = v3 | (unsigned int)v7;
if ( !(v3 | v7) )
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 func18()
{
return wl_display_connect();
}


xconfigAlloc

repo: NVIDIA/nvidia-xconfig

decompiled_code:
void *__fastcall xconfigAlloc(size_t n)
{
void *v1; // rax
int *v3; // rax
char *v4; // rax

v1 = malloc(n);
if ( !v1 )
{
v3 = _errno_location();
v4 = strerror(*v3);
fprintf(stderr, "memory allocation failure (%s)! \n", v4);
exit(1);
}
return memset(v1, 0, n);
}

canonical_decompiled_code:
void *__fastcall func0(size_t n)
{
void *v1; // rax
int *v3; // rax
char *v4; // rax

v1 = malloc(n);
if ( !v1 )
{
v3 = _errno_location();
v4 = strerror(*v3);
fprintf(stderr, "memory allocation failure (%s)! \n", v4);
exit(1);
}
return memset(v1, 0, n);
}

original_code:
void *xconfigAlloc(size_t size)
{
    void *m = malloc(size);
    if (!m) {
        fprintf(stderr, "memory allocation failure (%s)! \n", strerror((*__errno_location ())));
        exit(1);
    }
    memset((char *) m, 0, size);
    return m;
}

canonical_original_code:
void *xconfigAlloc(unsigned long size)
{
    void *m = malloc(size);
    if (!m) {
        fprintf(stderr, "memory allocation failure (%s)! \n", strerror((*__errno_location ())));
        exit(1);
    }
    memset((char *) m, 0, size);
    return m;
}

variable_types:
m
void *


xconfigStrdup

decompiled_code:
char *__fastcall xconfigStrdup(const char *a1)
{
char *result; // rax
int *v2; // rax
char *v3; // rax

if ( !a1 )
return 0LL;
result = strdup(a1);
if ( !result )
{
v2 = _errno_location();
v3 = strerror(*v2);
fprintf(stderr, "memory allocation failure during strdup (%s)! \n", v3);
exit(1);
}
return result;
}

canonical_decompiled_code:
char *__fastcall func1(const char *a1)
{
char *result; // rax
int *v2; // rax
char *v3; // rax

if ( !a1 )
return 0LL;
result = strdup(a1);
if ( !result )
{
v2 = _errno_location();
v3 = strerror(*v2);
fprintf(stderr, "memory allocation failure during strdup (%s)! \n", v3);
exit(1);
}
return result;
}

original_code:
char *xconfigStrdup(const char *s)
{
    char *m;
    if (!s) return ((void *)0);
    m = strdup(s);
    if (!m) {
        fprintf(stderr, "memory allocation failure during strdup (%s)! \n",
                strerror((*__errno_location ())));
        exit(1);
    }
    return m;
}

canonical_original_code:
char *xconfigStrdup(char *s)
{
    char *m;
    if (!s) return ((void *)0);
    m = strdup(s);
    if (!m) {
        fprintf(stderr, "memory allocation failure during strdup (%s)! \n",
                strerror((*__errno_location ())));
        exit(1);
    }
    return m;
}

variable_types:
s
char *

variable_types:
m
char *


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
char *v8; // r12
int i; // ebx
int v10; // eax
double v11; // xmm4_8
double v12; // xmm5_8
char *v13; // rbx
double v14; // xmm4_8
double v15; // xmm5_8
char *v16; // rbx
double v17; // xmm4_8
double v18; // xmm5_8
char *v19; // r13
double v20; // xmm4_8
double v21; // xmm5_8
char s[72]; // [rsp+0h] [rbp-130h] BYREF
gcc_va_list arg; // [rsp+48h] [rbp-E8h] BYREF
__int128 v24; // [rsp+90h] [rbp-A0h]
__int128 v25; // [rsp+A0h] [rbp-90h]
__int128 v26; // [rsp+B0h] [rbp-80h]
__int128 v27; // [rsp+C0h] [rbp-70h]
__int128 v28; // [rsp+D0h] [rbp-60h]
__int128 v29; // [rsp+E0h] [rbp-50h]
__int128 v30; // [rsp+F0h] [rbp-40h]
__int128 v31; // [rsp+100h] [rbp-30h]

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

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
char *v8; // r12
int i; // ebx
int v10; // eax
double v11; // xmm4_8
double v12; // xmm5_8
char *v13; // rbx
double v14; // xmm4_8
double v15; // xmm5_8
char *v16; // rbx
double v17; // xmm4_8
double v18; // xmm5_8
char *v19; // r13
double v20; // xmm4_8
double v21; // xmm5_8
char s[72]; // [rsp+0h] [rbp-130h] BYREF
gcc_va_list arg; // [rsp+48h] [rbp-E8h] BYREF
__int128 v24; // [rsp+90h] [rbp-A0h]
__int128 v25; // [rsp+A0h] [rbp-90h]
__int128 v26; // [rsp+B0h] [rbp-80h]
__int128 v27; // [rsp+C0h] [rbp-70h]
__int128 v28; // [rsp+D0h] [rbp-60h]
__int128 v29; // [rsp+E0h] [rbp-50h]
__int128 v30; // [rsp+F0h] [rbp-40h]
__int128 v31; // [rsp+100h] [rbp-30h]

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

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]


decompiled_code:
__int64 update_scf_depth()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 1LL;
}

original_code:
int update_scf_depth(int depth)
{
    return 1;
}

variable_types: depth int

return_type: int


decompiled_code:
__int64 read_scf_depth()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func1()
{
return 0LL;
}

original_code:
int read_scf_depth(int *depth)
{
    return 0;
}

variable_types:
depth
int *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
gen_manpage_opts_helper(&_options, argv, envp);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func8(&_options, argv, envp);
return 0;
}

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

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


decompiled_code:
int __fastcall print_option(const char **a1)
{
const char *v2; // rsi
const unsigned __int16 **v3; // rax
__int64 v4; // rsi
int v5; // eax
char *v6; // rbx
int v7; // er14
int v8; // edx
int v9; // er13
const char *v10; // rbx
int v11; // er12
const __int32_t *v12; // rsi
__int64 v13; // rax
__int64 v14; // rdx
char v15; // di
int v17; // [rsp+Ch] [rbp-74h]
char dest[112]; // [rsp+10h] [rbp-70h] BYREF

if ( (*((_BYTE *)a1 + 12) & 0xE) != 0 )
{
v2 = a1[2];
if ( v2 )
{
strcpy(dest, v2);
}
else
{
v10 = *a1;
v11 = strlen(*a1);
if ( v11 > 0 )
{
v12 = *__ctype_toupper_loc();
v13 = 0LL;
do
{
dest[v13] = v12[v10[v13]];
v14 = v13++;
}
while ( v14 != v11 - 1 );
}
dest[v11] = 0;
}
}
printf(".TP\n.BI \"");
v3 = __ctype_b_loc();
v4 = *((unsigned int *)a1 + 2);
if ( ((*v3)[(int)v4] & 0x400) != 0 )
{
printf("\\-%c", v4);
if ( (*((_BYTE *)a1 + 12) & 0xE) != 0 )
printf(" \" \"%s\" \"", dest);
printf(", ");
}
printf("\\-\\-%s", *a1);
if ( (*((_BYTE *)a1 + 12) & 0xE) != 0 )
{
printf("=\" \"%s", dest);
if ( (*((_BYTE *)a1 + 12) & 0x11) != 0 )
printf("\" \"");
}
v5 = *((_DWORD *)a1 + 3);
if ( (v5 & 0xF) == 1 || (v5 & 0x10) != 0 )
printf(", \\-\\-no\\-%s", *a1);
puts("\"");
v6 = (char *)a1[3];
if ( v6 )
{
v7 = 0;
v8 = 1;
v17 = 0;
v9 = 0;
while ( 1 )
{
v15 = *v6;
if ( !*v6 )
return putchar(10);
if ( v15 > 46 )
{
if ( v15 != 94 )
goto LABEL_34;
if ( v9 )
putchar(10);
else
printf("\n.B ");
v8 = v9;
v17 = v9;
v9 ^= 1u;
}
else
{
if ( v15 <= 9 )
{
LABEL_34:
putchar(v15);
v8 = 0;
v17 = 0;
goto LABEL_35;
}
switch ( v15 )
{
case 10:
putchar(10);
v8 = 1;
v17 = 0;
break;
case 32:
if ( !v17 )
{
putchar(32);
v8 = 0;
}
break;
case 38:
if ( v7 )
putchar(10);
else
printf("\n.I ");
v8 = v7;
v17 = v7;
v7 ^= 1u;
break;
case 39:
if ( v8 )
{
fprintf(
stderr,
"Error: *roff can't start a line with '''. If you started a line with ''' in the description of the '%s' "
"option, please add some text at the beginning of the sentence, so that a valid manpage can be generated.\n",
*a1);
exit(1);
}
goto LABEL_34;
case 45:
printf("\\-");
v8 = 0;
v17 = 0;
break;
case 46:
if ( v8 )
{
fprintf(
stderr,
"Error: *roff can't start a line with '.' If you used '&' or '^' to format text in the description of the"
" '%s' option, please add some text before the end of the sentence, so that a valid manpage can be generated.\n",
*a1);
exit(1);
}
goto LABEL_34;
default:
goto LABEL_34;
}
}
LABEL_35:
++v6;
}
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func7(const char **a1)
{
const char *v2; // rsi
const unsigned __int16 **v3; // rax
__int64 v4; // rsi
int v5; // eax
char *v6; // rbx
int v7; // er14
int v8; // edx
int v9; // er13
const char *v10; // rbx
int v11; // er12
const __int32_t *v12; // rsi
__int64 v13; // rax
__int64 v14; // rdx
char v15; // di
int v17; // [rsp+Ch] [rbp-74h]
char dest[112]; // [rsp+10h] [rbp-70h] BYREF

if ( (*((_BYTE *)a1 + 12) & 0xE) != 0 )
{
v2 = a1[2];
if ( v2 )
{
strcpy(dest, v2);
}
else
{
v10 = *a1;
v11 = strlen(*a1);
if ( v11 > 0 )
{
v12 = *__ctype_toupper_loc();
v13 = 0LL;
do
{
dest[v13] = v12[v10[v13]];
v14 = v13++;
}
while ( v14 != v11 - 1 );
}
dest[v11] = 0;
}
}
printf(".TP\n.BI \"");
v3 = __ctype_b_loc();
v4 = *((unsigned int *)a1 + 2);
if ( ((*v3)[(int)v4] & 0x400) != 0 )
{
printf("\\-%c", v4);
if ( (*((_BYTE *)a1 + 12) & 0xE) != 0 )
printf(" \" \"%s\" \"", dest);
printf(", ");
}
printf("\\-\\-%s", *a1);
if ( (*((_BYTE *)a1 + 12) & 0xE) != 0 )
{
printf("=\" \"%s", dest);
if ( (*((_BYTE *)a1 + 12) & 0x11) != 0 )
printf("\" \"");
}
v5 = *((_DWORD *)a1 + 3);
if ( (v5 & 0xF) == 1 || (v5 & 0x10) != 0 )
printf(", \\-\\-no\\-%s", *a1);
puts("\"");
v6 = (char *)a1[3];
if ( v6 )
{
v7 = 0;
v8 = 1;
v17 = 0;
v9 = 0;
while ( 1 )
{
v15 = *v6;
if ( !*v6 )
return putchar(10);
if ( v15 > 46 )
{
if ( v15 != 94 )
goto LABEL_34;
if ( v9 )
putchar(10);
else
printf("\n.B ");
v8 = v9;
v17 = v9;
v9 ^= 1u;
}
else
{
if ( v15 <= 9 )
{
LABEL_34:
putchar(v15);
v8 = 0;
v17 = 0;
goto LABEL_35;
}
switch ( v15 )
{
case 10:
putchar(10);
v8 = 1;
v17 = 0;
break;
case 32:
if ( !v17 )
{
putchar(32);
v8 = 0;
}
break;
case 38:
if ( v7 )
putchar(10);
else
printf("\n.I ");
v8 = v7;
v17 = v7;
v7 ^= 1u;
break;
case 39:
if ( v8 )
{
fprintf(
stderr,
"Error: *roff can't start a line with '''. If you started a line with ''' in the description of the '%s' "
"option, please add some text at the beginning of the sentence, so that a valid manpage can be generated.\n",
*a1);
exit(1);
}
goto LABEL_34;
case 45:
printf("\\-");
v8 = 0;
v17 = 0;
break;
case 46:
if ( v8 )
{
fprintf(
stderr,
"Error: *roff can't start a line with '.' If you used '&' or '^' to format text in the description of the"
" '%s' option, please add some text before the end of the sentence, so that a valid manpage can be generated.\n",
*a1);
exit(1);
}
goto LABEL_34;
default:
goto LABEL_34;
}
}
LABEL_35:
++v6;
}
}
return putchar(10);
}

original_code:
static void print_option(const NVGetoptOption *o)
{
    char scratch[64];
    const char *s;
    int j, len;
    int italics, bold, omitWhiteSpace, firstchar;
    if (o->flags & (0x0002 | 0x0004 | 0x0008)) {
        if (o->arg_name) {
            strcpy(scratch, o->arg_name);
        } else {
            len = strlen(o->name);
            for (j = 0; j < len; j++) scratch[j] = toupper(o->name[j]);
            scratch[len] = '\0';
        }
    }
    printf(".TP\n.BI \"");
    if (((*__ctype_b_loc ())[(int) ((o->val))] & (unsigned short int) _ISalpha)) {
        printf("\\-%c", o->val);
        if (o->flags & (0x0002 | 0x0004 | 0x0008)) {
            printf(" \" \"%s\" \"", scratch);
        }
        printf(", ");
    }
    printf("\\-\\-%s", o->name);
    if (o->flags & (0x0002 | 0x0004 | 0x0008)) {
        printf("=\" \"%s", scratch);
        if ((o->flags & 0x0001) ||
            (o->flags & 0x0010)) {
            printf("\" \"");
        }
    }
    if (((o->flags & 0x0001) &&
         !(o->flags & (0x0002 | 0x0004 | 0x0008))) ||
        (o->flags & 0x0010)) {
        printf(", \\-\\-no\\-%s", o->name);
    }
    printf("\"\n");
    italics = 0;
    bold = 0;
    omitWhiteSpace = 0;
    firstchar = 1;
    for (s = o->description; s && *s; s++) {
        switch (*s) {
          case '&':
              if (italics) {
                  printf("\n");
              } else {
                  printf("\n.I ");
              }
              omitWhiteSpace = italics;
              firstchar = italics;
              italics = !italics;
              break;
          case '^':
              if (bold) {
                  printf("\n");
              } else {
                  printf("\n.B ");
              }
              omitWhiteSpace = bold;
              firstchar = bold;
              bold = !bold;
              break;
          case '-':
              printf("\\-");
              omitWhiteSpace = 0;
              firstchar = 0;
              break;
          case ' ':
              if (!omitWhiteSpace) {
                  printf(" ");
                  firstchar = 0;
              }
              break;
          case '\n':
              printf("\n");
              omitWhiteSpace = 0;
              firstchar = 1;
              break;
          case '.':
              if (firstchar) {
                  fprintf(stderr, "Error: *roff can't start a line with '.' "
                          "If you used '&' or '^' to format text in the "
                          "description of the '%s' option, please add some "
                          "text before the end of the sentence, so that a "
                          "valid manpage can be generated.\n", o->name);
                  exit(1);
              }
          case '\'':
              if (firstchar) {
                  fprintf(stderr, "Error: *roff can't start a line with '\''. "
                          "If you started a line with '\'' in the description "
                          "of the '%s' option, please add some text at the "
                          "beginning of the sentence, so that a valid manpage "
                          "can be generated.\n", o->name);
                  exit(1);
              }
          default:
              printf("%c", *s);
              omitWhiteSpace = 0;
              firstchar = 0;
              break;
        }
    }
    printf("\n");
}

canonical_original_code:
static void print_option(struct NVGetoptOption *o)
{
    char scratch[64];
    char *s;
    int j; int len;
    int italics; int bold; int omitWhiteSpace; int firstchar;
    if (o->flags & (0x0002 | 0x0004 | 0x0008)) {
        if (o->arg_name) {
            strcpy(scratch, o->arg_name);
        } else {
            len = strlen(o->name);
            for (j = 0; j < len; j++) scratch[j] = toupper(o->name[j]);
            scratch[len] = '\0';
        }
    }
    printf(".TP\n.BI \"");
    if (((*__ctype_b_loc ())[(int) ((o->val))] & (unsigned short) _ISalpha)) {
        printf("\\-%c", o->val);
        if (o->flags & (0x0002 | 0x0004 | 0x0008)) {
            printf(" \" \"%s\" \"", scratch);
        }
        printf(", ");
    }
    printf("\\-\\-%s", o->name);
    if (o->flags & (0x0002 | 0x0004 | 0x0008)) {
        printf("=\" \"%s", scratch);
        if ((o->flags & 0x0001) ||
            (o->flags & 0x0010)) {
            printf("\" \"");
        }
    }
    if (((o->flags & 0x0001) &&
         !(o->flags & (0x0002 | 0x0004 | 0x0008))) ||
        (o->flags & 0x0010)) {
        printf(", \\-\\-no\\-%s", o->name);
    }
    printf("\"\n");
    italics = 0;
    bold = 0;
    omitWhiteSpace = 0;
    firstchar = 1;
    for (s = o->description; s && *s; s++) {
        switch (*s) {
          case '&':
              if (italics) {
                  printf("\n");
              } else {
                  printf("\n.I ");
              }
              omitWhiteSpace = italics;
              firstchar = italics;
              italics = !italics;
              break;
          case '^':
              if (bold) {
                  printf("\n");
              } else {
                  printf("\n.B ");
              }
              omitWhiteSpace = bold;
              firstchar = bold;
              bold = !bold;
              break;
          case '-':
              printf("\\-");
              omitWhiteSpace = 0;
              firstchar = 0;
              break;
          case ' ':
              if (!omitWhiteSpace) {
                  printf(" ");
                  firstchar = 0;
              }
              break;
          case '\n':
              printf("\n");
              omitWhiteSpace = 0;
              firstchar = 1;
              break;
          case '.':
              if (firstchar) {
                  fprintf(stderr, "Error: *roff can't start a line with '.' "
                          "If you used '&' or '^' to format text in the "
                          "description of the '%s' option, please add some "
                          "text before the end of the sentence, so that a "
                          "valid manpage can be generated.\n", o->name);
                  exit(1);
              }
          case '\'':
              if (firstchar) {
                  fprintf(stderr, "Error: *roff can't start a line with '\''. "
                          "If you started a line with '\'' in the description "
                          "of the '%s' option, please add some text at the "
                          "beginning of the sentence, so that a valid manpage "
                          "can be generated.\n", o->name);
                  exit(1);
              }
          default:
              printf("%c", *s);
              omitWhiteSpace = 0;
              firstchar = 0;
              break;
        }
    }
    printf("\n");
}

variable_types: struct NVGetoptOption { char *name; int val; unsigned int flags; char *arg_name; char *description; } *

variable_types: j int

variable_types: italics int

variable_types: bold int

variable_types: omitWhiteSpace int

variable_types: firstchar int


decompiled_code:
int __fastcall gen_manpage_opts_helper(const char **a1)
{
const char **v1; // r12
int result; // eax
const char **v3; // rbx
int v4; // er13

v1 = a1;
result = puts(".SH OPTIONS");
if ( *a1 )
{
v3 = a1;
v4 = 0;
do
{
if ( v3[3] )
{
if ( (*((_BYTE *)v3 + 12) & 0x40) != 0 )
result = print_option(v3);
else
v4 = 1;
}
v3 += 4;
}
while ( *v3 );
if ( v4 )
{
result = puts(".SH \"ADVANCED OPTIONS\"");
if ( *a1 )
{
do
{
if ( v1[3] )
{
if ( (*((_BYTE *)v1 + 12) & 0x40) == 0 )
result = print_option(v1);
}
v1 += 4;
}
while ( *v1 );
}
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func8(const char **a1)
{
const char **v1; // r12
int result; // eax
const char **v3; // rbx
int v4; // er13

v1 = a1;
result = puts(".SH OPTIONS");
if ( *a1 )
{
v3 = a1;
v4 = 0;
do
{
if ( v3[3] )
{
if ( (*((_BYTE *)v3 + 12) & 0x40) != 0 )
result = func7(v3);
else
v4 = 1;
}
v3 += 4;
}
while ( *v3 );
if ( v4 )
{
result = puts(".SH \"ADVANCED OPTIONS\"");
if ( *a1 )
{
do
{
if ( v1[3] )
{
if ( (*((_BYTE *)v1 + 12) & 0x40) == 0 )
result = func7(v1);
}
v1 += 4;
}
while ( *v1 );
}
}
}
return result;
}

original_code:
void gen_manpage_opts_helper(const NVGetoptOption *options)
{
    int i;
    int has_advanced_options = 0;
    printf(".SH OPTIONS\n");
    for (i = 0; options[i].name; i++) {
        const NVGetoptOption *o = &options[i];
        if (!o->description) {
            continue;
        }
        if (!(o->flags & 0x0040)) {
            has_advanced_options = 1;
            continue;
        }
        print_option(o);
    }
    if (has_advanced_options) {
        printf(".SH \"ADVANCED OPTIONS\"\n");
        for (i = 0; options[i].name; i++) {
            const NVGetoptOption *o = &options[i];
            if (!o->description) {
                continue;
            }
            if (o->flags & 0x0040) {
                continue;
            }
            print_option(o);
        }
    }
}

canonical_original_code:
void gen_manpage_opts_helper(struct NVGetoptOption *options)
{
    int i;
    int has_advanced_options = 0;
    printf(".SH OPTIONS\n");
    for (i = 0; options[i].name; i++) {
        struct NVGetoptOption *o = &options[i];
        if (!o->description) {
            continue;
        }
        if (!(o->flags & 0x0040)) {
            has_advanced_options = 1;
            continue;
        }
        print_option(o);
    }
    if (has_advanced_options) {
        printf(".SH \"ADVANCED OPTIONS\"\n");
        for (i = 0; options[i].name; i++) {
            struct NVGetoptOption *o = &options[i];
            if (!o->description) {
                continue;
            }
            if (o->flags & 0x0040) {
                continue;
            }
            print_option(o);
        }
    }
}

variable_types: i int

user_defined_types: struct NVGetoptOption { char *name; int val; unsigned int flags; char *arg_name; char *description; }


decompiled_code:
int __fastcall print_range(__int64 a1, int a2)
{
__int64 i; // rbx

if ( a2 > 0 )
{
for ( i = 1LL; ; ++i )
{
printf("%.1f-%.1f", *(float *)(a1 + 8 * i - 4), *(float *)(a1 + 8 * i - 8));
if ( i == a2 )
break;
if ( (int)i > 0 )
printf(", ");
}
}
return putchar(10);
}

original_code:
static void print_range(parser_range* range, int n)
{
    int i;
    for (i = 0; i < n; i++) {
        if (i > 0) printf(", ");
        printf("%.1f-%.1f", range[i].lo, range[i].hi);
    }
    printf("\n");
}

canonical_original_code:
static void print_range(struct parser_range *range, int n)
{
    int i;
    for (i = 0; i < n; i++) {
        if (i > 0) printf(", ");
        printf("%.1f-%.1f", range[i].lo, range[i].hi);
    }
    printf("\n");
}

variable_types:
range
struct parser_range { float hi; } *

variable_types: n int


decompiled_code:
_BOOL8 __fastcall nvpci_dev_is_vga(__int64 a1)
{
return (*(_DWORD *)(a1 + 16) & 0xFFFF00) == 196608;
}

original_code:
int nvpci_dev_is_vga(struct pci_device *dev)
{
    return (dev->device_class & PCI_CLASS_SUBCLASS_MASK) ==
           PCI_CLASS_DISPLAY_VGA;
}

variable_types: struct pci_device { unsigned short domain_16; unsigned char bus; unsigned char dev; unsigned char func; unsigned short vendor_id; unsigned short device_id; unsigned short subvendor_id; unsigned short subdevice_id; unsigned int device_class; unsigned char revision; struct pci_mem_region { void *memory; unsigned long bus_addr; unsigned long base_addr; unsigned long size; unsigned int is_IO; unsigned int is_prefetchable; unsigned int is_64; } regions[6]; unsigned long rom_size; int irq; long user_data; int vgaarb_rsrc; unsigned int domain; } *

user_defined_types: struct pci_device { unsigned short domain_16; unsigned char bus; unsigned char dev; unsigned char func; unsigned short vendor_id; unsigned short device_id; unsigned short subvendor_id; unsigned short subdevice_id; unsigned int device_class; unsigned char revision; struct pci_mem_region regions[6]; unsigned long rom_size; int irq; long user_data; int vgaarb_rsrc; unsigned int domain; }


original_code:
static char *display_device_mask_to_display_device_name(unsigned int mask)
{
    char *s;
    int first = 1;
    unsigned int devcnt, devmask;
    char *display_device_name_string;
    display_device_name_string = nvalloc(256);
    s = display_device_name_string;
    devmask = 1 << 0;
    devcnt = 0;
    while (devmask & (0xff << 0)) {
        if (devmask & mask) {
            if (first) first = 0;
            else s += sprintf(s, ", ");
            s += sprintf(s, "CRT-%X", devcnt);
        }
        devmask <<= 1;
        devcnt++;
    }
    devmask = 1 << 16;
    devcnt = 0;
    while (devmask & (0xff << 16)) {
        if (devmask & mask) {
            if (first) first = 0;
            else s += sprintf(s, ", ");
            s += sprintf(s, "DFP-%X", devcnt);
        }
        devmask <<= 1;
        devcnt++;
    }
    devmask = 1 << 8;
    devcnt = 0;
    while (devmask & (0xff << 8)) {
        if (devmask & mask) {
            if (first) first = 0;
            else s += sprintf(s, ", ");
            s += sprintf(s, "TV-%X", devcnt);
        }
        devmask <<= 1;
        devcnt++;
    }
    *s = '\0';
    return (display_device_name_string);
}

canonical_original_code:
static char *display_device_mask_to_display_device_name(unsigned int mask)
{
    char *s;
    int first = 1;
    unsigned int devcnt; unsigned int devmask;
    char *display_device_name_string;
    display_device_name_string = nvalloc(256);
    s = display_device_name_string;
    devmask = 1 << 0;
    devcnt = 0;
    while (devmask & (0xff << 0)) {
        if (devmask & mask) {
            if (first) first = 0;
            else s += sprintf(s, ", ");
            s += sprintf(s, "CRT-%X", devcnt);
        }
        devmask <<= 1;
        devcnt++;
    }
    devmask = 1 << 16;
    devcnt = 0;
    while (devmask & (0xff << 16)) {
        if (devmask & mask) {
            if (first) first = 0;
            else s += sprintf(s, ", ");
            s += sprintf(s, "DFP-%X", devcnt);
        }
        devmask <<= 1;
        devcnt++;
    }
    devmask = 1 << 8;
    devcnt = 0;
    while (devmask & (0xff << 8)) {
        if (devmask & mask) {
            if (first) first = 0;
            else s += sprintf(s, ", ");
            s += sprintf(s, "TV-%X", devcnt);
        }
        devmask <<= 1;
        devcnt++;
    }
    *s = '\0';
    return (display_device_name_string);
}

variable_types:
mask
unsigned int

variable_types:
s
char *

variable_types: first int

variable_types:
devcnt
unsigned int

variable_types:
devmask
unsigned int


decompiled_code:
char *__fastcall cook_description(const char *a1)
{
const char *v1; // rbx
char *v2; // rcx
char v3; // al
char *v4; // rdx

v1 = a1;
if ( !a1 )
return 0LL;
v2 = strdup(a1);
if ( v2 )
{
v3 = *a1;
if ( *a1 )
{
v4 = v2;
do
{
if ( v3 != 38 && v3 != 94 )
*v4++ = v3;
v3 = *++v1;
}
while ( *v1 );
}
else
{
v4 = v2;
}
*v4 = 0;
}
return v2;
}

canonical_decompiled_code:
char *__fastcall func0(const char *a1)
{
const char *v1; // rbx
char *v2; // rcx
char v3; // al
char *v4; // rdx

v1 = a1;
if ( !a1 )
return 0LL;
v2 = strdup(a1);
if ( v2 )
{
v3 = *a1;
if ( *a1 )
{
v4 = v2;
do
{
if ( v3 != 38 && v3 != 94 )
*v4++ = v3;
v3 = *++v1;
}
while ( *v1 );
}
else
{
v4 = v2;
}
*v4 = 0;
}
return v2;
}

original_code:
static char *cook_description(const char *description)
{
    const char *src;
    char *s, *dst;
    if (!description) {
        return ((void *)0);
    }
    s = strdup(description);
    if (!s) {
        return ((void *)0);
    }
    for (src = description, dst = s; *src; src++) {
        if ((*src == '&') || (*src == '^')) {
            continue;
        }
        *dst = *src;
        dst++;
    }
    *dst = '\0';
    return s;
}

canonical_original_code:
static char *cook_description(char *description)
{
    char *src;
    char *s; char *dst;
    if (!description) {
        return ((void *)0);
    }
    s = strdup(description);
    if (!s) {
        return ((void *)0);
    }
    for (src = description, dst = s; *src; src++) {
        if ((*src == '&') || (*src == '^')) {
            continue;
        }
        *dst = *src;
        dst++;
    }
    *dst = '\0';
    return s;
}

variable_types:
description
char *

variable_types:
src
char *

variable_types:
dst
char *