#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*/ Display;

/* Variables and functions */
int DefaultScreen(int /*<<< orphan*/ *);
char *glXQueryExtensionsString(int /*<<< orphan*/ *, int const);
size_t strlen(char const *);
char *strstr(char const *, char const *);
int is_glx_extension_supported(Display *dpy, const char *query) {
  const int scrnum = DefaultScreen(dpy);
  const char *glx_extensions = NULL;
  const size_t len = strlen(query);
  const char *ptr;
  if (glx_extensions == NULL) {
    glx_extensions = glXQueryExtensionsString(dpy, scrnum);
  }
  ptr = strstr(glx_extensions, query);
  return ((ptr != NULL) && ((ptr[len] == ' ') || (ptr[len] == '\0')));
}


x86 assembly (clang, -O0):
<is_glx_extension_supported>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <DefaultScreen@plt>
mov    %eax,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    118c <is_glx_extension_supported+0x4c>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <glXQueryExtensionsString@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x30(%rbp)
mov    %al,-0x31(%rbp)
je     11e2 <is_glx_extension_supported+0xa2>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x32(%rbp)
je     11dc <is_glx_extension_supported+0x9c>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_glx_extension_supported>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
call   1050 <DefaultScreen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <glXQueryExtensionsString@plt>
mov    %rax,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     1190 <is_glx_extension_supported+0x50>
mov    (%rax,%r14,1),%cl
mov    $0x1,%eax
cmp    $0x20,%cl
je     1192 <is_glx_extension_supported+0x52>
xor    %eax,%eax
test   %cl,%cl
sete   %al
jmp    1192 <is_glx_extension_supported+0x52>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_glx_extension_supported(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%9 = load i32*, i32** %3
%10 = call i32 @DefaultScreen(i32* %9)
store i32 %10, i32* %5
store i8* null, i8** %6
%11 = load i8*, i8** %4
%12 = call i64 @strlen(i8* %11)
store i64 %12, i64* %7
%13 = load i8*, i8** %6
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32*, i32** %3
%17 = load i32, i32* %5
%18 = call i8* @glXQueryExtensionsString(i32* %16, i32 %17)
store i8* %18, i8** %6
br label %19
19: ; preds = %15, %2
%20 = load i8*, i8** %6
%21 = load i8*, i8** %4
%22 = call i8* @strstr(i8* %20, i8* %21)
store i8* %22, i8** %8
%23 = load i8*, i8** %8
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %41
25: ; preds = %19
%26 = load i8*, i8** %8
%27 = load i64, i64* %7
%28 = getelementptr inbounds i8, i8* %26, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 32
br i1 %31, label %39, label %32
32: ; preds = %25
%33 = load i8*, i8** %8
%34 = load i64, i64* %7
%35 = getelementptr inbounds i8, i8* %33, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 0
br label %39
39: ; preds = %32, %25
%40 = phi i1 [ true, %25 ], [ %38, %32 ]
br label %41
41: ; preds = %39, %19
%42 = phi i1 [ false, %19 ], [ %40, %39 ]
%43 = zext i1 %42 to i32
ret i32 %43
}

LLVM IR (-O2):
define i32 @is_glx_extension_supported(i32* %0, i8* nocapture %1) {
%3 = tail call i32 @DefaultScreen(i32* %0)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = tail call i8* @glXQueryExtensionsString(i32* %0, i32 %3)
%6 = tail call i8* @strstr(i8* dereferenceable(1) %5, i8* dereferenceable(1) %1)
%7 = icmp eq i8* %6, null
br i1 %7, label %15, label %8
8: ; preds = %2
%9 = getelementptr inbounds i8, i8* %6, i64 %4
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 32
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = icmp eq i8 %10, 0
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %8, %12, %2
%16 = phi i32 [ 0, %2 ], [ 1, %8 ], [ %14, %12 ]
ret i32 %16
}