const char *compare_debug(int match) {
  static const char *bogus = "**bad matching flags** will never match the "
                             "string";
  static const char *ome = "exactly matching the case-sensitive string";
  static const char *ombw = "beginning with the case-sensitive string";
  static const char *omew = "ending with the case-sensitive string";
  static const char *omen = "exactly matching the case-insensitive string";
  static const char *ombwn = "beginning with the case-insensitive string";
  static const char *omewn = "ending with the case-insensitive string";
  static const char *omr = "matching the case-sensitive regular "
                           "expression";
  static const char *omrn = "matching the case-insensitive regular "
                            "expression";
  switch (match & 0x00000007) {
  default:
    return (bogus);
  case 0x00000000:
    return (omen);
  case 0x00000002:
    return (ombwn);
  case 0x00000001:
    return (omewn);
  case 0x00000003:
    return (omrn);
  case 0x00000000 | 0x00000004:
    return (ome);
  case 0x00000002 | 0x00000004:
    return (ombw);
  case 0x00000001 | 0x00000004:
    return (omew);
  case 0x00000003 | 0x00000004:
    return (omr);
  }
}


x86 assembly (clang, -O0):
<compare_debug>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x7,%eax
mov    %rax,-0x18(%rbp)
sub    $0x7,%eax
ja     112e <compare_debug+0x2e>
mov    -0x18(%rbp),%rax
lea    0xedb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2eeb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b9 <compare_debug+0xb9>
mov    0x2efb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b9 <compare_debug+0xb9>
mov    0x2ef3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b9 <compare_debug+0xb9>
mov    0x2eeb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b9 <compare_debug+0xb9>
mov    0x2eeb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b9 <compare_debug+0xb9>
mov    0x2ea3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b9 <compare_debug+0xb9>
mov    0x2e9b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b9 <compare_debug+0xb9>
mov    0x2e93(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b9 <compare_debug+0xb9>
mov    0x2ea3(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_debug>:
and    $0x7,%edi
lea    0x1052(%rip),%rcx
movslq (%rcx,%rdi,4),%rax
add    %rcx,%rax
ret

LLVM IR (-O0):
@compare_debug.bogus = internal global i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i32 0, i32 0)
@.str = [51 x i8] c"**bad matching flags** will never match the string\00"
@compare_debug.ome = internal global i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i32 0, i32 0)
@.str.1 = [43 x i8] c"exactly matching the case-sensitive string\00"
@compare_debug.ombw = internal global i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i32 0, i32 0)
@.str.2 = [41 x i8] c"beginning with the case-sensitive string\00"
@compare_debug.omew = internal global i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i32 0, i32 0)
@.str.3 = [38 x i8] c"ending with the case-sensitive string\00"
@compare_debug.omen = internal global i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i32 0, i32 0)
@.str.4 = [45 x i8] c"exactly matching the case-insensitive string\00"
@compare_debug.ombwn = internal global i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i32 0, i32 0)
@.str.5 = [43 x i8] c"beginning with the case-insensitive string\00"
@compare_debug.omewn = internal global i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i32 0, i32 0)
@.str.6 = [40 x i8] c"ending with the case-insensitive string\00"
@compare_debug.omr = internal global i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i32 0, i32 0)
@.str.7 = [47 x i8] c"matching the case-sensitive regular expression\00"
@compare_debug.omrn = internal global i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i32 0, i32 0)
@.str.8 = [49 x i8] c"matching the case-insensitive regular expression\00"
define i8* @compare_debug(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = and i32 %4, 7
switch i32 %5, label %6 [
i32 0, label %8
i32 2, label %10
i32 1, label %12
i32 3, label %14
i32 4, label %16
i32 6, label %18
i32 5, label %20
i32 7, label %22
]
6: ; preds = %1
%7 = load i8*, i8** @compare_debug.bogus
store i8* %7, i8** %2
br label %24
8: ; preds = %1
%9 = load i8*, i8** @compare_debug.omen
store i8* %9, i8** %2
br label %24
10: ; preds = %1
%11 = load i8*, i8** @compare_debug.ombwn
store i8* %11, i8** %2
br label %24
12: ; preds = %1
%13 = load i8*, i8** @compare_debug.omewn
store i8* %13, i8** %2
br label %24
14: ; preds = %1
%15 = load i8*, i8** @compare_debug.omrn
store i8* %15, i8** %2
br label %24
16: ; preds = %1
%17 = load i8*, i8** @compare_debug.ome
store i8* %17, i8** %2
br label %24
18: ; preds = %1
%19 = load i8*, i8** @compare_debug.ombw
store i8* %19, i8** %2
br label %24
20: ; preds = %1
%21 = load i8*, i8** @compare_debug.omew
store i8* %21, i8** %2
br label %24
22: ; preds = %1
%23 = load i8*, i8** @compare_debug.omr
store i8* %23, i8** %2
br label %24
24: ; preds = %22, %20, %18, %16, %14, %12, %10, %8, %6
%25 = load i8*, i8** %2
ret i8* %25
}

LLVM IR (-O2):
@.str.1 = [43 x i8] c"exactly matching the case-sensitive string\00"
@.str.2 = [41 x i8] c"beginning with the case-sensitive string\00"
@.str.3 = [38 x i8] c"ending with the case-sensitive string\00"
@.str.4 = [45 x i8] c"exactly matching the case-insensitive string\00"
@.str.5 = [43 x i8] c"beginning with the case-insensitive string\00"
@.str.6 = [40 x i8] c"ending with the case-insensitive string\00"
@.str.7 = [47 x i8] c"matching the case-sensitive regular expression\00"
@.str.8 = [49 x i8] c"matching the case-insensitive regular expression\00"
@reltable.compare_debug = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([45 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.compare_debug to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([40 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.compare_debug to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([43 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.compare_debug to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([49 x i8]* @.str.8 to i64), i64 ptrtoint ([8 x i32]* @reltable.compare_debug to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([43 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.compare_debug to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([38 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.compare_debug to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([41 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.compare_debug to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([47 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.compare_debug to i64)) to i32)]
define i8* @compare_debug(i32 %0) {
%2 = and i32 %0, 7
%3 = zext i32 %2 to i64
%4 = shl i64 %3, 2
%5 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.compare_debug to i8*), i64 %4)
ret i8* %5
}