#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*/ exit(int);
int glutExtensionSupported(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strlen(char *);
void wrangleExtensionName(char *extension) {
  char buffer[512];
  int rc, len;
  sprintf(buffer, " %s", extension);
  rc = glutExtensionSupported(buffer);
  if (rc) {
    printf("FAIL: test20, space prefix\n");
    exit(1);
  }
  sprintf(buffer, "%s ", extension);
  rc = glutExtensionSupported(buffer);
  if (rc) {
    printf("FAIL: test20, space suffix\n");
    exit(1);
  }
  sprintf(buffer, "GL_%s", extension);
  rc = glutExtensionSupported(buffer);
  if (rc) {
    printf("FAIL: test20, GL_ prefix\n");
    exit(1);
  }
  sprintf(buffer, "%s", extension + 1);
  rc = glutExtensionSupported(buffer);
  if (rc) {
    printf("FAIL: test20, missing first character\n");
    exit(1);
  }
  sprintf(buffer, "%s", extension);
  len = (int)strlen(buffer);
  if (len > 0) {
    buffer[len - 1] = '\0';
  }
  rc = glutExtensionSupported(buffer);
  if (rc) {
    printf("FAIL: test20, mising last character\n");
    exit(1);
  }
  sprintf(buffer, "%s", extension);
  len = (int)strlen(buffer);
  if (len > 0) {
    buffer[len - 1] = 'X';
  }
  rc = glutExtensionSupported(buffer);
  if (rc) {
    printf("FAIL: test20, changed last character\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<wrangleExtensionName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe8f(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1030 <glutExtensionSupported@plt>
mov    %eax,-0x214(%rbp)
cmpl   $0x0,-0x214(%rbp)
je     11ab <wrangleExtensionName+0x5b>
lea    0xe68(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe63(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1030 <glutExtensionSupported@plt>
mov    %eax,-0x214(%rbp)
cmpl   $0x0,-0x214(%rbp)
je     11f7 <wrangleExtensionName+0xa7>
lea    0xe3c(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe37(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1030 <glutExtensionSupported@plt>
mov    %eax,-0x214(%rbp)
cmpl   $0x0,-0x214(%rbp)
je     1243 <wrangleExtensionName+0xf3>
lea    0xe12(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
add    $0x1,%rdx
lea    0xda8(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1030 <glutExtensionSupported@plt>
mov    %eax,-0x214(%rbp)
cmpl   $0x0,-0x214(%rbp)
je     1293 <wrangleExtensionName+0x143>
lea    0xddc(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xd5c(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x218(%rbp)
cmpl   $0x0,-0x218(%rbp)
jle    12dc <wrangleExtensionName+0x18c>
mov    -0x218(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x210(%rbp,%rax,1)
lea    -0x210(%rbp),%rdi
call   1030 <glutExtensionSupported@plt>
mov    %eax,-0x214(%rbp)
cmpl   $0x0,-0x214(%rbp)
je     1311 <wrangleExtensionName+0x1c1>
lea    0xd85(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xcde(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x218(%rbp)
cmpl   $0x0,-0x218(%rbp)
jle    135a <wrangleExtensionName+0x20a>
mov    -0x218(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x58,-0x210(%rbp,%rax,1)
58
lea    -0x210(%rbp),%rdi
call   1030 <glutExtensionSupported@plt>
mov    %eax,-0x214(%rbp)
cmpl   $0x0,-0x214(%rbp)
je     138f <wrangleExtensionName+0x23f>
lea    0xd2c(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wrangleExtensionName>:
push   %r15
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rdi,%rbx
lea    0xe8a(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
call   1070 <sprintf@plt>
mov    %r14,%rdi
call   1050 <glutExtensionSupported@plt>
test   %eax,%eax
jne    126a <wrangleExtensionName+0x10a>
lea    0xe69(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
call   1070 <sprintf@plt>
mov    %r14,%rdi
call   1050 <glutExtensionSupported@plt>
test   %eax,%eax
jne    1273 <wrangleExtensionName+0x113>
lea    0xe48(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
call   1070 <sprintf@plt>
mov    %r14,%rdi
call   1050 <glutExtensionSupported@plt>
test   %eax,%eax
jne    127c <wrangleExtensionName+0x11c>
lea    0x1(%rbx),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1050 <glutExtensionSupported@plt>
test   %eax,%eax
jne    1285 <wrangleExtensionName+0x125>
mov    $0xffffffff,%r15d
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    1224 <wrangleExtensionName+0xc4>
add    %r15d,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1050 <glutExtensionSupported@plt>
test   %eax,%eax
jne    128e <wrangleExtensionName+0x12e>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    1251 <wrangleExtensionName+0xf1>
add    %r15d,%eax
movb   $0x58,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1050 <glutExtensionSupported@plt>
test   %eax,%eax
jne    1297 <wrangleExtensionName+0x137>
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe40(%rip),%rdi
jmp    129e <wrangleExtensionName+0x13e>
lea    0xe1c(%rip),%rdi
jmp    129e <wrangleExtensionName+0x13e>
lea    0xdfa(%rip),%rdi
jmp    129e <wrangleExtensionName+0x13e>
lea    0xdcb(%rip),%rdi
jmp    129e <wrangleExtensionName+0x13e>
lea    0xd9e(%rip),%rdi
jmp    129e <wrangleExtensionName+0x13e>
lea    0xd70(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c" %s\00"
@.str.1 = [28 x i8] c"FAIL: test20, space prefix\0A\00"
@.str.2 = [4 x i8] c"%s \00"
@.str.3 = [28 x i8] c"FAIL: test20, space suffix\0A\00"
@.str.4 = [6 x i8] c"GL_%s\00"
@.str.5 = [26 x i8] c"FAIL: test20, GL_ prefix\0A\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [39 x i8] c"FAIL: test20, missing first character\0A\00"
@.str.8 = [37 x i8] c"FAIL: test20, mising last character\0A\00"
@.str.9 = [38 x i8] c"FAIL: test20, changed last character\0A\00"
define void @wrangleExtensionName(i8* %0) {
%2 = alloca i8*
%3 = alloca [512 x i8]
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = load i8*, i8** %2
%8 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%10 = call i32 @glutExtensionSupported(i8* %9)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %1
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%18 = load i8*, i8** %2
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%21 = call i32 @glutExtensionSupported(i8* %20)
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %16
%25 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %16
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%29 = load i8*, i8** %2
%30 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %29)
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%32 = call i32 @glutExtensionSupported(i8* %31)
store i32 %32, i32* %4
%33 = load i32, i32* %4
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %27
%36 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %27
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%40 = load i8*, i8** %2
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = call i32 @sprintf(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %41)
%43 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%44 = call i32 @glutExtensionSupported(i8* %43)
store i32 %44, i32* %4
%45 = load i32, i32* %4
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %38
%48 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %38
%51 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%52 = load i8*, i8** %2
%53 = call i32 @sprintf(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %52)
%54 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%55 = call i64 @strlen(i8* %54)
%56 = trunc i64 %55 to i32
store i32 %56, i32* %5
%57 = load i32, i32* %5
%58 = icmp sgt i32 %57, 0
br i1 %58, label %59, label %64
59: ; preds = %50
%60 = load i32, i32* %5
%61 = sub nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %62
store i8 0, i8* %63
br label %64
64: ; preds = %59, %50
%65 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%66 = call i32 @glutExtensionSupported(i8* %65)
store i32 %66, i32* %4
%67 = load i32, i32* %4
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %64
%70 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0))
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %64
%73 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%74 = load i8*, i8** %2
%75 = call i32 @sprintf(i8* %73, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %74)
%76 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%77 = call i64 @strlen(i8* %76)
%78 = trunc i64 %77 to i32
store i32 %78, i32* %5
%79 = load i32, i32* %5
%80 = icmp sgt i32 %79, 0
br i1 %80, label %81, label %86
81: ; preds = %72
%82 = load i32, i32* %5
%83 = sub nsw i32 %82, 1
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %84
store i8 88, i8* %85
br label %86
86: ; preds = %81, %72
%87 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%88 = call i32 @glutExtensionSupported(i8* %87)
store i32 %88, i32* %4
%89 = load i32, i32* %4
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %86
%92 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0))
%93 = call i32 @exit(i32 1)
unreachable
94: ; preds = %86
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c" %s\00"
@.str.2 = [4 x i8] c"%s \00"
@.str.4 = [6 x i8] c"GL_%s\00"
@str = [37 x i8] c"FAIL: test20, changed last character\00"
@str.10 = [36 x i8] c"FAIL: test20, mising last character\00"
@str.11 = [38 x i8] c"FAIL: test20, missing first character\00"
@str.12 = [25 x i8] c"FAIL: test20, GL_ prefix\00"
@str.13 = [27 x i8] c"FAIL: test20, space suffix\00"
@str.14 = [27 x i8] c"FAIL: test20, space prefix\00"
define void @wrangleExtensionName(i8* %0) {
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = call i32 @glutExtensionSupported(i8* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.14, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%12 = call i32 @glutExtensionSupported(i8* %3)
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %10
%18 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%19 = call i32 @glutExtensionSupported(i8* %3)
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.12, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %17
%25 = getelementptr inbounds i8, i8* %0, i64 1
%26 = call i8* @strcpy(i8* %3, i8* %25)
%27 = call i32 @glutExtensionSupported(i8* %3)
%28 = icmp eq i32 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %24
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.11, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %24
%33 = call i8* @strcpy(i8* %3, i8* dereferenceable(1) %0)
%34 = call i64 @strlen(i8* %3)
%35 = trunc i64 %34 to i32
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %32
%38 = add i64 %34, 4294967295
%39 = and i64 %38, 4294967295
%40 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %39
store i8 0, i8* %40
br label %41
41: ; preds = %37, %32
%42 = call i32 @glutExtensionSupported(i8* %3)
%43 = icmp eq i32 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.10, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %41
%48 = call i8* @strcpy(i8* %3, i8* dereferenceable(1) %0)
%49 = call i64 @strlen(i8* %3)
%50 = trunc i64 %49 to i32
%51 = icmp sgt i32 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %47
%53 = add i64 %49, 4294967295
%54 = and i64 %53, 4294967295
%55 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %54
store i8 88, i8* %55
br label %56
56: ; preds = %52, %47
%57 = call i32 @glutExtensionSupported(i8* %3)
%58 = icmp eq i32 %57, 0
br i1 %58, label %62, label %59
59: ; preds = %56
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %56
ret void
}