#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*/ memset(char *, int /*<<< orphan*/, int);
char *(strnpbrk)(const char *string, const char *stopset, size_t maxlen) {
  char set[256];
  char c;
  const char *s = string;
  memset(set, 0, 256 * sizeof(char));
  while ((c = *stopset++))
    set[(size_t)c] = 1;
  while (maxlen-- && ((c = *s++)))
    if (!set[(size_t)c])
      break;
  return c ? (s - 1) : NULL;
}


x86 assembly (clang, -O0):
<strnpbrk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x130(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x121(%rbp)
cmp    $0x0,%al
je     1179 <strnpbrk+0x69>
movsbq -0x121(%rbp),%rax
ff
movb   $0x1,-0x120(%rbp,%rax,1)
01
jmp    1145 <strnpbrk+0x35>
jmp    117e <strnpbrk+0x6e>
mov    -0x18(%rbp),%rcx
mov    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x131(%rbp)
je     11cb <strnpbrk+0xbb>
mov    -0x130(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x130(%rbp)
mov    (%rax),%al
mov    %al,-0x121(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x131(%rbp)
mov    -0x131(%rbp),%al
test   $0x1,%al
jne    11de <strnpbrk+0xce>
jmp    11fe <strnpbrk+0xee>
movsbq -0x121(%rbp),%rax
ff
cmpb   $0x0,-0x120(%rbp,%rax,1)
jne    11f9 <strnpbrk+0xe9>
jmp    11fe <strnpbrk+0xee>
jmp    117e <strnpbrk+0x6e>
movsbl -0x121(%rbp),%eax
cmp    $0x0,%eax
je     1225 <strnpbrk+0x115>
mov    -0x130(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x140(%rbp)
jmp    1233 <strnpbrk+0x123>
xor    %eax,%eax
mov    %rax,-0x140(%rbp)
jmp    1233 <strnpbrk+0x123>
mov    -0x140(%rbp),%rax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strnpbrk>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
mov    (%rbx),%al
test   %al,%al
je     1153 <strnpbrk+0x43>
add    $0x1,%rbx
xchg   %ax,%ax
movsbq %al,%rax
movb   $0x1,(%rsp,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <strnpbrk+0x30>
test   %r14,%r14
je     118a <strnpbrk+0x7a>
lea    (%r15,%r14,1),%rax
mov    %r14,%rcx
nop
movsbq (%r15),%rdx
test   %rdx,%rdx
je     118a <strnpbrk+0x7a>
cmpb   $0x0,(%rsp,%rdx,1)
je     118d <strnpbrk+0x7d>
add    $0xffffffffffffffff,%rcx
add    $0x1,%r15
test   %rcx,%rcx
jne    1160 <strnpbrk+0x50>
test   %r14,%r14
je     118a <strnpbrk+0x7a>
add    $0xffffffffffffffff,%rax
mov    %rax,%r15
jmp    118d <strnpbrk+0x7d>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @strnpbrk(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [256 x i8]
%8 = alloca i8
%9 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%10 = load i8*, i8** %4
store i8* %10, i8** %9
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i32 0, i32 256)
br label %13
13: ; preds = %18, %3
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %5
%16 = load i8, i8* %14
store i8 %16, i8* %8
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = load i8, i8* %8
%20 = sext i8 %19 to i64
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %20
store i8 1, i8* %21
br label %13
22: ; preds = %13
br label %23
23: ; preds = %42, %22
%24 = load i64, i64* %6
%25 = add i64 %24, -1
store i64 %25, i64* %6
%26 = icmp ne i64 %24, 0
br i1 %26, label %27, label %33
27: ; preds = %23
%28 = load i8*, i8** %9
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %9
%30 = load i8, i8* %28
store i8 %30, i8* %8
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br label %33
33: ; preds = %27, %23
%34 = phi i1 [ false, %23 ], [ %32, %27 ]
br i1 %34, label %35, label %43
35: ; preds = %33
%36 = load i8, i8* %8
%37 = sext i8 %36 to i64
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = icmp ne i8 %39, 0
br i1 %40, label %42, label %41
41: ; preds = %35
br label %43
42: ; preds = %35
br label %23
43: ; preds = %41, %33
%44 = load i8, i8* %8
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = load i8*, i8** %9
%49 = getelementptr inbounds i8, i8* %48, i64 -1
br label %51
50: ; preds = %43
br label %51
51: ; preds = %50, %47
%52 = phi i8* [ %49, %47 ], [ null, %50 ]
ret i8* %52
}

LLVM IR (-O2):
define i8* @strnpbrk(i8* %0, i8* nocapture %1, i64 %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 256)
%7 = load i8, i8* %1
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %13, %3
%10 = icmp eq i64 %2, 0
br i1 %10, label %37, label %11
11: ; preds = %9
%12 = getelementptr i8, i8* %0, i64 %2
br label %24
13: ; preds = %3, %13
%14 = phi i8 [ %19, %13 ], [ %7, %3 ]
%15 = phi i8* [ %16, %13 ], [ %1, %3 ]
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = sext i8 %14 to i64
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %17
store i8 1, i8* %18
%19 = load i8, i8* %16
%20 = icmp eq i8 %19, 0
br i1 %20, label %9, label %13
21: ; preds = %29
%22 = getelementptr inbounds i8, i8* %26, i64 1
%23 = icmp eq i64 %30, 0
br i1 %23, label %35, label %24
24: ; preds = %11, %21
%25 = phi i64 [ %30, %21 ], [ %2, %11 ]
%26 = phi i8* [ %22, %21 ], [ %0, %11 ]
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %24
%30 = add i64 %25, -1
%31 = sext i8 %27 to i64
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 0
br i1 %34, label %38, label %21
35: ; preds = %21
%36 = getelementptr inbounds i8, i8* %12, i64 -1
br i1 %10, label %37, label %38
37: ; preds = %24, %9, %35
br label %38
38: ; preds = %29, %35, %37
%39 = phi i8* [ null, %37 ], [ %36, %35 ], [ %26, %29 ]
ret i8* %39
}