#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*/ *GLXContext;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ GL_TRUE;
int /*<<< orphan*/ None;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *glXCreateContext(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                     int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ glXQueryExtension(int /*<<< orphan*/ *, int *, int *);
int /*<<< orphan*/ printf(char *);
GLXContext _getGLXctx(Display *dpy, XVisualInfo *visInfo) {
  int dummy;
  if (!glXQueryExtension(dpy, &dummy, &dummy)) {
    printf("X server has no OpenGL GLX extension");
    exit(0);
  }
  GLXContext ctx = glXCreateContext(dpy, visInfo, None, GL_TRUE);
  if (ctx == NULL) {
    printf("could not create GLX rendering context");
    exit(0);
  }
  return ctx;
}


x86 assembly (clang, -O0):
<_getGLXctx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rdx
mov    %rdx,%rsi
call   1040 <glXQueryExtension@plt>
cmp    $0x0,%eax
jne    117c <_getGLXctx+0x3c>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e5d(%rip),%rax
mov    (%rax),%edx
mov    0x2e44(%rip),%rax
mov    (%rax),%ecx
call   1050 <glXCreateContext@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11bd <_getGLXctx+0x7d>
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_getGLXctx>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x4(%rsp),%rdx
mov    %rdx,%rsi
call   1040 <glXQueryExtension@plt>
test   %eax,%eax
je     1185 <_getGLXctx+0x45>
mov    0x2e86(%rip),%rax
mov    (%rax),%edx
mov    0x2e6d(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <glXCreateContext@plt>
test   %rax,%rax
je     118e <_getGLXctx+0x4e>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe74(%rip),%rdi
jmp    1195 <_getGLXctx+0x55>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"X server has no OpenGL GLX extension\00"
@None = global i32 0
@GL_TRUE = global i32 0
@.str.1 = [39 x i8] c"could not create GLX rendering context\00"
define i32* @_getGLXctx(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
store i32* %0, i32** %3
store i32* %1, i32** %4
%7 = load i32*, i32** %3
%8 = call i32 @glXQueryExtension(i32* %7, i32* %5, i32* %5)
%9 = icmp ne i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %2
%14 = load i32*, i32** %3
%15 = load i32*, i32** %4
%16 = load i32, i32* @None
%17 = load i32, i32* @GL_TRUE
%18 = call i32* @glXCreateContext(i32* %14, i32* %15, i32 %16, i32 %17)
store i32* %18, i32** %6
%19 = load i32*, i32** %6
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %13
%22 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %13
%25 = load i32*, i32** %6
ret i32* %25
}

LLVM IR (-O2):
@.str = [37 x i8] c"X server has no OpenGL GLX extension\00"
@None = global i32 0
@GL_TRUE = global i32 0
@.str.1 = [39 x i8] c"could not create GLX rendering context\00"
define i32* @_getGLXctx(i32* %0, i32* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @glXQueryExtension(i32* %0, i32* %3, i32* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 0)
unreachable
10: ; preds = %2
%11 = load i32, i32* @None
%12 = load i32, i32* @GL_TRUE
%13 = call i32* @glXCreateContext(i32* %0, i32* %1, i32 %11, i32 %12)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %10
ret i32* %13
}