long str$find_first_in_set(
    const struct dsc$descriptor_s *first_source_string,
    const struct dsc$descriptor_s *second_source_string) {
  char *s1_ptr;
  unsigned short s1_length;
  char *s2_ptr;
  unsigned short s2_length;
  int loop1;
  int loop2;
  str$analyze_sdesc(first_source_string, &s1_length, &s1_ptr);
  str$analyze_sdesc(second_source_string, &s2_length, &s2_ptr);
  if ((s1_length == 0) || (s2_length == 0)) {
    return 0;
  }
  for (loop1 = 0; loop1 < s1_length; loop1++) {
    for (loop2 = 0; loop2 < s2_length; loop2++) {
      if (s1_ptr[loop1] == s2_ptr[loop2]) {
        return loop1 + 1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<str$find_first_in_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x22(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <str$analyze_sdesc@plt>
mov    -0x18(%rbp),%rdi
lea    -0x32(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1030 <str$analyze_sdesc@plt>
movzwl -0x22(%rbp),%eax
cmp    $0x0,%eax
je     1160 <str$find_first_in_set+0x50>
movzwl -0x32(%rbp),%eax
cmp    $0x0,%eax
jne    116d <str$find_first_in_set+0x5d>
movq   $0x0,-0x8(%rbp)
jmp    11f8 <str$find_first_in_set+0xe8>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
movzwl -0x22(%rbp),%ecx
cmp    %ecx,%eax
jge    11f0 <str$find_first_in_set+0xe0>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
movzwl -0x32(%rbp),%ecx
cmp    %ecx,%eax
jge    11dd <str$find_first_in_set+0xcd>
mov    -0x20(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x30(%rbp),%rcx
movslq -0x3c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11ca <str$find_first_in_set+0xba>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
mov    %rax,-0x8(%rbp)
jmp    11f8 <str$find_first_in_set+0xe8>
jmp    11cf <str$find_first_in_set+0xbf>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    118a <str$find_first_in_set+0x7a>
jmp    11e2 <str$find_first_in_set+0xd2>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1174 <str$find_first_in_set+0x64>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str$find_first_in_set>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
xor    %r14d,%r14d
lea    0x6(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1030 <str$analyze_sdesc@plt>
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <str$analyze_sdesc@plt>
movzwl 0x6(%rsp),%eax
test   %rax,%rax
je     118f <str$find_first_in_set+0x7f>
movzwl 0x4(%rsp),%ecx
test   %cx,%cx
je     118f <str$find_first_in_set+0x7f>
movzwl %cx,%ecx
mov    0x10(%rsp),%r8
mov    0x8(%rsp),%rdi
xor    %r14d,%r14d
xor    %edx,%edx
mov    (%r8,%rdx,1),%bl
xor    %esi,%esi
xchg   %ax,%ax
cmp    (%rdi,%rsi,1),%bl
je     1189 <str$find_first_in_set+0x79>
add    $0x1,%rsi
cmp    %rsi,%rcx
jne    1170 <str$find_first_in_set+0x60>
add    $0x1,%rdx
cmp    %rax,%rdx
jne    1168 <str$find_first_in_set+0x58>
jmp    118f <str$find_first_in_set+0x7f>
add    $0x1,%edx
mov    %rdx,%r14
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%"struct.dsc$descriptor_s" = type opaque
define i64 @"str$find_first_in_set"(%"struct.dsc$descriptor_s"* %0, %"struct.dsc$descriptor_s"* %1) {
%3 = alloca i64
%4 = alloca %"struct.dsc$descriptor_s"*
%5 = alloca %"struct.dsc$descriptor_s"*
%6 = alloca i8*
%7 = alloca i16
%8 = alloca i8*
%9 = alloca i16
%10 = alloca i32
%11 = alloca i32
store %"struct.dsc$descriptor_s"* %0, %"struct.dsc$descriptor_s"** %4
store %"struct.dsc$descriptor_s"* %1, %"struct.dsc$descriptor_s"** %5
%12 = load %"struct.dsc$descriptor_s"*, %"struct.dsc$descriptor_s"** %4
%13 = call i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...) bitcast (i32 (...)* @"str$analyze_sdesc" to i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...)*)(%"struct.dsc$descriptor_s"* %12, i16* %7, i8** %6)
%14 = load %"struct.dsc$descriptor_s"*, %"struct.dsc$descriptor_s"** %5
%15 = call i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...) bitcast (i32 (...)* @"str$analyze_sdesc" to i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...)*)(%"struct.dsc$descriptor_s"* %14, i16* %9, i8** %8)
%16 = load i16, i16* %7
%17 = zext i16 %16 to i32
%18 = icmp eq i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %2
%20 = load i16, i16* %9
%21 = zext i16 %20 to i32
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19, %2
store i64 0, i64* %3
br label %63
24: ; preds = %19
store i32 0, i32* %10
br label %25
25: ; preds = %59, %24
%26 = load i32, i32* %10
%27 = load i16, i16* %7
%28 = zext i16 %27 to i32
%29 = icmp slt i32 %26, %28
br i1 %29, label %30, label %62
30: ; preds = %25
store i32 0, i32* %11
br label %31
31: ; preds = %55, %30
%32 = load i32, i32* %11
%33 = load i16, i16* %9
%34 = zext i16 %33 to i32
%35 = icmp slt i32 %32, %34
br i1 %35, label %36, label %58
36: ; preds = %31
%37 = load i8*, i8** %6
%38 = load i32, i32* %10
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = load i8*, i8** %8
%44 = load i32, i32* %11
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %42, %48
br i1 %49, label %50, label %54
50: ; preds = %36
%51 = load i32, i32* %10
%52 = add nsw i32 %51, 1
%53 = sext i32 %52 to i64
store i64 %53, i64* %3
br label %63
54: ; preds = %36
br label %55
55: ; preds = %54
%56 = load i32, i32* %11
%57 = add nsw i32 %56, 1
store i32 %57, i32* %11
br label %31
58: ; preds = %31
br label %59
59: ; preds = %58
%60 = load i32, i32* %10
%61 = add nsw i32 %60, 1
store i32 %61, i32* %10
br label %25
62: ; preds = %25
store i64 0, i64* %3
br label %63
63: ; preds = %62, %50, %23
%64 = load i64, i64* %3
ret i64 %64
}

LLVM IR (-O2):
%"struct.dsc$descriptor_s" = type opaque
define i64 @"str$find_first_in_set"(%"struct.dsc$descriptor_s"* %0, %"struct.dsc$descriptor_s"* %1) {
%3 = alloca i8*
%4 = alloca i16
%5 = alloca i8*
%6 = alloca i16
%7 = bitcast i8** %3 to i8*
%8 = bitcast i16* %4 to i8*
%9 = bitcast i8** %5 to i8*
%10 = bitcast i16* %6 to i8*
%11 = call i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...) bitcast (i32 (...)* @"str$analyze_sdesc" to i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...)*)(%"struct.dsc$descriptor_s"* %0, i16* %4, i8** %3)
%12 = call i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...) bitcast (i32 (...)* @"str$analyze_sdesc" to i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...)*)(%"struct.dsc$descriptor_s"* %1, i16* %6, i8** %5)
%13 = load i16, i16* %4
%14 = icmp eq i16 %13, 0
%15 = load i16, i16* %6
%16 = icmp eq i16 %15, 0
%17 = select i1 %14, i1 true, i1 %16
br i1 %17, label %41, label %18
18: ; preds = %2
%19 = load i8*, i8** %3
%20 = load i8*, i8** %5
%21 = zext i16 %13 to i64
%22 = zext i16 %15 to i64
br label %23
23: ; preds = %38, %18
%24 = phi i64 [ 0, %18 ], [ %39, %38 ]
%25 = getelementptr inbounds i8, i8* %19, i64 %24
%26 = load i8, i8* %25
br label %29
27: ; preds = %29
%28 = icmp eq i64 %34, %22
br i1 %28, label %38, label %29
29: ; preds = %23, %27
%30 = phi i64 [ 0, %23 ], [ %34, %27 ]
%31 = getelementptr inbounds i8, i8* %20, i64 %30
%32 = load i8, i8* %31
%33 = icmp eq i8 %26, %32
%34 = add nuw nsw i64 %30, 1
br i1 %33, label %35, label %27
35: ; preds = %29
%36 = add nuw i64 %24, 1
%37 = and i64 %36, 4294967295
br label %41
38: ; preds = %27
%39 = add nuw nsw i64 %24, 1
%40 = icmp eq i64 %39, %21
br i1 %40, label %41, label %23
41: ; preds = %38, %2, %35
%42 = phi i64 [ %37, %35 ], [ 0, %2 ], [ 0, %38 ]
ret i64 %42
}