#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 */

/* Variables and functions */
int /*<<< orphan*/ strlen(char const *);
scalar_t__ strncmp(char *, char const *, int /*<<< orphan*/);
char *strtok_r(char *, char *, char **);
void parse_single_option(char *attrs, const int *atflags,
                         const char **atstrings, const int arr_size, int *ret) {
  char *next = NULL, *attribute = NULL;
  if (!strtok_r(attrs, ":", &next)) {
    return;
  }
  while ((attribute = strtok_r(NULL, " ", &next)) != NULL) {
    int idx;
    for (idx = 0; idx < arr_size; idx++) {
      if (0 == strncmp(attribute, atstrings[idx], strlen(atstrings[idx]))) {
        *ret |= atflags[idx];
      }
    }
  }
}


x86 assembly (clang, -O0):
<parse_single_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9a(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1050 <strtok_r@plt>
cmp    $0x0,%rax
jne    117e <parse_single_option+0x4e>
jmp    1229 <parse_single_option+0xf9>
jmp    1183 <parse_single_option+0x53>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe74(%rip),%rsi
lea    -0x30(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     1229 <parse_single_option+0xf9>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1224 <parse_single_option+0xf4>
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1211 <parse_single_option+0xe1>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x28(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
jmp    1216 <parse_single_option+0xe6>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11ac <parse_single_option+0x7c>
jmp    1183 <parse_single_option+0x53>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_single_option>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x10(%rsp)
mov    %ecx,0x4(%rsp)
mov    %rdx,%rbp
mov    %rsi,%r12
movq   $0x0,0x8(%rsp)
lea    0xea3(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
je     1205 <parse_single_option+0xd5>
lea    0xe8b(%rip),%rsi
lea    0x8(%rsp),%rdx
xor    %edi,%edi
call   1050 <strtok_r@plt>
test   %rax,%rax
je     1205 <parse_single_option+0xd5>
mov    %rax,%rbx
mov    0x4(%rsp),%r14d
jmp    11bb <parse_single_option+0x8b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %edi,%edi
lea    0xe59(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1205 <parse_single_option+0xd5>
cmpl   $0x0,0x4(%rsp)
jle    11a0 <parse_single_option+0x70>
xor    %r15d,%r15d
jmp    11d9 <parse_single_option+0xa9>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15
cmp    %r15,%r14
je     11a0 <parse_single_option+0x70>
mov    0x0(%rbp,%r15,8),%r13
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11d0 <parse_single_option+0xa0>
mov    (%r12,%r15,4),%eax
mov    0x10(%rsp),%rcx
or     %eax,(%rcx)
jmp    11d0 <parse_single_option+0xa0>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
@.str.1 = [2 x i8] c" \00"
define void @parse_single_option(i8* %0, i32* nocapture %1, i8** nocapture %2, i32 %3, i32* nocapture %4) {
%6 = alloca i8*
%7 = bitcast i8** %6 to i8*
store i8* null, i8** %6
%8 = call i8* @strtok_r(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6)
%9 = icmp eq i8* %8, null
br i1 %9, label %36, label %10
10: ; preds = %5
%11 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %6)
%12 = icmp eq i8* %11, null
br i1 %12, label %36, label %13
13: ; preds = %10
%14 = icmp sgt i32 %3, 0
%15 = zext i32 %3 to i64
br label %19
16: ; preds = %33, %19
%17 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %6)
%18 = icmp eq i8* %17, null
br i1 %18, label %36, label %19
19: ; preds = %13, %16
%20 = phi i8* [ %11, %13 ], [ %17, %16 ]
br i1 %14, label %21, label %16
21: ; preds = %19, %33
%22 = phi i64 [ %34, %33 ], [ 0, %19 ]
%23 = getelementptr inbounds i8*, i8** %2, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @strlen(i8* %24)
%26 = call i64 @strncmp(i8* %20, i8* %24, i32 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %21
%29 = getelementptr inbounds i32, i32* %1, i64 %22
%30 = load i32, i32* %29
%31 = load i32, i32* %4
%32 = or i32 %31, %30
store i32 %32, i32* %4
br label %33
33: ; preds = %21, %28
%34 = add nuw nsw i64 %22, 1
%35 = icmp eq i64 %34, %15
br i1 %35, label %16, label %21
36: ; preds = %16, %10, %5
ret void
}