char *translate(char *name) {
  char *ip, *jp;
  static char buffer[1024];
  for (ip = name, jp = buffer; *ip != '\0'; ++ip, ++jp)
    *jp = (*ip == 'a' ? '-' : *ip);
  *jp = '\0';
  return (buffer);
}


x86 assembly (clang, -O0):
<translate>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    0x2f19(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     117a <translate+0x7a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
jne    1148 <translate+0x48>
mov    $0x2d,%eax
mov    %eax,-0x1c(%rbp)
jmp    1152 <translate+0x52>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    111b <translate+0x1b>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2ea8(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<translate>:
xor    %ecx,%ecx
lea    0x2f27(%rip),%rax
jmp    1118 <translate+0x18>
nopl   0x0(%rax,%rax,1)
mov    %sil,(%rcx,%rax,1)
add    $0x1,%rcx
movzbl (%rdi,%rcx,1),%edx
mov    $0x2d,%sil
cmp    $0x61,%dl
je     1110 <translate+0x10>
test   %dl,%dl
je     112c <translate+0x2c>
mov    %edx,%esi
jmp    1110 <translate+0x10>
movb   $0x0,(%rcx,%rax,1)
ret

LLVM IR (-O0):
@translate.buffer = internal global [1024 x i8] zeroinitializer
define i8* @translate(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %3
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @translate.buffer, i64 0, i64 0), i8** %4
br label %6
6: ; preds = %25, %1
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %30
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 97
br i1 %15, label %16, label %17
16: ; preds = %11
br label %21
17: ; preds = %11
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
br label %21
21: ; preds = %17, %16
%22 = phi i32 [ 45, %16 ], [ %20, %17 ]
%23 = trunc i32 %22 to i8
%24 = load i8*, i8** %4
store i8 %23, i8* %24
br label %25
25: ; preds = %21
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %3
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %4
br label %6
30: ; preds = %6
%31 = load i8*, i8** %4
store i8 0, i8* %31
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @translate.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@translate.buffer = internal global [1024 x i8] zeroinitializer
define i8* @translate(i8* nocapture %0) {
br label %2
2: ; preds = %7, %1
%3 = phi i8* [ %0, %1 ], [ %9, %7 ]
%4 = phi i8* [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @translate.buffer, i64 0, i64 0), %1 ], [ %10, %7 ]
%5 = load i8, i8* %3
switch i8 %5, label %6 [
i8 0, label %11
i8 97, label %7
]
6: ; preds = %2
br label %7
7: ; preds = %2, %6
%8 = phi i8 [ %5, %6 ], [ 45, %2 ]
store i8 %8, i8* %4
%9 = getelementptr inbounds i8, i8* %3, i64 1
%10 = getelementptr inbounds i8, i8* %4, i64 1
br label %2
11: ; preds = %2
store i8 0, i8* %4
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @translate.buffer, i64 0, i64 0)
}