#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*/ strcpy(unsigned char *, ...);
int /*<<< orphan*/ strncat(unsigned char *, int /*<<< orphan*/, int);
unsigned char tolower(unsigned char);
unsigned char *lock_strip_alpha(unsigned char *key, unsigned char *type) {
  unsigned char *c;
  unsigned char typetext[256], keyout[256];
  int i;
  strcpy(typetext, "");
  strcpy(keyout, "");
  while ((*key != ':') && (*key != '\0')) {
    strncat(typetext, key++, 1);
  }
  if (*key == '\0') {
    type = NULL;
  } else {
    key++;
    for (c = key; *c != '\0'; c++) {
      if (*c == ':')
        *c = '\0';
    }
    strcpy(type, typetext);
    for (c = type; *c != '\0'; ++c) {
      *c = tolower(*c);
    }
  }
  return (key);
}


x86 assembly (clang, -O0):
<lock_strip_alpha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x120(%rbp),%rdi
lea    0xeaf(%rip),%rsi
xor    %eax,%eax
call   1030 <strcpy@plt>
lea    -0x220(%rbp),%rdi
lea    0xe9a(%rip),%rsi
xor    %eax,%eax
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x3a,%ecx
mov    %al,-0x225(%rbp)
je     1198 <lock_strip_alpha+0x68>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x225(%rbp)
mov    -0x225(%rbp),%al
test   $0x1,%al
jne    11ab <lock_strip_alpha+0x7b>
jmp    11d2 <lock_strip_alpha+0xa2>
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    %eax,%esi
mov    $0x1,%edx
call   1040 <strncat@plt>
jmp    116d <lock_strip_alpha+0x3d>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    11ef <lock_strip_alpha+0xbf>
movq   $0x0,-0x10(%rbp)
jmp    1294 <lock_strip_alpha+0x164>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
je     1240 <lock_strip_alpha+0x110>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x3a,%eax
jne    122a <lock_strip_alpha+0xfa>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    122f <lock_strip_alpha+0xff>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1203 <lock_strip_alpha+0xd3>
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
xor    %eax,%eax
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
je     128f <lock_strip_alpha+0x15f>
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1050 <tolower@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    125a <lock_strip_alpha+0x12a>
jmp    1294 <lock_strip_alpha+0x164>
mov    -0x8(%rbp),%rax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lock_strip_alpha>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xeb5(%rip),%r14
mov    %rsp,%r12
mov    %r12,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <strcpy@plt>
lea    0x100(%rsp),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <strcpy@plt>
mov    %rbx,%r14
movzbl (%r14),%eax
test   %al,%al
je     11e8 <lock_strip_alpha+0xb8>
add    $0x1,%r14
cmp    $0x3a,%al
je     1194 <lock_strip_alpha+0x64>
mov    %r12,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
call   1040 <strncat@plt>
add    $0x1,%ebx
jmp    1170 <lock_strip_alpha+0x40>
mov    %r14,%rax
jmp    11a7 <lock_strip_alpha+0x77>
nopl   0x0(%rax)
movb   $0x0,(%rax)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x3a,%cl
je     11a0 <lock_strip_alpha+0x70>
test   %cl,%cl
jne    11a3 <lock_strip_alpha+0x73>
mov    %rsp,%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <strcpy@plt>
mov    (%r15),%al
test   %al,%al
je     11e8 <lock_strip_alpha+0xb8>
add    $0x1,%r15
nopl   0x0(%rax,%rax,1)
movzbl %al,%edi
call   1050 <tolower@plt>
mov    %al,-0x1(%r15)
movzbl (%r15),%eax
add    $0x1,%r15
test   %al,%al
jne    11d0 <lock_strip_alpha+0xa0>
mov    %r14,%rax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @lock_strip_alpha(i8* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = call i32 (i8*, ...) @strcpy(i8* %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @strcpy(i8* %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %12, %2
%10 = phi i8* [ %0, %2 ], [ %13, %12 ]
%11 = load i8, i8* %10
switch i8 %11, label %12 [
i8 0, label %36
i8 58, label %17
]
12: ; preds = %9
%13 = getelementptr inbounds i8, i8* %10, i64 1
%14 = ptrtoint i8* %10 to i64
%15 = trunc i64 %14 to i32
%16 = call i32 @strncat(i8* %5, i32 %15, i32 1)
br label %9
17: ; preds = %9
%18 = getelementptr inbounds i8, i8* %10, i64 1
br label %19
19: ; preds = %23, %17
%20 = phi i8* [ %18, %17 ], [ %24, %23 ]
%21 = load i8, i8* %20
switch i8 %21, label %23 [
i8 0, label %25
i8 58, label %22
]
22: ; preds = %19
store i8 0, i8* %20
br label %23
23: ; preds = %19, %22
%24 = getelementptr inbounds i8, i8* %20, i64 1
br label %19
25: ; preds = %19
%26 = call i32 (i8*, ...) @strcpy(i8* %1, i8* %5)
%27 = load i8, i8* %1
%28 = icmp eq i8 %27, 0
br i1 %28, label %36, label %29
29: ; preds = %25, %29
%30 = phi i8 [ %34, %29 ], [ %27, %25 ]
%31 = phi i8* [ %33, %29 ], [ %1, %25 ]
%32 = call zeroext i8 @tolower(i8 zeroext %30)
store i8 %32, i8* %31
%33 = getelementptr inbounds i8, i8* %31, i64 1
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 0
br i1 %35, label %36, label %29
36: ; preds = %9, %29, %25
%37 = phi i8* [ %18, %25 ], [ %18, %29 ], [ %10, %9 ]
ret i8* %37
}