char *bmap2dow(unsigned char bmap) {
  static char buff[10];
  int j;
  char *days = "smtwtfs";
  char *err = "-error-";
  unsigned char mask = 0x01;
  if (bmap > 127)
    return err;
  for (j = 0; j < 7; j++) {
    buff[j] = (mask & bmap) ? days[j] : '.';
    mask = mask << 1;
  }
  buff[7] = '\0';
  return buff;
}


x86 assembly (clang, -O0):
<bmap2dow>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x9(%rbp)
lea    0xeef(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xeec(%rip),%rax
mov    %rax,-0x20(%rbp)
movb   $0x1,-0x21(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0x7f,%eax
jle    113e <bmap2dow+0x3e>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c0 <bmap2dow+0xc0>
movl   $0x0,-0x10(%rbp)
cmpl   $0x7,-0x10(%rbp)
jge    11ae <bmap2dow+0xae>
movzbl -0x21(%rbp),%eax
movzbl -0x9(%rbp),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1176 <bmap2dow+0x76>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x28(%rbp)
jmp    1183 <bmap2dow+0x83>
mov    $0x2e,%eax
mov    %eax,-0x28(%rbp)
jmp    1183 <bmap2dow+0x83>
mov    -0x28(%rbp),%eax
mov    %al,%dl
movslq -0x10(%rbp),%rcx
lea    0x2e8e(%rip),%rax
mov    %dl,(%rax,%rcx,1)
movzbl -0x21(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x21(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1145 <bmap2dow+0x45>
movb   $0x0,0x2e73(%rip)
lea    0x2e65(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bmap2dow>:
test   %dil,%dil
js     11a1 <bmap2dow+0xa1>
test   $0x1,%dil
mov    $0x2e,%edx
mov    $0x73,%r8d
mov    $0x73,%eax
cmove  %edx,%eax
mov    %al,0x2efb(%rip)
lea    0x2ef4(%rip),%rax
test   $0x2,%dil
mov    $0x6d,%esi
cmove  %edx,%esi
mov    %sil,0x2ee2(%rip)
test   $0x4,%dil
mov    $0x74,%esi
cmove  %edx,%esi
mov    %sil,0x2ed0(%rip)
test   $0x8,%dil
mov    $0x77,%esi
cmove  %edx,%esi
mov    $0x74,%ecx
test   $0x10,%dil
cmove  %edx,%ecx
mov    %sil,0x2eb2(%rip)
mov    %cl,0x2ead(%rip)
test   $0x20,%dil
mov    $0x66,%ecx
cmove  %edx,%ecx
mov    %cl,0x2e9c(%rip)
test   $0x40,%dil
cmove  %edx,%r8d
mov    %r8b,0x2e8e(%rip)
movb   $0x0,0x2e88(%rip)
ret
lea    0xe58(%rip),%rax
ret

LLVM IR (-O0):
@bmap2dow.buff = internal global [10 x i8] zeroinitializer
@.str = [8 x i8] c"smtwtfs\00"
@.str.1 = [8 x i8] c"-error-\00"
define i8* @bmap2dow(i8 zeroext %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8
store i8 %0, i8* %3
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %6
store i8 1, i8* %7
%8 = load i8, i8* %3
%9 = zext i8 %8 to i32
%10 = icmp sgt i32 %9, 127
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = load i8*, i8** %6
store i8* %12, i8** %2
br label %46
13: ; preds = %1
store i32 0, i32* %4
br label %14
14: ; preds = %42, %13
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 7
br i1 %16, label %17, label %45
17: ; preds = %14
%18 = load i8, i8* %7
%19 = zext i8 %18 to i32
%20 = load i8, i8* %3
%21 = zext i8 %20 to i32
%22 = and i32 %19, %21
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %17
%25 = load i8*, i8** %5
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
br label %32
31: ; preds = %17
br label %32
32: ; preds = %31, %24
%33 = phi i32 [ %30, %24 ], [ 46, %31 ]
%34 = trunc i32 %33 to i8
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [10 x i8], [10 x i8]* @bmap2dow.buff, i64 0, i64 %36
store i8 %34, i8* %37
%38 = load i8, i8* %7
%39 = zext i8 %38 to i32
%40 = shl i32 %39, 1
%41 = trunc i32 %40 to i8
store i8 %41, i8* %7
br label %42
42: ; preds = %32
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %14
45: ; preds = %14
store i8 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @bmap2dow.buff, i64 0, i64 7)
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @bmap2dow.buff, i64 0, i64 0), i8** %2
br label %46
46: ; preds = %45, %11
%47 = load i8*, i8** %2
ret i8* %47
}

LLVM IR (-O2):
@bmap2dow.buff = internal global [10 x i8] zeroinitializer
@.str.1 = [8 x i8] c"-error-\00"
define i8* @bmap2dow(i8 zeroext %0) {
%2 = zext i8 %0 to i32
%3 = icmp slt i8 %0, 0
br i1 %3, label %26, label %4
4: ; preds = %1
%5 = and i32 %2, 1
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i8 46, i8 115
store i8 %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @bmap2dow.buff, i64 0, i64 0)
%8 = and i32 %2, 2
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8 46, i8 109
store i8 %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @bmap2dow.buff, i64 0, i64 1)
%11 = and i32 %2, 4
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8 46, i8 116
store i8 %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @bmap2dow.buff, i64 0, i64 2)
%14 = and i32 %2, 8
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i8 46, i8 119
store i8 %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @bmap2dow.buff, i64 0, i64 3)
%17 = and i32 %2, 16
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8 46, i8 116
store i8 %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @bmap2dow.buff, i64 0, i64 4)
%20 = and i32 %2, 32
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i8 46, i8 102
store i8 %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @bmap2dow.buff, i64 0, i64 5)
%23 = and i32 %2, 64
%24 = icmp eq i32 %23, 0
%25 = select i1 %24, i8 46, i8 115
store i8 %25, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @bmap2dow.buff, i64 0, i64 6)
store i8 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @bmap2dow.buff, i64 0, i64 7)
br label %26
26: ; preds = %1, %4
%27 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @bmap2dow.buff, i64 0, i64 0), %4 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %1 ]
ret i8* %27
}