#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 */
scalar_t__ char_is_oneof(char const, char const *);
const char *str_search_oneof(const char *str, const char *chars) {
  for (const char *ptr = str;; ptr++) {
    if (char_is_oneof(*ptr, chars))
      return ptr;
    if (*ptr == '\0')
      break;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<str_search_oneof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1030 <char_is_oneof@plt>
cmp    $0x0,%rax
je     1151 <str_search_oneof+0x41>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1184 <str_search_oneof+0x74>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1166 <str_search_oneof+0x56>
jmp    117c <str_search_oneof+0x6c>
jmp    116b <str_search_oneof+0x5b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1128 <str_search_oneof+0x18>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_search_oneof>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsbl (%rdi),%edi
nopl   (%rax)
call   1030 <char_is_oneof@plt>
test   %rax,%rax
jne    113e <str_search_oneof+0x2e>
cmpb   $0x0,(%rbx)
je     113c <str_search_oneof+0x2c>
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
mov    %r14,%rsi
jmp    1120 <str_search_oneof+0x10>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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