#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 */
typedef scalar_t__ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ add_bits_filter(scalar_t__, scalar_t__);
scalar_t__ parse_flag_names(char const *, int);
char *strchr(char const *, char);
void parse_bits_mask(const char *optarg) {
  uint64_t mask;
  uint64_t bits;
  const char *p;
  p = strchr(optarg, '=');
  if (p == optarg) {
    mask = ((uint64_t)~0ULL);
    bits = parse_flag_names(p + 1, 0);
  } else if (p) {
    mask = parse_flag_names(optarg, 0);
    bits = parse_flag_names(p + 1, 0);
  } else if (strchr(optarg, '~')) {
    mask = parse_flag_names(optarg, 1);
    bits = parse_flag_names(optarg, 0);
  } else {
    mask = parse_flag_names(optarg, 0);
    bits = ((uint64_t)~0ULL);
  }
  add_bits_filter(mask, bits);
}


x86 assembly (clang, -O0):
<parse_bits_mask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    117c <parse_bits_mask+0x4c>
movq   $0xffffffffffffffff,-0x10(%rbp)
ff
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
xor    %esi,%esi
call   1050 <parse_flag_names@plt>
mov    %rax,-0x18(%rbp)
jmp    120d <parse_bits_mask+0xdd>
cmpq   $0x0,-0x20(%rbp)
je     11ae <parse_bits_mask+0x7e>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1050 <parse_flag_names@plt>
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
xor    %esi,%esi
call   1050 <parse_flag_names@plt>
mov    %rax,-0x18(%rbp)
jmp    1208 <parse_bits_mask+0xd8>
mov    -0x8(%rbp),%rdi
mov    $0x7e,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11ec <parse_bits_mask+0xbc>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1050 <parse_flag_names@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1050 <parse_flag_names@plt>
mov    %rax,-0x18(%rbp)
jmp    1203 <parse_bits_mask+0xd3>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1050 <parse_flag_names@plt>
mov    %rax,-0x10(%rbp)
movq   $0xffffffffffffffff,-0x18(%rbp)
ff
jmp    1208 <parse_bits_mask+0xd8>
jmp    120d <parse_bits_mask+0xdd>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <add_bits_filter@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_bits_mask>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    $0x3d,%esi
call   1040 <strchr@plt>
cmp    %r15,%rax
je     1165 <parse_bits_mask+0x35>
mov    %rax,%rbx
test   %rax,%rax
je     117f <parse_bits_mask+0x4f>
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <parse_flag_names@plt>
mov    %rax,%r14
add    $0x1,%rbx
mov    %rbx,%rdi
jmp    11a4 <parse_bits_mask+0x74>
add    $0x1,%r15
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <parse_flag_names@plt>
mov    %rax,%rsi
mov    $0xffffffffffffffff,%r14
jmp    11ae <parse_bits_mask+0x7e>
mov    %r15,%rdi
mov    $0x7e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11bb <parse_bits_mask+0x8b>
mov    %r15,%rdi
mov    $0x1,%esi
call   1050 <parse_flag_names@plt>
mov    %rax,%r14
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <parse_flag_names@plt>
mov    %rax,%rsi
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <add_bits_filter@plt>
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <parse_flag_names@plt>
mov    %rax,%r14
mov    $0xffffffffffffffff,%rsi
jmp    11ae <parse_bits_mask+0x7e>

LLVM IR (-O0):
define void @parse_bits_mask(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @strchr(i8* %6, i8 signext 61)
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = load i8*, i8** %2
%10 = icmp eq i8* %8, %9
br i1 %10, label %11, label %15
11: ; preds = %1
store i64 -1, i64* %3
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = call i64 @parse_flag_names(i8* %13, i32 0)
store i64 %14, i64* %4
br label %38
15: ; preds = %1
%16 = load i8*, i8** %5
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i8*, i8** %2
%20 = call i64 @parse_flag_names(i8* %19, i32 0)
store i64 %20, i64* %3
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = call i64 @parse_flag_names(i8* %22, i32 0)
store i64 %23, i64* %4
br label %37
24: ; preds = %15
%25 = load i8*, i8** %2
%26 = call i8* @strchr(i8* %25, i8 signext 126)
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load i8*, i8** %2
%30 = call i64 @parse_flag_names(i8* %29, i32 1)
store i64 %30, i64* %3
%31 = load i8*, i8** %2
%32 = call i64 @parse_flag_names(i8* %31, i32 0)
store i64 %32, i64* %4
br label %36
33: ; preds = %24
%34 = load i8*, i8** %2
%35 = call i64 @parse_flag_names(i8* %34, i32 0)
store i64 %35, i64* %3
store i64 -1, i64* %4
br label %36
36: ; preds = %33, %28
br label %37
37: ; preds = %36, %18
br label %38
38: ; preds = %37, %11
%39 = load i64, i64* %3
%40 = load i64, i64* %4
%41 = call i32 @add_bits_filter(i64 %39, i64 %40)
ret void
}

LLVM IR (-O2):
define void @parse_bits_mask(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 61)
%3 = icmp eq i8* %2, %0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = tail call i64 @parse_flag_names(i8* %5, i32 0)
br label %21
7: ; preds = %1
%8 = icmp eq i8* %2, null
br i1 %8, label %13, label %9
9: ; preds = %7
%10 = tail call i64 @parse_flag_names(i8* %0, i32 0)
%11 = getelementptr inbounds i8, i8* %2, i64 1
%12 = tail call i64 @parse_flag_names(i8* %11, i32 0)
br label %21
13: ; preds = %7
%14 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 126)
%15 = icmp eq i8* %14, null
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call i64 @parse_flag_names(i8* %0, i32 1)
%18 = tail call i64 @parse_flag_names(i8* %0, i32 0)
br label %21
19: ; preds = %13
%20 = tail call i64 @parse_flag_names(i8* %0, i32 0)
br label %21
21: ; preds = %9, %19, %16, %4
%22 = phi i64 [ %6, %4 ], [ %12, %9 ], [ %18, %16 ], [ -1, %19 ]
%23 = phi i64 [ -1, %4 ], [ %10, %9 ], [ %17, %16 ], [ %20, %19 ]
%24 = tail call i32 @add_bits_filter(i64 %23, i64 %22)
ret void
}