#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 gdbwire_string {
  int dummy;
};

/* Variables and functions */
char *gdbwire_string_data(struct gdbwire_string *);
size_t gdbwire_string_size(struct gdbwire_string *);
size_t gdbwire_string_find_first_of(struct gdbwire_string *string,
                                    const char *chars) {
  size_t data_pos, data_size = 0;
  char *data_cur;
  const char *chars_cur;
  if (string && chars) {
    data_size = gdbwire_string_size(string);
    data_cur = gdbwire_string_data(string);
    for (data_pos = 0; data_pos < data_size; ++data_pos) {
      char data_c = data_cur[data_pos];
      for (chars_cur = chars; *chars_cur; ++chars_cur) {
        if (data_c == *chars_cur) {
          return data_pos;
        }
      }
    }
  }
  return data_size;
}


x86 assembly (clang, -O0):
<gdbwire_string_find_first_of>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11f2 <gdbwire_string_find_first_of+0xd2>
cmpq   $0x0,-0x18(%rbp)
je     11f2 <gdbwire_string_find_first_of+0xd2>
mov    -0x10(%rbp),%rdi
call   1040 <gdbwire_string_size@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <gdbwire_string_data@plt>
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11ed <gdbwire_string_find_first_of+0xcd>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x39(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmpb   $0x0,(%rax)
je     11d7 <gdbwire_string_find_first_of+0xb7>
movsbl -0x39(%rbp),%eax
mov    -0x38(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11c1 <gdbwire_string_find_first_of+0xa1>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11fa <gdbwire_string_find_first_of+0xda>
jmp    11c6 <gdbwire_string_find_first_of+0xa6>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1194 <gdbwire_string_find_first_of+0x74>
jmp    11dc <gdbwire_string_find_first_of+0xbc>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1170 <gdbwire_string_find_first_of+0x50>
jmp    11f2 <gdbwire_string_find_first_of+0xd2>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gdbwire_string_find_first_of>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
test   %rdi,%rdi
je     1193 <gdbwire_string_find_first_of+0x73>
mov    %rsi,%r15
test   %rsi,%rsi
je     1193 <gdbwire_string_find_first_of+0x73>
mov    %rdi,%rbx
call   1040 <gdbwire_string_size@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <gdbwire_string_data@plt>
test   %r14,%r14
je     1191 <gdbwire_string_find_first_of+0x71>
mov    %rax,%rdi
mov    (%r15),%cl
add    $0x1,%r15
xor    %eax,%eax
jmp    1169 <gdbwire_string_find_first_of+0x49>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rax
cmp    %r14,%rax
je     1199 <gdbwire_string_find_first_of+0x79>
test   %cl,%cl
je     1160 <gdbwire_string_find_first_of+0x40>
mov    (%rdi,%rax,1),%bl
mov    %r15,%rsi
mov    %ecx,%edx
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %dl,%bl
je     1193 <gdbwire_string_find_first_of+0x73>
movzbl (%rsi),%edx
add    $0x1,%rsi
test   %dl,%dl
jne    1180 <gdbwire_string_find_first_of+0x60>
jmp    1160 <gdbwire_string_find_first_of+0x40>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r14,%rax
jmp    1193 <gdbwire_string_find_first_of+0x73>

LLVM IR (-O0):
%struct.gdbwire_string = type { i32 }
define i64 @gdbwire_string_find_first_of(%struct.gdbwire_string* %0, i8* %1) {
%3 = alloca i64
%4 = alloca %struct.gdbwire_string*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8
store %struct.gdbwire_string* %0, %struct.gdbwire_string** %4
store i8* %1, i8** %5
store i64 0, i64* %7
%11 = load %struct.gdbwire_string*, %struct.gdbwire_string** %4
%12 = icmp ne %struct.gdbwire_string* %11, null
br i1 %12, label %13, label %53
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %53
16: ; preds = %13
%17 = load %struct.gdbwire_string*, %struct.gdbwire_string** %4
%18 = call i64 @gdbwire_string_size(%struct.gdbwire_string* %17)
store i64 %18, i64* %7
%19 = load %struct.gdbwire_string*, %struct.gdbwire_string** %4
%20 = call i8* @gdbwire_string_data(%struct.gdbwire_string* %19)
store i8* %20, i8** %8
store i64 0, i64* %6
br label %21
21: ; preds = %49, %16
%22 = load i64, i64* %6
%23 = load i64, i64* %7
%24 = icmp ult i64 %22, %23
br i1 %24, label %25, label %52
25: ; preds = %21
%26 = load i8*, i8** %8
%27 = load i64, i64* %6
%28 = getelementptr inbounds i8, i8* %26, i64 %27
%29 = load i8, i8* %28
store i8 %29, i8* %10
%30 = load i8*, i8** %5
store i8* %30, i8** %9
br label %31
31: ; preds = %45, %25
%32 = load i8*, i8** %9
%33 = load i8, i8* %32
%34 = icmp ne i8 %33, 0
br i1 %34, label %35, label %48
35: ; preds = %31
%36 = load i8, i8* %10
%37 = sext i8 %36 to i32
%38 = load i8*, i8** %9
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %37, %40
br i1 %41, label %42, label %44
42: ; preds = %35
%43 = load i64, i64* %6
store i64 %43, i64* %3
br label %55
44: ; preds = %35
br label %45
45: ; preds = %44
%46 = load i8*, i8** %9
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %9
br label %31
48: ; preds = %31
br label %49
49: ; preds = %48
%50 = load i64, i64* %6
%51 = add i64 %50, 1
store i64 %51, i64* %6
br label %21
52: ; preds = %21
br label %53
53: ; preds = %52, %13, %2
%54 = load i64, i64* %7
store i64 %54, i64* %3
br label %55
55: ; preds = %53, %42
%56 = load i64, i64* %3
ret i64 %56
}

LLVM IR (-O2):
%struct.gdbwire_string = type { i32 }
define i64 @gdbwire_string_find_first_of(%struct.gdbwire_string* %0, i8* %1) {
%3 = icmp ne %struct.gdbwire_string* %0, null
%4 = icmp ne i8* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %28
6: ; preds = %2
%7 = tail call i64 @gdbwire_string_size(%struct.gdbwire_string* %0)
%8 = tail call i8* @gdbwire_string_data(%struct.gdbwire_string* %0)
%9 = icmp eq i64 %7, 0
br i1 %9, label %28, label %10
10: ; preds = %6
%11 = load i8, i8* %1
%12 = icmp eq i8 %11, 0
br label %13
13: ; preds = %10, %25
%14 = phi i64 [ 0, %10 ], [ %26, %25 ]
%15 = getelementptr inbounds i8, i8* %8, i64 %14
%16 = load i8, i8* %15
br i1 %12, label %25, label %20
17: ; preds = %20
%18 = load i8, i8* %24
%19 = icmp eq i8 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %13, %17
%21 = phi i8 [ %18, %17 ], [ %11, %13 ]
%22 = phi i8* [ %24, %17 ], [ %1, %13 ]
%23 = icmp eq i8 %16, %21
%24 = getelementptr inbounds i8, i8* %22, i64 1
br i1 %23, label %28, label %17
25: ; preds = %17, %13
%26 = add nuw i64 %14, 1
%27 = icmp eq i64 %26, %7
br i1 %27, label %28, label %13
28: ; preds = %25, %20, %6, %2
%29 = phi i64 [ 0, %2 ], [ 0, %6 ], [ %14, %20 ], [ %7, %25 ]
ret i64 %29
}