#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 */
scalar_t__ strchr(char const *, char);
int makemask(const char *smask, int count) {
  int mask = 0;
  if (strchr(smask, 'c'))
    mask |= (1 << 0);
  if (strchr(smask, 'r'))
    mask |= (1 << 1);
  if (strchr(smask, 'l'))
    mask |= (1 << 2);
  if (count > 0)
    mask |= (1 << 3);
  return mask;
}


x86 assembly (clang, -O0):
<makemask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x63,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     1147 <makemask+0x37>
mov    -0x10(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x72,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     1168 <makemask+0x58>
mov    -0x10(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x6c,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     1189 <makemask+0x79>
mov    -0x10(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    119c <makemask+0x8c>
mov    -0x10(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makemask>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
mov    $0x63,%esi
call   1030 <strchr@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %r15,%rdi
mov    $0x72,%esi
call   1030 <strchr@plt>
lea    0x2(%rbp),%ebx
test   %rax,%rax
cmove  %ebp,%ebx
mov    %r15,%rdi
mov    $0x6c,%esi
call   1030 <strchr@plt>
lea    0x4(%rbx),%ecx
test   %rax,%rax
cmove  %ebx,%ecx
lea    0x8(%rcx),%eax
test   %r14d,%r14d
cmovle %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @makemask(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = call i64 @strchr(i8* %6, i8 signext 99)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* %5
%11 = or i32 %10, 1
store i32 %11, i32* %5
br label %12
12: ; preds = %9, %2
%13 = load i8*, i8** %3
%14 = call i64 @strchr(i8* %13, i8 signext 114)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %5
%18 = or i32 %17, 2
store i32 %18, i32* %5
br label %19
19: ; preds = %16, %12
%20 = load i8*, i8** %3
%21 = call i64 @strchr(i8* %20, i8 signext 108)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i32, i32* %5
%25 = or i32 %24, 4
store i32 %25, i32* %5
br label %26
26: ; preds = %23, %19
%27 = load i32, i32* %4
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %5
%31 = or i32 %30, 8
store i32 %31, i32* %5
br label %32
32: ; preds = %29, %26
%33 = load i32, i32* %5
ret i32 %33
}

LLVM IR (-O2):
define i32 @makemask(i8* %0, i32 %1) {
%3 = tail call i64 @strchr(i8* %0, i8 signext 99)
%4 = icmp ne i64 %3, 0
%5 = zext i1 %4 to i32
%6 = tail call i64 @strchr(i8* %0, i8 signext 114)
%7 = icmp eq i64 %6, 0
%8 = or i32 %5, 2
%9 = select i1 %7, i32 %5, i32 %8
%10 = tail call i64 @strchr(i8* %0, i8 signext 108)
%11 = icmp eq i64 %10, 0
%12 = or i32 %9, 4
%13 = select i1 %11, i32 %9, i32 %12
%14 = icmp sgt i32 %1, 0
%15 = or i32 %13, 8
%16 = select i1 %14, i32 %15, i32 %13
ret i32 %16
}