#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*/ *strchr(char *, char const);
size_t strlen(char const *);
int check_group_name(const char *gname) {
  size_t len = strlen(gname);
  const char *p;
  if (len > 20)
    return -1;
  for (p = gname; *p; p++) {
    if (strchr(
            "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-",
            *p) == NULL)
      return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_group_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x14,-0x18(%rbp)
jbe    1150 <check_group_name+0x30>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ab <check_group_name+0x8b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a4 <check_group_name+0x84>
mov    -0x20(%rbp),%rax
lea    0xe90(%rip),%rdi
movsbl (%rax),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    118e <check_group_name+0x6e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ab <check_group_name+0x8b>
jmp    1193 <check_group_name+0x73>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1158 <check_group_name+0x38>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_group_name>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    $0xffffffff,%r14d
cmp    $0x14,%rax
ja     116e <check_group_name+0x4e>
mov    (%rbx),%al
test   %al,%al
je     116b <check_group_name+0x4b>
add    $0x1,%rbx
lea    0xeb7(%rip),%rbp
nopl   0x0(%rax)
movsbl %al,%esi
mov    %rbp,%rdi
call   1040 <strchr@plt>
test   %rax,%rax
je     116e <check_group_name+0x4e>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <check_group_name+0x30>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [65 x i8] c"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-\00"
define i32 @check_group_name(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i64 @strlen(i8* %6)
store i64 %7, i64* %4
%8 = load i64, i64* %4
%9 = icmp ugt i64 %8, 20
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 -1, i32* %2
br label %28
11: ; preds = %1
%12 = load i8*, i8** %3
store i8* %12, i8** %5
br label %13
13: ; preds = %24, %11
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = call i32* @strchr(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8 signext %19)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %23
22: ; preds = %17
store i32 -1, i32* %2
br label %28
23: ; preds = %17
br label %24
24: ; preds = %23
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %5
br label %13
27: ; preds = %13
store i32 0, i32* %2
br label %28
28: ; preds = %27, %22, %10
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [65 x i8] c"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-\00"
define i32 @check_group_name(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = icmp ugt i64 %2, 20
br i1 %3, label %16, label %4
4: ; preds = %1
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %16, label %10
7: ; preds = %10
%8 = load i8, i8* %15
%9 = icmp eq i8 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %4, %7
%11 = phi i8 [ %8, %7 ], [ %5, %4 ]
%12 = phi i8* [ %15, %7 ], [ %0, %4 ]
%13 = tail call i32* @strchr(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8 signext %11)
%14 = icmp eq i32* %13, null
%15 = getelementptr inbounds i8, i8* %12, i64 1
br i1 %14, label %16, label %7
16: ; preds = %10, %7, %4, %1
%17 = phi i32 [ -1, %1 ], [ 0, %4 ], [ -1, %10 ], [ 0, %7 ]
ret i32 %17
}