#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 char const GLubyte;

/* Variables and functions */
int /*<<< orphan*/ GL_EXTENSIONS;
char *glGetString(int /*<<< orphan*/);
scalar_t__ strchr(char const *, char);
int strlen(char const *);
scalar_t__ strstr(char const *, char const *);
int CheckForExtension(const char *extension) {
  const GLubyte *extensions = NULL, *start;
  GLubyte *where, *terminator;
  where = (GLubyte *)strchr(extension, ' ');
  if (where || *extension == '\0')
    return 0;
  extensions = glGetString(GL_EXTENSIONS);
  start = extensions;
  for (;;) {
    where = (GLubyte *)strstr((const char *)start, extension);
    if (!where)
      break;
    terminator = where + strlen(extension);
    if (where == start || *(where - 1) == ' ')
      if (*terminator == ' ' || *terminator == '\0')
        return 1;
    start = terminator;
  }
  return 0;
}


x86 assembly (clang, -O0):
<CheckForExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1181 <CheckForExtension+0x41>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    118d <CheckForExtension+0x4d>
movl   $0x0,-0x4(%rbp)
jmp    124d <CheckForExtension+0x10d>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
call   1050 <glGetString@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11c8 <CheckForExtension+0x88>
jmp    1246 <CheckForExtension+0x106>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     1208 <CheckForExtension+0xc8>
mov    -0x28(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x20,%eax
jne    1239 <CheckForExtension+0xf9>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1228 <CheckForExtension+0xe8>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1234 <CheckForExtension+0xf4>
movl   $0x1,-0x4(%rbp)
jmp    124d <CheckForExtension+0x10d>
jmp    1239 <CheckForExtension+0xf9>
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11a7 <CheckForExtension+0x67>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CheckForExtension>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
mov    $0x20,%esi
call   1040 <strchr@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     1169 <CheckForExtension+0x29>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
cmpb   $0x0,(%r15)
je     115d <CheckForExtension+0x1d>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1050 <glGetString@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     115d <CheckForExtension+0x1d>
mov    %rax,%rbx
jmp    11b9 <CheckForExtension+0x79>
cs nopw 0x0(%rax,%rax,1)
nop
testb  $0xdf,0x0(%rbp)
je     11d7 <CheckForExtension+0x97>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     115d <CheckForExtension+0x1d>
mov    %rbp,%r12
mov    %r15,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbp
add    %rbx,%rbp
cmp    %rbx,%r12
je     11a0 <CheckForExtension+0x60>
cmpb   $0x20,-0x1(%rbx)
je     11a0 <CheckForExtension+0x60>
jmp    11a6 <CheckForExtension+0x66>
mov    $0x1,%r14d
jmp    115d <CheckForExtension+0x1d>

LLVM IR (-O0):
@GL_EXTENSIONS = global i32 0
define i32 @CheckForExtension(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
store i8* null, i8** %4
%8 = load i8*, i8** %3
%9 = call i64 @strchr(i8* %8, i8 signext 32)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = icmp ne i8* %11, null
br i1 %12, label %18, label %13
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13, %1
store i32 0, i32* %2
br label %61
19: ; preds = %13
%20 = load i32, i32* @GL_EXTENSIONS
%21 = call i8* @glGetString(i32 %20)
store i8* %21, i8** %4
%22 = load i8*, i8** %4
store i8* %22, i8** %5
br label %23
23: ; preds = %58, %19
%24 = load i8*, i8** %5
%25 = load i8*, i8** %3
%26 = call i64 @strstr(i8* %24, i8* %25)
%27 = inttoptr i64 %26 to i8*
store i8* %27, i8** %6
%28 = load i8*, i8** %6
%29 = icmp ne i8* %28, null
br i1 %29, label %31, label %30
30: ; preds = %23
br label %60
31: ; preds = %23
%32 = load i8*, i8** %6
%33 = load i8*, i8** %3
%34 = call i32 @strlen(i8* %33)
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
store i8* %36, i8** %7
%37 = load i8*, i8** %6
%38 = load i8*, i8** %5
%39 = icmp eq i8* %37, %38
br i1 %39, label %46, label %40
40: ; preds = %31
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i64 -1
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 32
br i1 %45, label %46, label %58
46: ; preds = %40, %31
%47 = load i8*, i8** %7
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 32
br i1 %50, label %56, label %51
51: ; preds = %46
%52 = load i8*, i8** %7
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %51, %46
store i32 1, i32* %2
br label %61
57: ; preds = %51
br label %58
58: ; preds = %57, %40
%59 = load i8*, i8** %7
store i8* %59, i8** %5
br label %23
60: ; preds = %30
store i32 0, i32* %2
br label %61
61: ; preds = %60, %56, %18
%62 = load i32, i32* %2
ret i32 %62
}

LLVM IR (-O2):
@GL_EXTENSIONS = global i32 0
define i32 @CheckForExtension(i8* %0) {
%2 = tail call i64 @strchr(i8* %0, i8 signext 32)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %29
4: ; preds = %1
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %29, label %7
7: ; preds = %4
%8 = load i32, i32* @GL_EXTENSIONS
%9 = tail call i8* @glGetString(i32 %8)
%10 = tail call i64 @strstr(i8* %9, i8* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %29, label %12
12: ; preds = %7, %26
%13 = phi i64 [ %27, %26 ], [ %10, %7 ]
%14 = phi i8* [ %18, %26 ], [ %9, %7 ]
%15 = inttoptr i64 %13 to i8*
%16 = tail call i32 @strlen(i8* %0)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = icmp eq i8* %14, %15
br i1 %19, label %24, label %20
20: ; preds = %12
%21 = getelementptr inbounds i8, i8* %15, i64 -1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 32
br i1 %23, label %24, label %26
24: ; preds = %20, %12
%25 = load i8, i8* %18
switch i8 %25, label %26 [
i8 32, label %29
i8 0, label %29
]
26: ; preds = %24, %20
%27 = tail call i64 @strstr(i8* %18, i8* %0)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %12
29: ; preds = %24, %24, %26, %7, %1, %4
%30 = phi i32 [ 0, %4 ], [ 0, %1 ], [ 0, %7 ], [ 1, %24 ], [ 1, %24 ], [ 0, %26 ]
ret i32 %30
}