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

/* Variables and functions */
int /*<<< orphan*/ GL_EXTENSIONS;
int GL_FALSE;
int GL_TRUE;
scalar_t__ glGetString(int /*<<< orphan*/);
int strcspn(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int query_extension(char *extName) {
  char *p = (char *)glGetString(GL_EXTENSIONS);
  char *end = p + strlen(p);
  while (p < end) {
    int n = strcspn(p, " ");
    if ((strlen(extName) == n) && (strncmp(extName, p, n) == 0))
      return GL_TRUE;
    p += (n + 1);
  }
  return GL_FALSE;
}


x86 assembly (clang, -O0):
<query_extension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
call   1060 <glGetString@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11f6 <query_extension+0xb6>
mov    -0x18(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1050 <strcspn@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    -0x24(%rbp),%eax
jne    11dd <query_extension+0x9d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11dd <query_extension+0x9d>
mov    0x2e05(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1202 <query_extension+0xc2>
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    117f <query_extension+0x3f>
mov    0x2deb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<query_extension>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
call   1060 <glGetString@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    0x2e7a(%rip),%r12
test   %eax,%eax
jle    11d1 <query_extension+0x91>
movslq %eax,%r13
add    %rbx,%r13
lea    0xe81(%rip),%r15
jmp    119f <query_extension+0x5f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq %ebp,%rax
add    %rax,%rbx
add    $0x1,%rbx
cmp    %r13,%rbx
jae    11d1 <query_extension+0x91>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcspn@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    %ebp,%eax
jne    1190 <query_extension+0x50>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1190 <query_extension+0x50>
mov    0x2e07(%rip),%r12
mov    (%r12),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@GL_EXTENSIONS = global i32 0
@.str = [2 x i8] c" \00"
@GL_TRUE = global i32 0
@GL_FALSE = global i32 0
define i32 @query_extension(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i32, i32* @GL_EXTENSIONS
%8 = call i64 @glGetString(i32 %7)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %11)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
store i8* %14, i8** %5
br label %15
15: ; preds = %34, %1
%16 = load i8*, i8** %4
%17 = load i8*, i8** %5
%18 = icmp ult i8* %16, %17
br i1 %18, label %19, label %40
19: ; preds = %15
%20 = load i8*, i8** %4
%21 = call i32 @strcspn(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %21, i32* %6
%22 = load i8*, i8** %3
%23 = call i32 @strlen(i8* %22)
%24 = load i32, i32* %6
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %34
26: ; preds = %19
%27 = load i8*, i8** %3
%28 = load i8*, i8** %4
%29 = load i32, i32* %6
%30 = call i64 @strncmp(i8* %27, i8* %28, i32 %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %26
%33 = load i32, i32* @GL_TRUE
store i32 %33, i32* %2
br label %42
34: ; preds = %26, %19
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
%37 = load i8*, i8** %4
%38 = sext i32 %36 to i64
%39 = getelementptr inbounds i8, i8* %37, i64 %38
store i8* %39, i8** %4
br label %15
40: ; preds = %15
%41 = load i32, i32* @GL_FALSE
store i32 %41, i32* %2
br label %42
42: ; preds = %40, %32
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
@GL_EXTENSIONS = global i32 0
@.str = [2 x i8] c" \00"
@GL_TRUE = global i32 0
@GL_FALSE = global i32 0
define i32 @query_extension(i8* %0) {
%2 = load i32, i32* @GL_EXTENSIONS
%3 = tail call i64 @glGetString(i32 %2)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @strlen(i8* %4)
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %4, i64 %6
%8 = icmp sgt i32 %5, 0
br i1 %8, label %9, label %22
9: ; preds = %1, %17
%10 = phi i8* [ %20, %17 ], [ %4, %1 ]
%11 = tail call i32 @strcspn(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @strlen(i8* %0)
%13 = icmp eq i32 %12, %11
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = tail call i64 @strncmp(i8* %0, i8* %10, i32 %11)
%16 = icmp eq i64 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %9, %14
%18 = add nsw i32 %11, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %10, i64 %19
%21 = icmp ult i8* %20, %7
br i1 %21, label %9, label %22
22: ; preds = %14, %17, %1
%23 = phi i32* [ @GL_FALSE, %1 ], [ @GL_FALSE, %17 ], [ @GL_TRUE, %14 ]
%24 = load i32, i32* %23
ret i32 %24
}