#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*/ strchr(char *, char);
unsigned int find_length_without_trailing(char *buf, char *not_trailing,
                                          char *search_end) {
  unsigned int len, cur;
  for (cur = 1, len = 0; *buf && !strchr(search_end, buf[0]); buf++, cur++)
    if (!strchr(not_trailing, buf[0]))
      len = cur;
  return len;
}


x86 assembly (clang, -O0):
<find_length_without_trailing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     1162 <find_length_without_trailing+0x52>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1172 <find_length_without_trailing+0x62>
jmp    11b0 <find_length_without_trailing+0xa0>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%eax
jne    1191 <find_length_without_trailing+0x81>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1196 <find_length_without_trailing+0x86>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1132 <find_length_without_trailing+0x22>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_length_without_trailing>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1161 <find_length_without_trailing+0x51>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
xor    %ebp,%ebp
mov    $0x1,%ebx
xchg   %ax,%ax
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <strchr@plt>
test   %eax,%eax
jne    1163 <find_length_without_trailing+0x53>
movsbl -0x1(%r12,%rbx,1),%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
test   %eax,%eax
cmove  %ebx,%ebp
movzbl (%r12,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <find_length_without_trailing+0x20>
jmp    1163 <find_length_without_trailing+0x53>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @find_length_without_trailing(i8* nocapture %0, i8* %1, i8* %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %22, label %6
6: ; preds = %3, %13
%7 = phi i8 [ %20, %13 ], [ %4, %3 ]
%8 = phi i32 [ %19, %13 ], [ 1, %3 ]
%9 = phi i32 [ %17, %13 ], [ 0, %3 ]
%10 = phi i8* [ %18, %13 ], [ %0, %3 ]
%11 = tail call i32 @strchr(i8* %2, i8 signext %7)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %6
%14 = load i8, i8* %10
%15 = tail call i32 @strchr(i8* %1, i8 signext %14)
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i32 %8, i32 %9
%18 = getelementptr inbounds i8, i8* %10, i64 1
%19 = add i32 %8, 1
%20 = load i8, i8* %18
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %6
22: ; preds = %6, %13, %3
%23 = phi i32 [ 0, %3 ], [ %17, %13 ], [ %9, %6 ]
ret i32 %23
}