#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 *, char);
int strlen(char *);
scalar_t__ strstr(char *, char *);
int glextd_is_supported(char *extension) {
  const GLubyte *e = NULL;
  const GLubyte *s;
  GLubyte *w, *t;
  if (extension == NULL || extension[0] == 0)
    return 0;
  w = (GLubyte *)strchr(extension, ' ');
  if (w != NULL)
    return 0;
  e = glGetString(GL_EXTENSIONS);
  s = e;
  while (1) {
    w = (GLubyte *)strstr((char *)s, extension);
    if (w == NULL)
      break;
    t = w + strlen(extension);
    if (w == s || *(w - 1) == ' ') {
      if (*t == ' ' || *t == 0)
        return 1;
    }
    s = t;
  }
  return 0;
}


x86 assembly (clang, -O0):
<glextd_is_supported>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     116f <glextd_is_supported+0x2f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    117b <glextd_is_supported+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    1264 <glextd_is_supported+0x124>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a4 <glextd_is_supported+0x64>
movl   $0x0,-0x4(%rbp)
jmp    1264 <glextd_is_supported+0x124>
mov    0x2e35(%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    11df <glextd_is_supported+0x9f>
jmp    125d <glextd_is_supported+0x11d>
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     121f <glextd_is_supported+0xdf>
mov    -0x28(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x20,%eax
jne    1250 <glextd_is_supported+0x110>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     123f <glextd_is_supported+0xff>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    124b <glextd_is_supported+0x10b>
movl   $0x1,-0x4(%rbp)
jmp    1264 <glextd_is_supported+0x124>
jmp    1250 <glextd_is_supported+0x110>
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11be <glextd_is_supported+0x7e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glextd_is_supported>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r14d,%r14d
test   %rdi,%rdi
je     116a <glextd_is_supported+0x2a>
mov    %rdi,%r15
cmpb   $0x0,(%rdi)
je     116a <glextd_is_supported+0x2a>
mov    %r15,%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1176 <glextd_is_supported+0x36>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e63(%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     116a <glextd_is_supported+0x2a>
mov    %rax,%rbx
jmp    11b9 <glextd_is_supported+0x79>
nopl   0x0(%rax)
testb  $0xdf,0x0(%rbp)
je     11d7 <glextd_is_supported+0x97>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     116a <glextd_is_supported+0x2a>
mov    %rbp,%r12
mov    %r15,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbp
add    %rbx,%rbp
cmp    %rbx,%r12
je     11a0 <glextd_is_supported+0x60>
cmpb   $0x20,-0x1(%rbx)
je     11a0 <glextd_is_supported+0x60>
jmp    11a6 <glextd_is_supported+0x66>
mov    $0x1,%r14d
jmp    116a <glextd_is_supported+0x2a>

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

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