const char *config_file_option_escape(const char *name) {
  static char str_escaped[2] = "\\", str_not_escaped[1] = {'\0'};
  if (!name)
    return str_escaped;
  if ((name[0] == '#') || (name[0] == '[') || (name[0] == '\\'))
    return str_escaped;
  return str_not_escaped;
}


x86 assembly (clang, -O0):
<config_file_option_escape>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1123 <config_file_option_escape+0x23>
lea    0x2f06(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    116e <config_file_option_escape+0x6e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     1153 <config_file_option_escape+0x53>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
je     1153 <config_file_option_escape+0x53>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1163 <config_file_option_escape+0x63>
lea    0x2ec6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    116e <config_file_option_escape+0x6e>
lea    0x2eb9(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_file_option_escape>:
lea    0x2f19(%rip),%rax
test   %rdi,%rdi
je     1129 <config_file_option_escape+0x29>
mov    (%rdi),%cl
add    $0xdd,%cl
cmp    $0x39,%cl
ja     112a <config_file_option_escape+0x2a>
movzbl %cl,%ecx
movabs $0x300000000000001,%rdx
bt     %rcx,%rdx
jae    112a <config_file_option_escape+0x2a>
ret
lea    0x2ef2(%rip),%rax
ret

LLVM IR (-O0):
@config_file_option_escape.str_escaped = internal global [2 x i8] c"\\\00"
@config_file_option_escape.str_not_escaped = internal global [1 x i8] zeroinitializer
define i8* @config_file_option_escape(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %7, label %6
6: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @config_file_option_escape.str_escaped, i64 0, i64 0), i8** %2
br label %27
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 35
br i1 %12, label %25, label %13
13: ; preds = %7
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 91
br i1 %18, label %25, label %19
19: ; preds = %13
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 92
br i1 %24, label %25, label %26
25: ; preds = %19, %13, %7
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @config_file_option_escape.str_escaped, i64 0, i64 0), i8** %2
br label %27
26: ; preds = %19
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @config_file_option_escape.str_not_escaped, i64 0, i64 0), i8** %2
br label %27
27: ; preds = %26, %25, %6
%28 = load i8*, i8** %2
ret i8* %28
}

LLVM IR (-O2):
@config_file_option_escape.str_escaped = internal global [2 x i8] c"\\\00"
@config_file_option_escape.str_not_escaped = internal global [1 x i8] zeroinitializer
define i8* @config_file_option_escape(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = load i8, i8* %0
switch i8 %4, label %5 [
i8 35, label %6
i8 91, label %6
i8 92, label %6
]
5: ; preds = %3
br label %6
6: ; preds = %3, %3, %3, %1, %5
%7 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @config_file_option_escape.str_not_escaped, i64 0, i64 0), %5 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @config_file_option_escape.str_escaped, i64 0, i64 0), %1 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @config_file_option_escape.str_escaped, i64 0, i64 0), %3 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @config_file_option_escape.str_escaped, i64 0, i64 0), %3 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @config_file_option_escape.str_escaped, i64 0, i64 0), %3 ]
ret i8* %7
}