void adjust_name(char *name) {
  for (; *name; name++) {
    if (*name == ' ')
      *name = '_';
    else if (*name == '-')
      *name = '~';
    else if (*name == '[')
      *name = '(';
    else if (*name == ']')
      *name = ')';
  }
  return;
}


x86 assembly (clang, -O0):
<adjust_name>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a5 <adjust_name+0xa5>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1131 <adjust_name+0x31>
mov    -0x8(%rbp),%rax
movb   $0x5f,(%rax)
jmp    118f <adjust_name+0x8f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    114d <adjust_name+0x4d>
mov    -0x8(%rbp),%rax
movb   $0x7e,(%rax)
jmp    118a <adjust_name+0x8a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    1169 <adjust_name+0x69>
mov    -0x8(%rbp),%rax
movb   $0x28,(%rax)
jmp    1185 <adjust_name+0x85>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5d,%eax
jne    1180 <adjust_name+0x80>
mov    -0x8(%rbp),%rax
movb   $0x29,(%rax)
jmp    1185 <adjust_name+0x85>
jmp    118a <adjust_name+0x8a>
jmp    118f <adjust_name+0x8f>
jmp    1194 <adjust_name+0x94>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1108 <adjust_name+0x8>
pop    %rbp
ret

x86 assembly (clang, -O2):
<adjust_name>:
jmp    110a <adjust_name+0xa>
mov    $0x28,%al
mov    %al,(%rdi)
add    $0x1,%rdi
movzbl (%rdi),%eax
cmp    $0x5a,%al
jg     1120 <adjust_name+0x20>
cmp    $0x20,%al
je     112c <adjust_name+0x2c>
cmp    $0x2d,%al
jne    1130 <adjust_name+0x30>
mov    $0x7e,%al
jmp    1104 <adjust_name+0x4>
nopl   (%rax)
cmp    $0x5b,%al
je     1102 <adjust_name+0x2>
cmp    $0x5d,%al
jne    1106 <adjust_name+0x6>
mov    $0x29,%al
jmp    1104 <adjust_name+0x4>
mov    $0x5f,%al
jmp    1104 <adjust_name+0x4>
test   %al,%al
jne    1106 <adjust_name+0x6>
ret

LLVM IR (-O0):
define void @adjust_name(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %39, %1
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = icmp ne i8 %5, 0
br i1 %6, label %7, label %42
7: ; preds = %3
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 32
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = load i8*, i8** %2
store i8 95, i8* %13
br label %38
14: ; preds = %7
%15 = load i8*, i8** %2
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 45
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = load i8*, i8** %2
store i8 126, i8* %20
br label %37
21: ; preds = %14
%22 = load i8*, i8** %2
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 91
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = load i8*, i8** %2
store i8 40, i8* %27
br label %36
28: ; preds = %21
%29 = load i8*, i8** %2
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 93
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = load i8*, i8** %2
store i8 41, i8* %34
br label %35
35: ; preds = %33, %28
br label %36
36: ; preds = %35, %26
br label %37
37: ; preds = %36, %19
br label %38
38: ; preds = %37, %12
br label %39
39: ; preds = %38
%40 = load i8*, i8** %2
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %2
br label %3
42: ; preds = %3
ret void
}

LLVM IR (-O2):
define void @adjust_name(i8* nocapture %0) {
br label %2
2: ; preds = %10, %1
%3 = phi i8* [ %0, %1 ], [ %11, %10 ]
%4 = load i8, i8* %3
switch i8 %4, label %10 [
i8 0, label %12
i8 32, label %8
i8 45, label %5
i8 91, label %6
i8 93, label %7
]
5: ; preds = %2
br label %8
6: ; preds = %2
br label %8
7: ; preds = %2
br label %8
8: ; preds = %2, %5, %7, %6
%9 = phi i8 [ 40, %6 ], [ 41, %7 ], [ 126, %5 ], [ 95, %2 ]
store i8 %9, i8* %3
br label %10
10: ; preds = %8, %2
%11 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
12: ; preds = %2
ret void
}