#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ XVisualInfo;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
#define GLX_ACCUM_ALPHA_SIZE 139
#define GLX_ACCUM_BLUE_SIZE 138
#define GLX_ACCUM_GREEN_SIZE 137
#define GLX_ACCUM_RED_SIZE 136
#define GLX_BLUE_SIZE 135
#define GLX_DEPTH_SIZE 134
#define GLX_DOUBLEBUFFER 133
#define GLX_GREEN_SIZE 132
#define GLX_RED_SIZE 131
#define GLX_RGBA 130
#define GLX_STENCIL_SIZE 129
#define None 128
int /*<<< orphan*/ XFree(int /*<<< orphan*/ *);
int /*<<< orphan*/ *glXChooseVisual(int /*<<< orphan*/ *, int, int *);
void mesa_hack(Display *dpy, int scrnum) {
  static int attribs[] = {
      GLX_RGBA, GLX_RED_SIZE,         1, GLX_GREEN_SIZE,
      1,        GLX_BLUE_SIZE,        1, GLX_DEPTH_SIZE,
      1,        GLX_STENCIL_SIZE,     1, GLX_ACCUM_RED_SIZE,
      1,        GLX_ACCUM_GREEN_SIZE, 1, GLX_ACCUM_BLUE_SIZE,
      1,        GLX_ACCUM_ALPHA_SIZE, 1, GLX_DOUBLEBUFFER,
      None};
  XVisualInfo *visinfo;
  visinfo = glXChooseVisual(dpy, scrnum, attribs);
  if (visinfo)
    XFree(visinfo);
}


x86 assembly (clang, -O0):
<mesa_hack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    0x2f03(%rip),%rdx
call   1040 <glXChooseVisual@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     115a <mesa_hack+0x3a>
mov    -0x18(%rbp),%rdi
call   1030 <XFree@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mesa_hack>:
push   %rax
lea    0x2f18(%rip),%rdx
call   1040 <glXChooseVisual@plt>
test   %rax,%rax
je     113b <mesa_hack+0x1b>
mov    %rax,%rdi
pop    %rax
jmp    1030 <XFree@plt>
pop    %rax
ret

LLVM IR (-O0):
@mesa_hack.attribs = internal global [21 x i32] [i32 130, i32 131, i32 1, i32 132, i32 1, i32 135, i32 1, i32 134, i32 1, i32 129, i32 1, i32 136, i32 1, i32 137, i32 1, i32 138, i32 1, i32 139, i32 1, i32 133, i32 128]
define void @mesa_hack(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32*, i32** %3
%7 = load i32, i32* %4
%8 = call i32* @glXChooseVisual(i32* %6, i32 %7, i32* getelementptr inbounds ([21 x i32], [21 x i32]* @mesa_hack.attribs, i64 0, i64 0))
store i32* %8, i32** %5
%9 = load i32*, i32** %5
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32*, i32** %5
%13 = call i32 @XFree(i32* %12)
br label %14
14: ; preds = %11, %2
ret void
}

LLVM IR (-O2):
@mesa_hack.attribs = internal global [21 x i32] [i32 130, i32 131, i32 1, i32 132, i32 1, i32 135, i32 1, i32 134, i32 1, i32 129, i32 1, i32 136, i32 1, i32 137, i32 1, i32 138, i32 1, i32 139, i32 1, i32 133, i32 128]
define void @mesa_hack(i32* %0, i32 %1) {
%3 = tail call i32* @glXChooseVisual(i32* %0, i32 %1, i32* getelementptr inbounds ([21 x i32], [21 x i32]* @mesa_hack.attribs, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @XFree(i32* %3)
br label %7
7: ; preds = %5, %2
ret void
}