#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*/ isalnum(char const);
int /*<<< orphan*/ isascii(char const);
bool could_be_servicename(char const *s, char const *e) {
  char const *const s0 = s;
  if (s == e)
    return false;
  for (; s < e; s++) {
    if (!isascii(*s) || (!isalnum(*s) && *s != '-'))
      return false;
    if (*s == '-' && (s > s0 && s[-1] == '-'))
      return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<could_be_servicename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    1152 <could_be_servicename+0x32>
movl   $0x0,-0x4(%rbp)
jmp    1203 <could_be_servicename+0xe3>
jmp    1157 <could_be_servicename+0x37>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11fc <could_be_servicename+0xdc>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isascii@plt>
cmp    $0x0,%eax
je     119f <could_be_servicename+0x7f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    11ab <could_be_servicename+0x8b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     11ab <could_be_servicename+0x8b>
movl   $0x0,-0x4(%rbp)
jmp    1203 <could_be_servicename+0xe3>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11e6 <could_be_servicename+0xc6>
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    11e6 <could_be_servicename+0xc6>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2d,%eax
jne    11e6 <could_be_servicename+0xc6>
movl   $0x0,-0x4(%rbp)
jmp    1203 <could_be_servicename+0xe3>
jmp    11eb <could_be_servicename+0xcb>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1157 <could_be_servicename+0x37>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<could_be_servicename>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
cmp    %rsi,%rdi
je     1187 <could_be_servicename+0x67>
jae    1181 <could_be_servicename+0x61>
mov    %rsi,%rbx
mov    %rdi,%r15
sub    %rdi,%rbx
mov    %rdi,%rbp
jmp    114a <could_be_servicename+0x2a>
nop
add    $0x1,%rbp
add    $0xffffffffffffffff,%rbx
je     1181 <could_be_servicename+0x61>
movsbl 0x0(%rbp),%edi
call   1040 <isascii@plt>
test   %eax,%eax
je     1187 <could_be_servicename+0x67>
movsbl 0x0(%rbp),%edi
call   1030 <isalnum@plt>
movzbl 0x0(%rbp),%ecx
test   %eax,%eax
jne    116f <could_be_servicename+0x4f>
cmp    $0x2d,%cl
mov    $0x2d,%cl
jne    1187 <could_be_servicename+0x67>
cmp    $0x2d,%cl
jne    1140 <could_be_servicename+0x20>
cmp    %r15,%rbp
jbe    1140 <could_be_servicename+0x20>
cmpb   $0x2d,-0x1(%rbp)
jne    1140 <could_be_servicename+0x20>
jmp    1187 <could_be_servicename+0x67>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @could_be_servicename(i8* %0, i8* readnone %1) {
%3 = ptrtoint i8* %0 to i64
%4 = ptrtoint i8* %1 to i64
%5 = icmp eq i8* %0, %1
br i1 %5, label %35, label %6
6: ; preds = %2
%7 = icmp ult i8* %0, %1
br i1 %7, label %8, label %35
8: ; preds = %6
%9 = sub i64 %4, %3
%10 = getelementptr i8, i8* %0, i64 %9
br label %11
11: ; preds = %8, %32
%12 = phi i8* [ %33, %32 ], [ %0, %8 ]
%13 = load i8, i8* %12
%14 = tail call i32 @isascii(i8 signext %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %35, label %16
16: ; preds = %11
%17 = load i8, i8* %12
%18 = tail call i32 @isalnum(i8 signext %17)
%19 = icmp eq i32 %18, 0
%20 = load i8, i8* %12
br i1 %19, label %21, label %23
21: ; preds = %16
%22 = icmp eq i8 %20, 45
br i1 %22, label %23, label %35
23: ; preds = %16, %21
%24 = phi i8 [ 45, %21 ], [ %20, %16 ]
%25 = icmp eq i8 %24, 45
%26 = icmp ugt i8* %12, %0
%27 = and i1 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = getelementptr inbounds i8, i8* %12, i64 -1
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 45
br i1 %31, label %35, label %32
32: ; preds = %23, %28
%33 = getelementptr inbounds i8, i8* %12, i64 1
%34 = icmp eq i8* %33, %10
br i1 %34, label %35, label %11
35: ; preds = %21, %11, %28, %32, %6, %2
%36 = phi i32 [ 0, %2 ], [ 1, %6 ], [ 0, %21 ], [ 0, %11 ], [ 0, %28 ], [ 1, %32 ]
ret i32 %36
}