int parse_protolist(valp)
char *valp;
{
  int proto_bits = 0;
  if (strstr(valp, "XIM"))
    proto_bits |= (1 << (1));
  if (strstr(valp, "Ximp"))
    proto_bits |= (1 << (2));
  if (strstr(valp, "Xsi"))
    proto_bits |= (1 << (3));
  if (strstr(valp, "None"))
    proto_bits |= (1 << (0));
  return proto_bits;
}


x86 assembly (clang, -O0):
<parse_protolist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed2(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1146 <parse_protolist+0x36>
mov    -0xc(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb3(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1169 <parse_protolist+0x59>
mov    -0xc(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     118c <parse_protolist+0x7c>
mov    -0xc(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     11af <parse_protolist+0x9f>
mov    -0xc(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_protolist>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xee2(%rip),%rsi
call   1030 <strstr@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
lea    (%rbx,%rbx,1),%ebp
lea    0xecf(%rip),%rsi
mov    %r14,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
lea    0x4(%rbx,%rbx,1),%ebx
cmove  %ebp,%ebx
lea    0xebb(%rip),%rsi
mov    %r14,%rdi
call   1030 <strstr@plt>
lea    0x8(%rbx),%ebp
test   %rax,%rax
cmove  %ebx,%ebp
lea    0xea7(%rip),%rsi
mov    %r14,%rdi
call   1030 <strstr@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
or     %ebp,%ecx
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"XIM\00"
@.str.1 = [5 x i8] c"Ximp\00"
@.str.2 = [4 x i8] c"Xsi\00"
@.str.3 = [5 x i8] c"None\00"
define i32 @parse_protolist(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load i8*, i8** %2
%5 = call i8* @strstr(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* %3
%9 = or i32 %8, 2
store i32 %9, i32* %3
br label %10
10: ; preds = %7, %1
%11 = load i8*, i8** %2
%12 = call i8* @strstr(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* %3
%16 = or i32 %15, 4
store i32 %16, i32* %3
br label %17
17: ; preds = %14, %10
%18 = load i8*, i8** %2
%19 = call i8* @strstr(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %3
%23 = or i32 %22, 8
store i32 %23, i32* %3
br label %24
24: ; preds = %21, %17
%25 = load i8*, i8** %2
%26 = call i8* @strstr(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* %3
%30 = or i32 %29, 1
store i32 %30, i32* %3
br label %31
31: ; preds = %28, %24
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str = [4 x i8] c"XIM\00"
@.str.1 = [5 x i8] c"Ximp\00"
@.str.2 = [4 x i8] c"Xsi\00"
@.str.3 = [5 x i8] c"None\00"
define i32 @parse_protolist(i8* %0) {
%2 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
%4 = select i1 %3, i32 0, i32 2
%5 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i8* %5, null
%7 = or i32 %4, 4
%8 = select i1 %6, i32 %4, i32 %7
%9 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i8* %9, null
%11 = or i32 %8, 8
%12 = select i1 %10, i32 %8, i32 %11
%13 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp ne i8* %13, null
%15 = zext i1 %14 to i32
%16 = or i32 %12, %15
ret i32 %16
}