#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 *, char);
int strtowdays(char *str) {
  int j;
  int result = 0;
  for (j = 0; str[j] && (j < 7); ++j) {
    if (!strchr("-_", str[j]))
      result |= 1 << ((j + 1) % 7);
  }
  return result;
}


x86 assembly (clang, -O0):
<strtowdays>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     114e <strtowdays+0x3e>
cmpl   $0x7,-0xc(%rbp)
setl   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    115e <strtowdays+0x4e>
jmp    11af <strtowdays+0x9f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
lea    0xe93(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <strchr@plt>
cmp    $0x0,%eax
jne    119c <strtowdays+0x8c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11a1 <strtowdays+0x91>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112a <strtowdays+0x1a>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtowdays>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1195 <strtowdays+0x85>
mov    %rdi,%r12
xor    %ebx,%ebx
mov    $0x1,%ebp
lea    0xed1(%rip),%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <strchr@plt>
test   %eax,%eax
jne    1179 <strtowdays+0x69>
mov    %ebp,%eax
imul   $0x24924925,%rax,%rax
shr    $0x20,%rax
mov    %ebp,%ecx
sub    %eax,%ecx
shr    %ecx
add    %eax,%ecx
shr    $0x2,%ecx
mov    %ecx,%eax
shl    $0x3,%eax
neg    %eax
add    %ecx,%eax
add    $0x1,%eax
add    %ebx,%eax
bts    %eax,%r15d
movzbl 0x1(%r12,%rbx,1),%eax
test   %al,%al
je     1198 <strtowdays+0x88>
lea    0x1(%rbx),%rcx
add    $0x1,%ebp
cmp    $0x6,%rbx
mov    %rcx,%rbx
jb     1140 <strtowdays+0x30>
jmp    1198 <strtowdays+0x88>
xor    %r15d,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"-_\00"
define i32 @strtowdays(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %27, label %4
4: ; preds = %1, %18
%5 = phi i64 [ %20, %18 ], [ 0, %1 ]
%6 = phi i8 [ %23, %18 ], [ %2, %1 ]
%7 = phi i32 [ %19, %18 ], [ 0, %1 ]
%8 = phi i32 [ %21, %18 ], [ 0, %1 ]
%9 = tail call i32 @strchr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %6)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %4
%12 = trunc i32 %8 to i8
%13 = add i8 %12, 1
%14 = urem i8 %13, 7
%15 = zext i8 %14 to i32
%16 = shl nuw nsw i32 1, %15
%17 = or i32 %16, %7
br label %18
18: ; preds = %4, %11
%19 = phi i32 [ %7, %4 ], [ %17, %11 ]
%20 = add nuw nsw i64 %5, 1
%21 = add nuw nsw i32 %8, 1
%22 = getelementptr inbounds i8, i8* %0, i64 %20
%23 = load i8, i8* %22
%24 = icmp ne i8 %23, 0
%25 = icmp ult i64 %5, 6
%26 = select i1 %24, i1 %25, i1 false
br i1 %26, label %4, label %27
27: ; preds = %18, %1
%28 = phi i32 [ 0, %1 ], [ %19, %18 ]
ret i32 %28
}