int except(char (*endg)(), char *token, int len, int end) {
  int found;
  char rtok[32];
  strn_rev(token, rtok, (len - end));
  if (0)
    printf("\nexcept: %s", rtok);
  found = (*endg)(rtok, 1, 0);
  if (0)
    printf("\nexcept: found = %d", found);
  if (found)
    return (len);
  else
    return (len - end);
}


x86 assembly (clang, -O0):
<except>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x1c(%rbp),%edx
sub    -0x20(%rbp),%edx
mov    $0x0,%al
call   1030 <strn_rev@plt>
mov    -0x10(%rbp),%rcx
lea    -0x50(%rbp),%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    $0x0,%al
call   *%rcx
movsbl %al,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1169 <except+0x59>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1172 <except+0x62>
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<except>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edx,%ebx
mov    %rdi,%r14
mov    %edx,%ebp
sub    %ecx,%ebp
mov    %rsp,%r15
mov    %rsi,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <strn_rev@plt>
mov    %r15,%rdi
mov    $0x1,%esi
xor    %edx,%edx
xor    %eax,%eax
call   *%r14
test   %al,%al
cmovne %ebx,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @except(i8 (...)* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8 (...)*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [32 x i8]
store i8 (...)* %0, i8 (...)** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%12 = load i8*, i8** %7
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%14 = load i32, i32* %8
%15 = load i32, i32* %9
%16 = sub nsw i32 %14, %15
%17 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @strn_rev to i32 (i8*, i8*, i32, ...)*)(i8* %12, i8* %13, i32 %16)
%18 = load i8 (...)*, i8 (...)** %6
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%20 = bitcast i8 (...)* %18 to i8 (i8*, i32, i32, ...)*
%21 = call signext i8 (i8*, i32, i32, ...) %20(i8* %19, i32 1, i32 0)
%22 = sext i8 %21 to i32
store i32 %22, i32* %10
%23 = load i32, i32* %10
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %4
%26 = load i32, i32* %8
store i32 %26, i32* %5
br label %31
27: ; preds = %4
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = sub nsw i32 %28, %29
store i32 %30, i32* %5
br label %31
31: ; preds = %27, %25
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
define i32 @except(i8 (...)* nocapture %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca [32 x i8]
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%7 = sub nsw i32 %2, %3
%8 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @strn_rev to i32 (i8*, i8*, i32, ...)*)(i8* %1, i8* %6, i32 %7)
%9 = bitcast i8 (...)* %0 to i8 (i8*, i32, i32, ...)*
%10 = call signext i8 (i8*, i32, i32, ...) %9(i8* %6, i32 1, i32 0)
%11 = icmp eq i8 %10, 0
%12 = select i1 %11, i32 %7, i32 %2
ret i32 %12
}