#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*/ *strchr(char const *, char);
scalar_t__ strlen(char *);
short ppos(const char *s) {
  char c[] = "nsmewc";
  int p[] = {1, 2, 0, 4, 8, 0};
  int i;
  short pos = 0;
  for (i = 0; i < (int)strlen(c); i++)
    if (strchr(s, c[i]) != NULL)
      pos |= p[i];
  return pos;
}


x86 assembly (clang, -O0):
<ppos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xece(%rip),%eax
mov    %eax,-0xf(%rbp)
mov    0xec8(%rip),%ax
mov    %ax,-0xb(%rbp)
mov    0xec0(%rip),%al
mov    %al,-0x9(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
movw   $0x0,-0x36(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
lea    -0xf(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
jge    11d5 <ppos+0xb5>
mov    -0x8(%rbp),%rdi
movslq -0x34(%rbp),%rax
movsbl -0xf(%rbp,%rax,1),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11c2 <ppos+0xa2>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
movswl -0x36(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x36(%rbp)
jmp    11c7 <ppos+0xa7>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1177 <ppos+0x57>
movswl -0x36(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ppos>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x6e,%esi
call   1030 <strchr@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %r14,%rdi
mov    $0x73,%esi
call   1030 <strchr@plt>
lea    0x2(%rbp),%r15d
test   %rax,%rax
cmove  %ebp,%r15d
mov    %r14,%rdi
mov    $0x6d,%esi
call   1030 <strchr@plt>
mov    %r14,%rdi
mov    $0x65,%esi
call   1030 <strchr@plt>
lea    0x4(%r15),%ebx
test   %rax,%rax
cmove  %r15d,%ebx
mov    %r14,%rdi
mov    $0x77,%esi
call   1030 <strchr@plt>
lea    0x8(%rbx),%ebp
test   %rax,%rax
cmove  %ebx,%ebp
mov    %r14,%rdi
mov    $0x63,%esi
call   1030 <strchr@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.ppos.c = [7 x i8] c"nsmewc\00"
@__const.ppos.p = [6 x i32] [i32 1, i32 2, i32 0, i32 4, i32 8, i32 0]
define signext i16 @ppos(i8* %0) {
%2 = alloca i8*
%3 = alloca [7 x i8]
%4 = alloca [6 x i32]
%5 = alloca i32
%6 = alloca i16
store i8* %0, i8** %2
%7 = bitcast [7 x i8]* %3 to i8*
%8 = bitcast [6 x i32]* %4 to i8*
store i16 0, i16* %6
store i32 0, i32* %5
br label %9
9: ; preds = %33, %1
%10 = load i32, i32* %5
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%12 = call i64 @strlen(i8* %11)
%13 = trunc i64 %12 to i32
%14 = icmp slt i32 %10, %13
br i1 %14, label %15, label %36
15: ; preds = %9
%16 = load i8*, i8** %2
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = call i32* @strchr(i8* %16, i8 signext %20)
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %32
23: ; preds = %15
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = load i16, i16* %6
%29 = sext i16 %28 to i32
%30 = or i32 %29, %27
%31 = trunc i32 %30 to i16
store i16 %31, i16* %6
br label %32
32: ; preds = %23, %15
br label %33
33: ; preds = %32
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %9
36: ; preds = %9
%37 = load i16, i16* %6
ret i16 %37
}

LLVM IR (-O2):
define signext i16 @ppos(i8* %0) {
%2 = tail call i32* @strchr(i8* %0, i8 signext 110)
%3 = icmp ne i32* %2, null
%4 = zext i1 %3 to i16
%5 = tail call i32* @strchr(i8* %0, i8 signext 115)
%6 = icmp eq i32* %5, null
%7 = or i16 %4, 2
%8 = select i1 %6, i16 %4, i16 %7
%9 = tail call i32* @strchr(i8* %0, i8 signext 109)
%10 = tail call i32* @strchr(i8* %0, i8 signext 101)
%11 = icmp eq i32* %10, null
%12 = or i16 %8, 4
%13 = select i1 %11, i16 %8, i16 %12
%14 = tail call i32* @strchr(i8* %0, i8 signext 119)
%15 = icmp eq i32* %14, null
%16 = or i16 %13, 8
%17 = select i1 %15, i16 %13, i16 %16
%18 = tail call i32* @strchr(i8* %0, i8 signext 99)
ret i16 %17
}