#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 */
struct lm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ freeMem(char *);
char *hmacMd5(char *, char *);
scalar_t__ isalnum(char);
scalar_t__ isspace(char);
char *lmAlloc(struct lm *, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
char *skipLeadingSpaces(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *symbolify(char *prefix, char *original, struct lm *lm) {
  int prefixSize = strlen(prefix);
  char *result = lmAlloc(lm, strlen(original) + prefixSize + 1);
  memcpy(result, prefix, prefixSize);
  char *in = skipLeadingSpaces(original);
  char *out = result + prefixSize;
  char c;
  while ((c = *in++) != 0) {
    if (isspace(c))
      *out++ = '_';
    else if (isalnum(c) || c == '.' || c == '_')
      *out++ = c;
  }
  *out++ = 0;
  int len = strlen(result) - prefixSize;
  if (len > 32) {
    char *md5 = hmacMd5("", original);
    strcpy(result + prefixSize, md5);
    freeMem(md5);
  }
  return result;
}


x86 assembly (clang, -O0):
<symbolify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
add    -0x1c(%rbp),%esi
add    $0x1,%esi
call   10b0 <lmAlloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1090 <memcpy@plt>
mov    -0x10(%rbp),%rdi
call   1070 <skipLeadingSpaces@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%al
mov    %al,-0x39(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     1297 <symbolify+0x107>
movsbl -0x39(%rbp),%edi
call   1080 <isspace@plt>
cmp    $0x0,%rax
je     124c <symbolify+0xbc>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x5f,(%rax)
jmp    1292 <symbolify+0x102>
movsbl -0x39(%rbp),%edi
call   1050 <isalnum@plt>
cmp    $0x0,%rax
jne    1279 <symbolify+0xe9>
movsbl -0x39(%rbp),%eax
cmp    $0x2e,%eax
je     1279 <symbolify+0xe9>
movsbl -0x39(%rbp),%eax
cmp    $0x5f,%eax
jne    128d <symbolify+0xfd>
mov    -0x39(%rbp),%cl
mov    -0x38(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x38(%rbp)
mov    %cl,(%rax)
jmp    1292 <symbolify+0x102>
jmp    1202 <symbolify+0x72>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
sub    -0x1c(%rbp),%eax
mov    %eax,-0x40(%rbp)
cmpl   $0x20,-0x40(%rbp)
jle    12f3 <symbolify+0x163>
mov    -0x10(%rbp),%rsi
lea    0xd33(%rip),%rdi
call   10a0 <hmacMd5@plt>
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    -0x48(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x48(%rbp),%rdi
call   1060 <freeMem@plt>
mov    -0x28(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<symbolify>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    (%r12,%rax,1),%esi
add    $0x1,%esi
mov    %r14,%rdi
call   10b0 <lmAlloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1090 <memcpy@plt>
mov    %rbx,0x8(%rsp)
mov    %rbx,%rdi
call   1070 <skipLeadingSpaces@plt>
movslq %r12d,%r14
mov    %rbp,0x10(%rsp)
add    %rbp,%r14
mov    (%rax),%r15b
mov    %r14,%r13
test   %r15b,%r15b
je     1259 <symbolify+0xc9>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %r14,%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %r15b,%ebp
mov    %ebp,%edi
call   1080 <isspace@plt>
mov    $0x5f,%cl
test   %rax,%rax
jne    1231 <symbolify+0xa1>
mov    %ebp,%edi
call   1050 <isalnum@plt>
test   %rax,%rax
je     1248 <symbolify+0xb8>
mov    %r15d,%ecx
mov    %cl,0x0(%r13)
add    $0x1,%r13
movzbl (%rbx),%r15d
add    $0x1,%rbx
test   %r15b,%r15b
jne    1210 <symbolify+0x80>
jmp    1259 <symbolify+0xc9>
cmp    $0x5f,%r15b
je     122e <symbolify+0x9e>
mov    %r15d,%ecx
cmp    $0x2e,%r15b
je     1231 <symbolify+0xa1>
jmp    1239 <symbolify+0xa9>
movb   $0x0,0x0(%r13)
mov    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
sub    %r12d,%eax
cmp    $0x21,%eax
jl     129a <symbolify+0x10a>
lea    0xd86(%rip),%rdi
mov    0x8(%rsp),%rsi
call   10a0 <hmacMd5@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1060 <freeMem@plt>
mov    %rbp,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.lm = type { i32 }
@.str = [1 x i8] zeroinitializer
define i8* @symbolify(i8* %0, i8* %1, %struct.lm* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.lm*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8
%12 = alloca i32
%13 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store %struct.lm* %2, %struct.lm** %6
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %7
%16 = load %struct.lm*, %struct.lm** %6
%17 = load i8*, i8** %5
%18 = call i32 @strlen(i8* %17)
%19 = load i32, i32* %7
%20 = add nsw i32 %18, %19
%21 = add nsw i32 %20, 1
%22 = call i8* @lmAlloc(%struct.lm* %16, i32 %21)
store i8* %22, i8** %8
%23 = load i8*, i8** %8
%24 = load i8*, i8** %4
%25 = load i32, i32* %7
%26 = call i32 @memcpy(i8* %23, i8* %24, i32 %25)
%27 = load i8*, i8** %5
%28 = call i8* @skipLeadingSpaces(i8* %27)
store i8* %28, i8** %9
%29 = load i8*, i8** %8
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8* %32, i8** %10
br label %33
33: ; preds = %63, %3
%34 = load i8*, i8** %9
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %9
%36 = load i8, i8* %34
store i8 %36, i8* %11
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %64
39: ; preds = %33
%40 = load i8, i8* %11
%41 = call i64 @isspace(i8 signext %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i8*, i8** %10
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %10
store i8 95, i8* %44
br label %63
46: ; preds = %39
%47 = load i8, i8* %11
%48 = call i64 @isalnum(i8 signext %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %58, label %50
50: ; preds = %46
%51 = load i8, i8* %11
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 46
br i1 %53, label %58, label %54
54: ; preds = %50
%55 = load i8, i8* %11
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 95
br i1 %57, label %58, label %62
58: ; preds = %54, %50, %46
%59 = load i8, i8* %11
%60 = load i8*, i8** %10
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %10
store i8 %59, i8* %60
br label %62
62: ; preds = %58, %54
br label %63
63: ; preds = %62, %43
br label %33
64: ; preds = %33
%65 = load i8*, i8** %10
%66 = getelementptr inbounds i8, i8* %65, i32 1
store i8* %66, i8** %10
store i8 0, i8* %65
%67 = load i8*, i8** %8
%68 = call i32 @strlen(i8* %67)
%69 = load i32, i32* %7
%70 = sub nsw i32 %68, %69
store i32 %70, i32* %12
%71 = load i32, i32* %12
%72 = icmp sgt i32 %71, 32
br i1 %72, label %73, label %84
73: ; preds = %64
%74 = load i8*, i8** %5
%75 = call i8* @hmacMd5(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %74)
store i8* %75, i8** %13
%76 = load i8*, i8** %8
%77 = load i32, i32* %7
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %76, i64 %78
%80 = load i8*, i8** %13
%81 = call i32 @strcpy(i8* %79, i8* %80)
%82 = load i8*, i8** %13
%83 = call i32 @freeMem(i8* %82)
br label %84
84: ; preds = %73, %64
%85 = load i8*, i8** %8
ret i8* %85
}

LLVM IR (-O2):
%struct.lm = type { i32 }
@.str = [1 x i8] zeroinitializer
define i8* @symbolify(i8* %0, i8* %1, %struct.lm* %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @strlen(i8* %1)
%6 = add i32 %4, 1
%7 = add i32 %6, %5
%8 = tail call i8* @lmAlloc(%struct.lm* %2, i32 %7)
%9 = tail call i32 @memcpy(i8* %8, i8* %0, i32 %4)
%10 = tail call i8* @skipLeadingSpaces(i8* %1)
%11 = sext i32 %4 to i64
%12 = getelementptr inbounds i8, i8* %8, i64 %11
%13 = load i8, i8* %10
%14 = icmp eq i8 %13, 0
br i1 %14, label %34, label %15
15: ; preds = %3, %30
%16 = phi i8 [ %32, %30 ], [ %13, %3 ]
%17 = phi i8* [ %19, %30 ], [ %10, %3 ]
%18 = phi i8* [ %31, %30 ], [ %12, %3 ]
%19 = getelementptr inbounds i8, i8* %17, i64 1
%20 = tail call i64 @isspace(i8 signext %16)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %15
%23 = tail call i64 @isalnum(i8 signext %16)
%24 = freeze i64 %23
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
switch i8 %16, label %30 [
i8 95, label %27
i8 46, label %27
]
27: ; preds = %22, %26, %26, %15
%28 = phi i8 [ 95, %15 ], [ %16, %26 ], [ %16, %26 ], [ %16, %22 ]
%29 = getelementptr inbounds i8, i8* %18, i64 1
store i8 %28, i8* %18
br label %30
30: ; preds = %27, %26
%31 = phi i8* [ %18, %26 ], [ %29, %27 ]
%32 = load i8, i8* %19
%33 = icmp eq i8 %32, 0
br i1 %33, label %34, label %15
34: ; preds = %30, %3
%35 = phi i8* [ %12, %3 ], [ %31, %30 ]
store i8 0, i8* %35
%36 = tail call i32 @strlen(i8* %8)
%37 = sub nsw i32 %36, %4
%38 = icmp sgt i32 %37, 32
br i1 %38, label %39, label %43
39: ; preds = %34
%40 = tail call i8* @hmacMd5(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %1)
%41 = tail call i32 @strcpy(i8* %12, i8* %40)
%42 = tail call i32 @freeMem(i8* %40)
br label %43
43: ; preds = %39, %34
ret i8* %8
}