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


x86 assembly (clang, -O0):
<strnprcbrk>:
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)
movq   $0x0,-0x138(%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     1184 <strnprcbrk+0x74>
movsbq -0x121(%rbp),%rax
ff
movb   $0x1,-0x120(%rbp,%rax,1)
01
jmp    1150 <strnprcbrk+0x40>
jmp    1189 <strnprcbrk+0x79>
mov    -0x18(%rbp),%rcx
mov    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x139(%rbp)
je     11d6 <strnprcbrk+0xc6>
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,-0x139(%rbp)
mov    -0x139(%rbp),%al
test   $0x1,%al
jne    11e9 <strnprcbrk+0xd9>
jmp    1216 <strnprcbrk+0x106>
movsbq -0x121(%rbp),%rax
ff
cmpb   $0x0,-0x120(%rbp,%rax,1)
je     1211 <strnprcbrk+0x101>
mov    -0x130(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x138(%rbp)
jmp    1189 <strnprcbrk+0x79>
mov    -0x138(%rbp),%rax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strnprcbrk>:
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 <strnprcbrk+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 <strnprcbrk+0x30>
xor    %eax,%eax
test   %r15,%r15
je     117e <strnprcbrk+0x6e>
nopw   0x0(%rax,%rax,1)
movsbq (%r14),%rcx
test   %rcx,%rcx
je     117e <strnprcbrk+0x6e>
add    $0xffffffffffffffff,%r15
cmpb   $0x0,(%rsp,%rcx,1)
cmovne %r14,%rax
add    $0x1,%r14
test   %r15,%r15
jne    1160 <strnprcbrk+0x50>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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