#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int strlen(char *);
char *strchr_reverse_isnot(char *s, int n, int c) {
  char *p;
  p = s + strlen(s) - 1;
  while (*p == c && p != s) {
    p--;
  }
  return (p);
}


x86 assembly (clang, -O0):
<strchr_reverse_isnot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    -0x10(%rbp),%ecx
mov    %al,-0x21(%rbp)
jne    116a <strchr_reverse_isnot+0x5a>
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    117a <strchr_reverse_isnot+0x6a>
jmp    118b <strchr_reverse_isnot+0x7b>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1147 <strchr_reverse_isnot+0x37>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strchr_reverse_isnot>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rdi,%rbx
call   1030 <strlen@plt>
movslq %eax,%rcx
lea    -0x1(%rcx),%rax
cmp    $0x1,%rcx
je     1136 <strchr_reverse_isnot+0x26>
movsbl -0x1(%rbx,%rcx,1),%edx
mov    %rax,%rcx
cmp    %ebp,%edx
je     1120 <strchr_reverse_isnot+0x10>
add    %rax,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @strchr_reverse_isnot(i8* %0, i32 %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
br label %7
7: ; preds = %7, %3
%8 = phi i8* [ %6, %3 ], [ %9, %7 ]
%9 = getelementptr inbounds i8, i8* %8, i64 -1
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, %2
%13 = icmp ne i8* %9, %0
%14 = and i1 %13, %12
br i1 %14, label %7, label %15
15: ; preds = %7
ret i8* %9
}