#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 *(strnpcbrknul)(const char *string, const char *skipset, size_t maxlen) {
  char set[256];
  char c;
  const char *s = string;
  memset(set, 0, 256 * sizeof(char));
  while ((c = *skipset++))
    set[(size_t)c] = 1;
  while (maxlen-- && ((c = *s++)))
    if (set[(size_t)c])
      break;
  return s - 1;
}


x86 assembly (clang, -O0):
<strnpcbrknul>:
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 <strnpcbrknul+0x69>
movsbq -0x121(%rbp),%rax
ff
movb   $0x1,-0x120(%rbp,%rax,1)
01
jmp    1145 <strnpcbrknul+0x35>
jmp    117e <strnpcbrknul+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 <strnpcbrknul+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 <strnpcbrknul+0xce>
jmp    11fe <strnpcbrknul+0xee>
movsbq -0x121(%rbp),%rax
ff
cmpb   $0x0,-0x120(%rbp,%rax,1)
je     11f9 <strnpcbrknul+0xe9>
jmp    11fe <strnpcbrknul+0xee>
jmp    117e <strnpcbrknul+0x6e>
mov    -0x130(%rbp),%rax
add    $0xffffffffffffffff,%rax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strnpcbrknul>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
mov    (%rbx),%al
test   %al,%al
je     1153 <strnpcbrknul+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 <strnpcbrknul+0x30>
lea    (%r14,%r15,1),%rcx
lea    0x1(%r14),%rdx
nopl   0x0(%rax,%rax,1)
sub    $0x1,%r15
jb     1183 <strnpcbrknul+0x73>
mov    %rdx,%rax
add    $0x1,%r14
movsbq -0x1(%rdx),%rsi
test   %rsi,%rsi
je     1188 <strnpcbrknul+0x78>
lea    0x1(%rax),%rdx
cmpb   $0x0,(%rsp,%rsi,1)
je     1160 <strnpcbrknul+0x50>
jmp    118b <strnpcbrknul+0x7b>
mov    %rcx,%rax
jmp    118b <strnpcbrknul+0x7b>
mov    %r14,%rax
add    $0xffffffffffffffff,%rax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @strnpcbrknul(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 %41, label %42
41: ; preds = %35
br label %43
42: ; preds = %35
br label %23
43: ; preds = %41, %33
%44 = load i8*, i8** %9
%45 = getelementptr inbounds i8, i8* %44, i64 -1
ret i8* %45
}

LLVM IR (-O2):
define i8* @strnpcbrknul(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 %11
9: ; preds = %11, %3
%10 = getelementptr i8, i8* %0, i64 %2
br label %19
11: ; preds = %3, %11
%12 = phi i8 [ %17, %11 ], [ %7, %3 ]
%13 = phi i8* [ %14, %11 ], [ %1, %3 ]
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = sext i8 %12 to i64
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %15
store i8 1, i8* %16
%17 = load i8, i8* %14
%18 = icmp eq i8 %17, 0
br i1 %18, label %9, label %11
19: ; preds = %9, %28
%20 = phi i64 [ %22, %28 ], [ %2, %9 ]
%21 = phi i8* [ %25, %28 ], [ %0, %9 ]
%22 = add i64 %20, -1
%23 = icmp eq i64 %20, 0
br i1 %23, label %33, label %24
24: ; preds = %19
%25 = getelementptr inbounds i8, i8* %21, i64 1
%26 = load i8, i8* %21
%27 = icmp eq i8 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %24
%29 = sext i8 %26 to i64
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 0
br i1 %32, label %19, label %33
33: ; preds = %19, %28, %24
%34 = phi i8* [ %25, %28 ], [ %25, %24 ], [ %10, %19 ]
%35 = getelementptr inbounds i8, i8* %34, i64 -1
ret i8* %35
}