#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 */
char *scout_pchar(char const *);
const char *scout_any_segment(const char *c, char exclude) {
  const char *p = NULL;
  c = scout_pchar(c);
  while (c != NULL && *c != exclude) {
    p = c++;
    c = scout_pchar(c);
  }
  return p;
}


x86 assembly (clang, -O0):
<scout_any_segment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <scout_pchar@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x19(%rbp)
je     115a <scout_any_segment+0x4a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    116a <scout_any_segment+0x5a>
jmp    118f <scout_any_segment+0x7f>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <scout_pchar@plt>
mov    %rax,-0x8(%rbp)
jmp    1137 <scout_any_segment+0x27>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scout_any_segment>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
call   1030 <scout_pchar@plt>
test   %rax,%rax
je     1124 <scout_any_segment+0x14>
cmp    %bpl,(%rax)
jne    1130 <scout_any_segment+0x20>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %rax,%rbx
lea    0x1(%rax),%rdi
call   1030 <scout_pchar@plt>
test   %rax,%rax
je     1126 <scout_any_segment+0x16>
cmp    %bpl,(%rax)
jne    1130 <scout_any_segment+0x20>
jmp    1126 <scout_any_segment+0x16>

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

LLVM IR (-O2):
define i8* @scout_any_segment(i8* %0, i8 signext %1) {
%3 = tail call i8* @scout_pchar(i8* %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %16, label %5
5: ; preds = %2
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, %1
br i1 %7, label %16, label %11
8: ; preds = %11
%9 = load i8, i8* %14
%10 = icmp eq i8 %9, %1
br i1 %10, label %16, label %11
11: ; preds = %5, %8
%12 = phi i8* [ %14, %8 ], [ %3, %5 ]
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = tail call i8* @scout_pchar(i8* %13)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %8
16: ; preds = %11, %8, %5, %2
%17 = phi i8* [ null, %2 ], [ null, %5 ], [ %12, %8 ], [ %12, %11 ]
ret i8* %17
}