char *plugin_name(const char *str) {
  char *buf, *p;
  static const char prefix[] = "sasl-";
  assert(str != ((void *)0));
  buf = malloc(sizeof prefix + strlen(str) + sizeof "");
  if (buf == ((void *)0))
    return ((void *)0);
  strcpy(buf, prefix);
  p = buf + sizeof prefix - 1;
  while (*str != '\0')
    *p++ = tolower(*str++);
  strcpy(p, "");
  return buf;
}


x86 assembly (clang, -O0):
<plugin_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x6,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a5 <plugin_name+0x55>
movq   $0x0,-0x8(%rbp)
jmp    121c <plugin_name+0xcc>
mov    -0x18(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x6,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1204 <plugin_name+0xb4>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%edi
call   1060 <tolower@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    11c5 <plugin_name+0x75>
mov    -0x20(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plugin_name>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %edi,%edi
test   %r15,%r15
setne  %dil
xor    %eax,%eax
call   1040 <assert@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
lea    0x7(%rax),%rdi
call   1060 <malloc@plt>
mov    %rax,%r14
test   %rax,%rax
je     11bd <plugin_name+0x7d>
mov    %rax,%rbx
movw   $0x2d,0x4(%r14)
movl   $0x6c736173,(%r14)
add    $0x5,%rbx
mov    (%r15),%al
test   %al,%al
je     11ba <plugin_name+0x7a>
add    $0x1,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1050 <tolower@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
movzbl (%r15),%eax
add    $0x1,%r15
test   %al,%al
jne    11a0 <plugin_name+0x60>
movb   $0x0,(%rbx)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@plugin_name.prefix = internal constant [6 x i8] c"sasl-\00"
@.str = [1 x i8] zeroinitializer
define i8* @plugin_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
%8 = zext i1 %7 to i32
%9 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %8)
%10 = load i8*, i8** %3
%11 = call i64 @strlen(i8* %10)
%12 = add i64 6, %11
%13 = add i64 %12, 1
%14 = call i8* @malloc(i64 %13)
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %18
17: ; preds = %1
store i8* null, i8** %2
br label %42
18: ; preds = %1
%19 = load i8*, i8** %4
%20 = call i8* @strcpy(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @plugin_name.prefix, i64 0, i64 0))
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 6
%23 = getelementptr inbounds i8, i8* %22, i64 -1
store i8* %23, i8** %5
br label %24
24: ; preds = %29, %18
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %38
29: ; preds = %24
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %3
%32 = load i8, i8* %30
%33 = sext i8 %32 to i32
%34 = call i32 @tolower(i32 %33)
%35 = trunc i32 %34 to i8
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %5
store i8 %35, i8* %36
br label %24
38: ; preds = %24
%39 = load i8*, i8** %5
%40 = call i8* @strcpy(i8* %39, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%41 = load i8*, i8** %4
store i8* %41, i8** %2
br label %42
42: ; preds = %38, %17
%43 = load i8*, i8** %2
ret i8* %43
}

LLVM IR (-O2):
@plugin_name.prefix = internal unnamed_addr constant [6 x i8] c"sasl-\00"
define i8* @plugin_name(i8* %0) {
%2 = icmp ne i8* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %3)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = add i64 %5, 7
%7 = tail call i8* @malloc(i64 %6)
%8 = icmp eq i8* %7, null
br i1 %8, label %26, label %9
9: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(6) %7, i8* align 1 dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @plugin_name.prefix, i64 0, i64 0), i64 6, i1 false)
%10 = getelementptr inbounds i8, i8* %7, i64 5
%11 = load i8, i8* %0
%12 = icmp eq i8 %11, 0
br i1 %12, label %24, label %13
13: ; preds = %9, %13
%14 = phi i8 [ %22, %13 ], [ %11, %9 ]
%15 = phi i8* [ %21, %13 ], [ %10, %9 ]
%16 = phi i8* [ %18, %13 ], [ %0, %9 ]
%17 = sext i8 %14 to i32
%18 = getelementptr inbounds i8, i8* %16, i64 1
%19 = tail call i32 @tolower(i32 %17)
%20 = trunc i32 %19 to i8
%21 = getelementptr inbounds i8, i8* %15, i64 1
store i8 %20, i8* %15
%22 = load i8, i8* %18
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %13
24: ; preds = %13, %9
%25 = phi i8* [ %10, %9 ], [ %21, %13 ]
store i8 0, i8* %25
br label %26
26: ; preds = %1, %24
ret i8* %7
}