#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 */
struct string {
  int dummy;
};

/* Variables and functions */
char *string_get(struct string const *);
int string_find_first_of(struct string const *src, char const *delim) {
  char const *str_beg = string_get(src);
  char const *str = str_beg;
  while (*str) {
    char const *delim_cur = delim;
    while (*delim_cur) {
      if (*str == *delim_cur)
        return str - str_beg;
      delim_cur++;
    }
    str++;
  }
  return -1;
}


x86 assembly (clang, -O0):
<string_find_first_of>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <string_get@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a2 <string_find_first_of+0x92>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     1191 <string_find_first_of+0x81>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
mov    -0x30(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1180 <string_find_first_of+0x70>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
jmp    11a9 <string_find_first_of+0x99>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    114a <string_find_first_of+0x3a>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1135 <string_find_first_of+0x25>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_find_first_of>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
call   1030 <string_get@plt>
mov    %rax,%rdi
mov    (%rax),%dl
mov    $0xffffffff,%eax
test   %dl,%dl
je     1175 <string_find_first_of+0x65>
mov    (%r14),%r8b
add    $0x1,%r14
mov    %rdi,%rsi
jmp    114b <string_find_first_of+0x3b>
cs nopw 0x0(%rax,%rax,1)
mov    0x1(%rsi),%dl
add    $0x1,%rsi
test   %dl,%dl
je     1175 <string_find_first_of+0x65>
mov    %r14,%rbx
mov    %r8d,%ecx
test   %r8b,%r8b
je     1140 <string_find_first_of+0x30>
cs nopw 0x0(%rax,%rax,1)
cmp    %cl,%dl
je     1171 <string_find_first_of+0x61>
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    1160 <string_find_first_of+0x50>
jmp    1140 <string_find_first_of+0x30>
sub    %edi,%esi
mov    %esi,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.string = type { i32 }
define i32 @string_find_first_of(%struct.string* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.string*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store %struct.string* %0, %struct.string** %4
store i8* %1, i8** %5
%9 = load %struct.string*, %struct.string** %4
%10 = call i8* @string_get(%struct.string* %9)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
store i8* %11, i8** %7
br label %12
12: ; preds = %40, %2
%13 = load i8*, i8** %7
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %16, label %43
16: ; preds = %12
%17 = load i8*, i8** %5
store i8* %17, i8** %8
br label %18
18: ; preds = %37, %16
%19 = load i8*, i8** %8
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 0
br i1 %21, label %22, label %40
22: ; preds = %18
%23 = load i8*, i8** %7
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = load i8*, i8** %8
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %25, %28
br i1 %29, label %30, label %37
30: ; preds = %22
%31 = load i8*, i8** %7
%32 = load i8*, i8** %6
%33 = ptrtoint i8* %31 to i64
%34 = ptrtoint i8* %32 to i64
%35 = sub i64 %33, %34
%36 = trunc i64 %35 to i32
store i32 %36, i32* %3
br label %44
37: ; preds = %22
%38 = load i8*, i8** %8
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %8
br label %18
40: ; preds = %18
%41 = load i8*, i8** %7
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %7
br label %12
43: ; preds = %12
store i32 -1, i32* %3
br label %44
44: ; preds = %43, %30
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
%struct.string = type { i32 }
define i32 @string_find_first_of(%struct.string* %0, i8* nocapture %1) {
%3 = tail call i8* @string_get(%struct.string* %0)
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
br i1 %5, label %29, label %6
6: ; preds = %2
%7 = load i8, i8* %1
%8 = icmp eq i8 %7, 0
br label %9
9: ; preds = %6, %25
%10 = phi i8 [ %4, %6 ], [ %27, %25 ]
%11 = phi i8* [ %3, %6 ], [ %26, %25 ]
br i1 %8, label %25, label %15
12: ; preds = %15
%13 = load i8, i8* %19
%14 = icmp eq i8 %13, 0
br i1 %14, label %25, label %15
15: ; preds = %9, %12
%16 = phi i8 [ %13, %12 ], [ %7, %9 ]
%17 = phi i8* [ %19, %12 ], [ %1, %9 ]
%18 = icmp eq i8 %10, %16
%19 = getelementptr inbounds i8, i8* %17, i64 1
br i1 %18, label %20, label %12
20: ; preds = %15
%21 = ptrtoint i8* %11 to i64
%22 = ptrtoint i8* %3 to i64
%23 = sub i64 %21, %22
%24 = trunc i64 %23 to i32
br label %29
25: ; preds = %12, %9
%26 = getelementptr inbounds i8, i8* %11, i64 1
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %9
29: ; preds = %25, %2, %20
%30 = phi i32 [ %24, %20 ], [ -1, %2 ], [ -1, %25 ]
ret i32 %30
}