#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 int /*<<< orphan*/ replace_name;

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
char *get_subst_symbol(const char *begin, size_t len, char prefix) {
  static char replace_name[128];
  char *cp, *start;
  start = replace_name;
  if (prefix)
    *start++ = prefix;
  if (len > sizeof(replace_name) - 2)
    return NULL;
  memcpy(start, begin, len);
  start[len] = 0;
  for (cp = start; *cp; cp++) {
    if (!(*cp >= 'a' && *cp <= 'z') && !(*cp >= 'A' && *cp <= 'Z') &&
        !(*cp >= '0' && *cp <= '9') && !(*cp == '_'))
      return NULL;
  }
  return (replace_name);
}


x86 assembly (clang, -O0):
<get_subst_symbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dl,%al
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %al,-0x19(%rbp)
lea    0x2f14(%rip),%rax
mov    %rax,-0x30(%rbp)
cmpb   $0x0,-0x19(%rbp)
je     114e <get_subst_symbol+0x3e>
mov    -0x19(%rbp),%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
cmpq   $0x7e,-0x18(%rbp)
jbe    1166 <get_subst_symbol+0x56>
movq   $0x0,-0x8(%rbp)
jmp    1236 <get_subst_symbol+0x126>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <memcpy@plt>
mov    -0x30(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     122b <get_subst_symbol+0x11b>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
jl     11b8 <get_subst_symbol+0xa8>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7a,%eax
jle    1215 <get_subst_symbol+0x105>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jl     11d8 <get_subst_symbol+0xc8>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5a,%eax
jle    1215 <get_subst_symbol+0x105>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     11f8 <get_subst_symbol+0xe8>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jle    1215 <get_subst_symbol+0x105>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     1215 <get_subst_symbol+0x105>
movq   $0x0,-0x8(%rbp)
jmp    1236 <get_subst_symbol+0x126>
jmp    121a <get_subst_symbol+0x10a>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    118b <get_subst_symbol+0x7b>
lea    0x2e0e(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_subst_symbol>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rsi
test   %dl,%dl
je     1133 <get_subst_symbol+0x23>
mov    %dl,0x2f1c(%rip)
lea    0x2f16(%rip),%rbx
cmp    $0x7e,%r14
jbe    1140 <get_subst_symbol+0x30>
jmp    1195 <get_subst_symbol+0x85>
lea    0x2f06(%rip),%rbx
cmp    $0x7e,%r14
ja     1195 <get_subst_symbol+0x85>
mov    %rbx,%rdi
mov    %r14,%rdx
call   1030 <memcpy@plt>
movb   $0x0,(%rbx,%r14,1)
mov    (%rbx),%cl
lea    0x2ee7(%rip),%rax
test   %cl,%cl
je     1197 <get_subst_symbol+0x87>
add    $0x1,%rbx
jmp    117b <get_subst_symbol+0x6b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
je     1197 <get_subst_symbol+0x87>
mov    %ecx,%edx
and    $0xdf,%dl
add    $0xbf,%dl
cmp    $0x1a,%dl
jb     1170 <get_subst_symbol+0x60>
cmp    $0x5f,%cl
je     1170 <get_subst_symbol+0x60>
add    $0xd0,%cl
cmp    $0x9,%cl
jbe    1170 <get_subst_symbol+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@get_subst_symbol.replace_name = internal global [128 x i8] zeroinitializer
define i8* @get_subst_symbol(i8* %0, i64 %1, i8 signext %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8 %2, i8* %7
store i8* getelementptr inbounds ([128 x i8], [128 x i8]* @get_subst_symbol.replace_name, i64 0, i64 0), i8** %9
%10 = load i8, i8* %7
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i8, i8* %7
%14 = load i8*, i8** %9
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %9
store i8 %13, i8* %14
br label %16
16: ; preds = %12, %3
%17 = load i64, i64* %6
%18 = icmp ugt i64 %17, 126
br i1 %18, label %19, label %20
19: ; preds = %16
store i8* null, i8** %4
br label %74
20: ; preds = %16
%21 = load i8*, i8** %9
%22 = load i8*, i8** %5
%23 = load i64, i64* %6
%24 = call i32 @memcpy(i8* %21, i8* %22, i64 %23)
%25 = load i8*, i8** %9
%26 = load i64, i64* %6
%27 = getelementptr inbounds i8, i8* %25, i64 %26
store i8 0, i8* %27
%28 = load i8*, i8** %9
store i8* %28, i8** %8
br label %29
29: ; preds = %70, %20
%30 = load i8*, i8** %8
%31 = load i8, i8* %30
%32 = icmp ne i8 %31, 0
br i1 %32, label %33, label %73
33: ; preds = %29
%34 = load i8*, i8** %8
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp sge i32 %36, 97
br i1 %37, label %38, label %43
38: ; preds = %33
%39 = load i8*, i8** %8
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp sle i32 %41, 122
br i1 %42, label %69, label %43
43: ; preds = %38, %33
%44 = load i8*, i8** %8
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp sge i32 %46, 65
br i1 %47, label %48, label %53
48: ; preds = %43
%49 = load i8*, i8** %8
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp sle i32 %51, 90
br i1 %52, label %69, label %53
53: ; preds = %48, %43
%54 = load i8*, i8** %8
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp sge i32 %56, 48
br i1 %57, label %58, label %63
58: ; preds = %53
%59 = load i8*, i8** %8
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp sle i32 %61, 57
br i1 %62, label %69, label %63
63: ; preds = %58, %53
%64 = load i8*, i8** %8
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 95
br i1 %67, label %69, label %68
68: ; preds = %63
store i8* null, i8** %4
br label %74
69: ; preds = %63, %58, %48, %38
br label %70
70: ; preds = %69
%71 = load i8*, i8** %8
%72 = getelementptr inbounds i8, i8* %71, i32 1
store i8* %72, i8** %8
br label %29
73: ; preds = %29
store i8* getelementptr inbounds ([128 x i8], [128 x i8]* @get_subst_symbol.replace_name, i64 0, i64 0), i8** %4
br label %74
74: ; preds = %73, %68, %19
%75 = load i8*, i8** %4
ret i8* %75
}

LLVM IR (-O2):
@get_subst_symbol.replace_name = internal global [128 x i8] zeroinitializer
define i8* @get_subst_symbol(i8* %0, i64 %1, i8 signext %2) {
%4 = icmp eq i8 %2, 0
br i1 %4, label %6, label %5
5: ; preds = %3
store i8 %2, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @get_subst_symbol.replace_name, i64 0, i64 0)
br label %6
6: ; preds = %5, %3
%7 = phi i8* [ getelementptr inbounds ([128 x i8], [128 x i8]* @get_subst_symbol.replace_name, i64 0, i64 1), %5 ], [ getelementptr inbounds ([128 x i8], [128 x i8]* @get_subst_symbol.replace_name, i64 0, i64 0), %3 ]
%8 = icmp ugt i64 %1, 126
br i1 %8, label %29, label %9
9: ; preds = %6
%10 = tail call i32 @memcpy(i8* %7, i8* %0, i64 %1)
%11 = getelementptr inbounds i8, i8* %7, i64 %1
store i8 0, i8* %11
%12 = load i8, i8* %7
%13 = icmp eq i8 %12, 0
br i1 %13, label %29, label %14
14: ; preds = %9, %25
%15 = phi i8 [ %27, %25 ], [ %12, %9 ]
%16 = phi i8* [ %26, %25 ], [ %7, %9 ]
%17 = and i8 %15, -33
%18 = add i8 %17, -65
%19 = icmp ult i8 %18, 26
br i1 %19, label %25, label %20
20: ; preds = %14
%21 = add i8 %15, -48
%22 = icmp ult i8 %21, 10
%23 = icmp eq i8 %15, 95
%24 = or i1 %23, %22
br i1 %24, label %25, label %29
25: ; preds = %20, %14
%26 = getelementptr inbounds i8, i8* %16, i64 1
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %14
29: ; preds = %25, %20, %9, %6
%30 = phi i8* [ null, %6 ], [ getelementptr inbounds ([128 x i8], [128 x i8]* @get_subst_symbol.replace_name, i64 0, i64 0), %9 ], [ getelementptr inbounds ([128 x i8], [128 x i8]* @get_subst_symbol.replace_name, i64 0, i64 0), %25 ], [ null, %20 ]
ret i8* %30
}