int match_char_against_range_clean(char c, const char *expr) {
  char low;
  int direct = 1;
  if (*expr == '^') {
    direct = 0;
    expr++;
  }
  do {
    low = *expr;
    expr++;
    if (*expr == '-' && expr[1] != '\0') {
      expr++;
      if (c >= low && c <= *expr)
        return direct;
      expr++;
      continue;
    }
    if (low == c)
      return direct;
  } while (*expr != '\0');
  return !direct;
}


x86 assembly (clang, -O0):
<match_char_against_range_clean>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5e,%eax
jne    1138 <match_char_against_range_clean+0x38>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113d <match_char_against_range_clean+0x3d>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11be <match_char_against_range_clean+0xbe>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     11be <match_char_against_range_clean+0xbe>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movsbl -0x5(%rbp),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jl     11ad <match_char_against_range_clean+0xad>
movsbl -0x5(%rbp),%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jg     11ad <match_char_against_range_clean+0xad>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ff <match_char_against_range_clean+0xff>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11de <match_char_against_range_clean+0xde>
movsbl -0x11(%rbp),%eax
movsbl -0x5(%rbp),%ecx
cmp    %ecx,%eax
jne    11d9 <match_char_against_range_clean+0xd9>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ff <match_char_against_range_clean+0xff>
jmp    11de <match_char_against_range_clean+0xde>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    113d <match_char_against_range_clean+0x3d>
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_char_against_range_clean>:
xor    %r9d,%r9d
cmpb   $0x5e,(%rsi)
setne  %r8b
sete   %r9b
lea    (%rsi,%r9,1),%rdx
mov    (%rsi,%r9,1),%al
jmp    112e <match_char_against_range_clean+0x2e>
nopl   0x0(%rax,%rax,1)
movzbl 0x3(%rdx),%ecx
add    $0x3,%rdx
mov    %ecx,%eax
test   %cl,%cl
je     115b <match_char_against_range_clean+0x5b>
movzbl 0x1(%rdx),%ecx
cmp    $0x2d,%cl
jne    1150 <match_char_against_range_clean+0x50>
movzbl 0x2(%rdx),%esi
test   %sil,%sil
je     1150 <match_char_against_range_clean+0x50>
cmp    %dil,%al
jg     1120 <match_char_against_range_clean+0x20>
cmp    %dil,%sil
jl     1120 <match_char_against_range_clean+0x20>
jmp    115e <match_char_against_range_clean+0x5e>
nopl   0x0(%rax)
cmp    %dil,%al
je     115e <match_char_against_range_clean+0x5e>
add    $0x1,%rdx
jmp    1128 <match_char_against_range_clean+0x28>
mov    %r9d,%r8d
movzbl %r8b,%eax
ret

LLVM IR (-O0):
define i32 @match_char_against_range_clean(i8 signext %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
store i8 %0, i8* %4
store i8* %1, i8** %5
store i32 1, i32* %7
%8 = load i8*, i8** %5
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 94
br i1 %11, label %12, label %15
12: ; preds = %2
store i32 0, i32* %7
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %5
br label %15
15: ; preds = %12, %2
br label %16
16: ; preds = %60, %15
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
store i8 %18, i8* %6
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %5
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 45
br i1 %24, label %25, label %51
25: ; preds = %16
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %51
31: ; preds = %25
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
%34 = load i8, i8* %4
%35 = sext i8 %34 to i32
%36 = load i8, i8* %6
%37 = sext i8 %36 to i32
%38 = icmp sge i32 %35, %37
br i1 %38, label %39, label %48
39: ; preds = %31
%40 = load i8, i8* %4
%41 = sext i8 %40 to i32
%42 = load i8*, i8** %5
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp sle i32 %41, %44
br i1 %45, label %46, label %48
46: ; preds = %39
%47 = load i32, i32* %7
store i32 %47, i32* %3
br label %70
48: ; preds = %39, %31
%49 = load i8*, i8** %5
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %5
br label %60
51: ; preds = %25, %16
%52 = load i8, i8* %6
%53 = sext i8 %52 to i32
%54 = load i8, i8* %4
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %53, %55
br i1 %56, label %57, label %59
57: ; preds = %51
%58 = load i32, i32* %7
store i32 %58, i32* %3
br label %70
59: ; preds = %51
br label %60
60: ; preds = %59, %48
%61 = load i8*, i8** %5
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp ne i32 %63, 0
br i1 %64, label %16, label %65
65: ; preds = %60
%66 = load i32, i32* %7
%67 = icmp ne i32 %66, 0
%68 = xor i1 %67, true
%69 = zext i1 %68 to i32
store i32 %69, i32* %3
br label %70
70: ; preds = %65, %57, %46
%71 = load i32, i32* %3
ret i32 %71
}

LLVM IR (-O2):
define i32 @match_char_against_range_clean(i8 signext %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 94
%5 = zext i1 %4 to i64
%6 = getelementptr i8, i8* %1, i64 %5
%7 = xor i1 %4, true
%8 = load i8, i8* %6
br label %9
9: ; preds = %28, %2
%10 = phi i8 [ %8, %2 ], [ %29, %28 ]
%11 = phi i8* [ %6, %2 ], [ %30, %28 ]
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 45
br i1 %14, label %15, label %26
15: ; preds = %9
%16 = getelementptr inbounds i8, i8* %11, i64 2
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %15
%20 = icmp sgt i8 %10, %0
%21 = icmp slt i8 %17, %0
%22 = select i1 %20, i1 true, i1 %21
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = getelementptr inbounds i8, i8* %11, i64 3
%25 = load i8, i8* %24
br label %28
26: ; preds = %15, %9
%27 = icmp eq i8 %10, %0
br i1 %27, label %32, label %28
28: ; preds = %26, %23
%29 = phi i8 [ %25, %23 ], [ %13, %26 ]
%30 = phi i8* [ %24, %23 ], [ %12, %26 ]
%31 = icmp eq i8 %29, 0
br i1 %31, label %32, label %9
32: ; preds = %28, %19, %26
%33 = phi i1 [ %7, %26 ], [ %7, %19 ], [ %4, %28 ]
%34 = zext i1 %33 to i32
ret i32 %34
}