#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 /*<<< orphan*/ char_length(char const *);
int /*<<< orphan*/ *mbstrchr(char const *, char const *);
char *mbstrpbrk(const char *string, const char *accept) {
  while (*string != '\0') {
    if (mbstrchr(accept, string) != NULL)
      return (char *)string;
    string += char_length(string);
  }
  return NULL;
}


x86 assembly (clang, -O0):
<mbstrpbrk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1182 <mbstrpbrk+0x62>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <mbstrchr@plt>
cmp    $0x0,%rax
je     1164 <mbstrpbrk+0x44>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    118a <mbstrpbrk+0x6a>
mov    -0x10(%rbp),%rdi
call   1040 <char_length@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    1130 <mbstrpbrk+0x10>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mbstrpbrk>:
push   %r14
push   %rbx
push   %rax
cmpb   $0x0,(%rdi)
je     1154 <mbstrpbrk+0x34>
mov    %rsi,%r14
mov    %rdi,%rbx
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <mbstrchr@plt>
test   %rax,%rax
jne    1156 <mbstrpbrk+0x36>
mov    %rbx,%rdi
call   1040 <char_length@plt>
cltq
cmpb   $0x0,(%rbx,%rax,1)
lea    (%rbx,%rax,1),%rbx
jne    1130 <mbstrpbrk+0x10>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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