#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 *, int);
char *get_subst_symbol(const char *begin, int 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    %esi,-0x14(%rbp)
mov    %al,-0x15(%rbp)
lea    0x2f15(%rip),%rax
mov    %rax,-0x28(%rbp)
cmpb   $0x0,-0x15(%rbp)
je     114d <get_subst_symbol+0x3d>
mov    -0x15(%rbp),%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
movslq -0x14(%rbp),%rax
cmp    $0x7e,%rax
jbe    1168 <get_subst_symbol+0x58>
movq   $0x0,-0x8(%rbp)
jmp    1237 <get_subst_symbol+0x127>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     122c <get_subst_symbol+0x11c>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
jl     11b9 <get_subst_symbol+0xa9>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7a,%eax
jle    1216 <get_subst_symbol+0x106>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jl     11d9 <get_subst_symbol+0xc9>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5a,%eax
jle    1216 <get_subst_symbol+0x106>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     11f9 <get_subst_symbol+0xe9>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jle    1216 <get_subst_symbol+0x106>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     1216 <get_subst_symbol+0x106>
movq   $0x0,-0x8(%rbp)
jmp    1237 <get_subst_symbol+0x127>
jmp    121b <get_subst_symbol+0x10b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    118c <get_subst_symbol+0x7c>
lea    0x2e0d(%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    %esi,%eax
mov    %rdi,%rsi
test   %dl,%dl
je     1131 <get_subst_symbol+0x21>
mov    %dl,0x2f1d(%rip)
lea    0x2f17(%rip),%rbx
cmp    $0x7e,%eax
jbe    113d <get_subst_symbol+0x2d>
jmp    1195 <get_subst_symbol+0x85>
lea    0x2f08(%rip),%rbx
cmp    $0x7e,%eax
ja     1195 <get_subst_symbol+0x85>
mov    %eax,%r14d
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <memcpy@plt>
movb   $0x0,(%rbx,%r14,1)
mov    (%rbx),%cl
lea    0x2ee8(%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   0x0(%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, i32 %1, i8 signext %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %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 i32, i32* %6
%18 = sext i32 %17 to i64
%19 = icmp ugt i64 %18, 126
br i1 %19, label %20, label %21
20: ; preds = %16
store i8* null, i8** %4
br label %76
21: ; preds = %16
%22 = load i8*, i8** %9
%23 = load i8*, i8** %5
%24 = load i32, i32* %6
%25 = call i32 @memcpy(i8* %22, i8* %23, i32 %24)
%26 = load i8*, i8** %9
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 0, i8* %29
%30 = load i8*, i8** %9
store i8* %30, i8** %8
br label %31
31: ; preds = %72, %21
%32 = load i8*, i8** %8
%33 = load i8, i8* %32
%34 = icmp ne i8 %33, 0
br i1 %34, label %35, label %75
35: ; preds = %31
%36 = load i8*, i8** %8
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp sge i32 %38, 97
br i1 %39, label %40, label %45
40: ; preds = %35
%41 = load i8*, i8** %8
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp sle i32 %43, 122
br i1 %44, label %71, label %45
45: ; preds = %40, %35
%46 = load i8*, i8** %8
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp sge i32 %48, 65
br i1 %49, label %50, label %55
50: ; preds = %45
%51 = load i8*, i8** %8
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp sle i32 %53, 90
br i1 %54, label %71, label %55
55: ; preds = %50, %45
%56 = load i8*, i8** %8
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp sge i32 %58, 48
br i1 %59, label %60, label %65
60: ; preds = %55
%61 = load i8*, i8** %8
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp sle i32 %63, 57
br i1 %64, label %71, label %65
65: ; preds = %60, %55
%66 = load i8*, i8** %8
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 95
br i1 %69, label %71, label %70
70: ; preds = %65
store i8* null, i8** %4
br label %76
71: ; preds = %65, %60, %50, %40
br label %72
72: ; preds = %71
%73 = load i8*, i8** %8
%74 = getelementptr inbounds i8, i8* %73, i32 1
store i8* %74, i8** %8
br label %31
75: ; preds = %31
store i8* getelementptr inbounds ([128 x i8], [128 x i8]* @get_subst_symbol.replace_name, i64 0, i64 0), i8** %4
br label %76
76: ; preds = %75, %70, %20
%77 = load i8*, i8** %4
ret i8* %77
}

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