#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 const *, char const);
int field_length(const char *s, const char *delimiters) {
  int len = 0;
  if (!s || !delimiters)
    return -1;
  while (*s != '\0' && !strchr(delimiters, *s)) {
    len++;
    s++;
  }
  return len;
}


x86 assembly (clang, -O0):
<field_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     113d <field_length+0x2d>
cmpq   $0x0,-0x18(%rbp)
jne    1149 <field_length+0x39>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ae <field_length+0x9e>
jmp    114e <field_length+0x3e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
je     117e <field_length+0x6e>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    118e <field_length+0x7e>
jmp    11a8 <field_length+0x98>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    114e <field_length+0x3e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<field_length>:
push   %r15
push   %r14
push   %rbx
mov    $0xffffffff,%ebx
test   %rdi,%rdi
je     115d <field_length+0x4d>
mov    %rsi,%r14
test   %rsi,%rsi
je     115d <field_length+0x4d>
mov    %rdi,%r15
mov    (%rdi),%al
xor    %ebx,%ebx
test   %al,%al
je     115d <field_length+0x4d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <strchr@plt>
test   %eax,%eax
jne    115d <field_length+0x4d>
movzbl 0x1(%r15,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <field_length+0x30>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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