const char *find_soh(const char *s) {
  for (;;) {
    unsigned long t = *(const unsigned long *)s;
    if ((t & 0xFFul) == 1ul)
      return s;
    t >>= 8;
    if ((t & 0xFFul) == 1ul)
      return s + 1;
    t >>= 8;
    if ((t & 0xFFul) == 1ul)
      return s + 2;
    t >>= 8;
    if ((t & 0xFFul) == 1ul)
      return s + 3;
    t >>= 8;
    if ((t & 0xFFul) == 1ul)
      return s + 4;
    t >>= 8;
    if ((t & 0xFFul) == 1ul)
      return s + 5;
    t >>= 8;
    if ((t & 0xFFul) == 1ul)
      return s + 6;
    t >>= 8;
    if ((t & 0xFFul) == 1ul)
      return s + 7;
    s += sizeof(unsigned long);
  }
}


x86 assembly (clang, -O0):
<find_soh>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
and    $0xff,%rax
cmp    $0x1,%rax
jne    1134 <find_soh+0x34>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    129c <find_soh+0x19c>
mov    -0x18(%rbp),%rax
shr    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
and    $0xff,%rax
cmp    $0x1,%rax
jne    1165 <find_soh+0x65>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    129c <find_soh+0x19c>
mov    -0x18(%rbp),%rax
shr    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
and    $0xff,%rax
cmp    $0x1,%rax
jne    1196 <find_soh+0x96>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    129c <find_soh+0x19c>
mov    -0x18(%rbp),%rax
shr    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
and    $0xff,%rax
cmp    $0x1,%rax
jne    11c7 <find_soh+0xc7>
mov    -0x10(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x8(%rbp)
jmp    129c <find_soh+0x19c>
mov    -0x18(%rbp),%rax
shr    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
and    $0xff,%rax
cmp    $0x1,%rax
jne    11f8 <find_soh+0xf8>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    129c <find_soh+0x19c>
mov    -0x18(%rbp),%rax
shr    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
and    $0xff,%rax
cmp    $0x1,%rax
jne    1229 <find_soh+0x129>
mov    -0x10(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x8(%rbp)
jmp    129c <find_soh+0x19c>
mov    -0x18(%rbp),%rax
shr    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
and    $0xff,%rax
cmp    $0x1,%rax
jne    125a <find_soh+0x15a>
mov    -0x10(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x8(%rbp)
jmp    129c <find_soh+0x19c>
mov    -0x18(%rbp),%rax
shr    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
and    $0xff,%rax
cmp    $0x1,%rax
jne    128b <find_soh+0x18b>
mov    -0x10(%rbp),%rax
add    $0x7,%rax
mov    %rax,-0x8(%rbp)
jmp    129c <find_soh+0x19c>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1108 <find_soh+0x8>
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_soh>:
mov    %rdi,%rax
mov    (%rdi),%rcx
cmp    $0x1,%cl
jne    110c <find_soh+0xc>
ret
add    $0x4,%rax
movabs $0xff00000000,%r10
movabs $0x100000000,%rsi
movabs $0xff0000000000,%r8
movabs $0x10000000000,%rdi
movabs $0xff000000000000,%r9
movabs $0x1000000000000,%r11
mov    %ecx,%edx
and    $0xff00,%edx
cmp    $0x100,%edx
je     11b8 <find_soh+0xb8>
mov    %ecx,%edx
and    $0xff0000,%edx
cmp    $0x10000,%edx
je     11bd <find_soh+0xbd>
mov    %ecx,%edx
and    $0xff000000,%edx
cmp    $0x1000000,%edx
je     11c2 <find_soh+0xc2>
mov    %rcx,%rdx
and    %r10,%rdx
cmp    %rsi,%rdx
je     110b <find_soh+0xb>
mov    %rcx,%rdx
and    %r8,%rdx
cmp    %rdi,%rdx
je     11c7 <find_soh+0xc7>
mov    %rcx,%rdx
and    %r9,%rdx
cmp    %r11,%rdx
je     11cc <find_soh+0xcc>
shr    $0x38,%rcx
cmp    $0x1,%ecx
je     11d1 <find_soh+0xd1>
mov    0x4(%rax),%rcx
add    $0x8,%rax
cmp    $0x1,%cl
jne    114c <find_soh+0x4c>
add    $0xfffffffffffffffc,%rax
ret
add    $0xfffffffffffffffd,%rax
ret
add    $0xfffffffffffffffe,%rax
ret
add    $0xffffffffffffffff,%rax
ret
add    $0x1,%rax
ret
add    $0x2,%rax
ret
add    $0x3,%rax
ret

LLVM IR (-O0):
define i8* @find_soh(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
br label %5
5: ; preds = %77, %1
%6 = load i8*, i8** %3
%7 = bitcast i8* %6 to i64*
%8 = load i64, i64* %7
store i64 %8, i64* %4
%9 = load i64, i64* %4
%10 = and i64 %9, 255
%11 = icmp eq i64 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %5
%13 = load i8*, i8** %3
store i8* %13, i8** %2
br label %80
14: ; preds = %5
%15 = load i64, i64* %4
%16 = lshr i64 %15, 8
store i64 %16, i64* %4
%17 = load i64, i64* %4
%18 = and i64 %17, 255
%19 = icmp eq i64 %18, 1
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %22, i8** %2
br label %80
23: ; preds = %14
%24 = load i64, i64* %4
%25 = lshr i64 %24, 8
store i64 %25, i64* %4
%26 = load i64, i64* %4
%27 = and i64 %26, 255
%28 = icmp eq i64 %27, 1
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 2
store i8* %31, i8** %2
br label %80
32: ; preds = %23
%33 = load i64, i64* %4
%34 = lshr i64 %33, 8
store i64 %34, i64* %4
%35 = load i64, i64* %4
%36 = and i64 %35, 255
%37 = icmp eq i64 %36, 1
br i1 %37, label %38, label %41
38: ; preds = %32
%39 = load i8*, i8** %3
%40 = getelementptr inbounds i8, i8* %39, i64 3
store i8* %40, i8** %2
br label %80
41: ; preds = %32
%42 = load i64, i64* %4
%43 = lshr i64 %42, 8
store i64 %43, i64* %4
%44 = load i64, i64* %4
%45 = and i64 %44, 255
%46 = icmp eq i64 %45, 1
br i1 %46, label %47, label %50
47: ; preds = %41
%48 = load i8*, i8** %3
%49 = getelementptr inbounds i8, i8* %48, i64 4
store i8* %49, i8** %2
br label %80
50: ; preds = %41
%51 = load i64, i64* %4
%52 = lshr i64 %51, 8
store i64 %52, i64* %4
%53 = load i64, i64* %4
%54 = and i64 %53, 255
%55 = icmp eq i64 %54, 1
br i1 %55, label %56, label %59
56: ; preds = %50
%57 = load i8*, i8** %3
%58 = getelementptr inbounds i8, i8* %57, i64 5
store i8* %58, i8** %2
br label %80
59: ; preds = %50
%60 = load i64, i64* %4
%61 = lshr i64 %60, 8
store i64 %61, i64* %4
%62 = load i64, i64* %4
%63 = and i64 %62, 255
%64 = icmp eq i64 %63, 1
br i1 %64, label %65, label %68
65: ; preds = %59
%66 = load i8*, i8** %3
%67 = getelementptr inbounds i8, i8* %66, i64 6
store i8* %67, i8** %2
br label %80
68: ; preds = %59
%69 = load i64, i64* %4
%70 = lshr i64 %69, 8
store i64 %70, i64* %4
%71 = load i64, i64* %4
%72 = and i64 %71, 255
%73 = icmp eq i64 %72, 1
br i1 %73, label %74, label %77
74: ; preds = %68
%75 = load i8*, i8** %3
%76 = getelementptr inbounds i8, i8* %75, i64 7
store i8* %76, i8** %2
br label %80
77: ; preds = %68
%78 = load i8*, i8** %3
%79 = getelementptr inbounds i8, i8* %78, i64 8
store i8* %79, i8** %3
br label %5
80: ; preds = %74, %65, %56, %47, %38, %29, %20, %12
%81 = load i8*, i8** %2
ret i8* %81
}

LLVM IR (-O2):
define i8* @find_soh(i8* %0) {
%2 = bitcast i8* %0 to i64*
%3 = load i64, i64* %2
%4 = and i64 %3, 255
%5 = icmp eq i64 %4, 1
br i1 %5, label %49, label %6
6: ; preds = %1, %43
%7 = phi i64 [ %46, %43 ], [ %3, %1 ]
%8 = phi i8* [ %44, %43 ], [ %0, %1 ]
%9 = and i64 %7, 65280
%10 = icmp eq i64 %9, 256
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %8, i64 1
br label %49
13: ; preds = %6
%14 = and i64 %7, 16711680
%15 = icmp eq i64 %14, 65536
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = getelementptr inbounds i8, i8* %8, i64 2
br label %49
18: ; preds = %13
%19 = and i64 %7, 4278190080
%20 = icmp eq i64 %19, 16777216
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = getelementptr inbounds i8, i8* %8, i64 3
br label %49
23: ; preds = %18
%24 = and i64 %7, 1095216660480
%25 = icmp eq i64 %24, 4294967296
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = getelementptr inbounds i8, i8* %8, i64 4
br label %49
28: ; preds = %23
%29 = and i64 %7, 280375465082880
%30 = icmp eq i64 %29, 1099511627776
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = getelementptr inbounds i8, i8* %8, i64 5
br label %49
33: ; preds = %28
%34 = and i64 %7, 71776119061217280
%35 = icmp eq i64 %34, 281474976710656
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = getelementptr inbounds i8, i8* %8, i64 6
br label %49
38: ; preds = %33
%39 = and i64 %7, -72057594037927936
%40 = icmp eq i64 %39, 72057594037927936
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = getelementptr inbounds i8, i8* %8, i64 7
br label %49
43: ; preds = %38
%44 = getelementptr inbounds i8, i8* %8, i64 8
%45 = bitcast i8* %44 to i64*
%46 = load i64, i64* %45
%47 = and i64 %46, 255
%48 = icmp eq i64 %47, 1
br i1 %48, label %49, label %6
49: ; preds = %43, %1, %11, %16, %21, %26, %31, %36, %41
%50 = phi i8* [ %42, %41 ], [ %37, %36 ], [ %32, %31 ], [ %27, %26 ], [ %22, %21 ], [ %17, %16 ], [ %12, %11 ], [ %0, %1 ], [ %44, %43 ]
ret i8* %50
}