void int_to_access_type_k(unsigned access, char *str) {
  str[0] = ((access & 0x01) != 0) ? 'r' : '-';
  str[1] = ((access & 0x02) != 0) ? 'w' : '-';
  str[2] = ((access & 0x04) != 0) ? 'x' : '-';
  str[3] = ((access & 0x08) != 0) ? 'a' : '-';
  str[4] = ((access & 0x10) != 0) ? 't' : '-';
  str[5] = '\0';
}


x86 assembly (clang, -O0):
<int_to_access_type_k>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edx
and    $0x1,%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x4(%rbp),%edx
and    $0x2,%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x4(%rbp),%edx
and    $0x4,%edx
mov    $0x2d,%eax
mov    $0x78,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x4(%rbp),%edx
and    $0x8,%edx
mov    $0x2d,%eax
mov    $0x61,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x4(%rbp),%edx
and    $0x10,%edx
mov    $0x2d,%eax
mov    $0x74,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x5(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_to_access_type_k>:
test   $0x1,%dil
mov    $0x2d,%eax
mov    $0x72,%ecx
cmove  %eax,%ecx
mov    %cl,(%rsi)
test   $0x2,%dil
mov    $0x77,%ecx
cmove  %eax,%ecx
mov    %cl,0x1(%rsi)
test   $0x4,%dil
mov    $0x78,%ecx
cmove  %eax,%ecx
test   $0x8,%dil
mov    $0x61,%edx
cmove  %eax,%edx
mov    %cl,0x2(%rsi)
mov    %dl,0x3(%rsi)
test   $0x10,%dil
mov    $0x74,%ecx
cmove  %eax,%ecx
mov    %cl,0x4(%rsi)
movb   $0x0,0x5(%rsi)
ret

LLVM IR (-O0):
define void @int_to_access_type_k(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
%6 = and i32 %5, 1
%7 = icmp ne i32 %6, 0
%8 = zext i1 %7 to i64
%9 = select i1 %7, i32 114, i32 45
%10 = trunc i32 %9 to i8
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 0
store i8 %10, i8* %12
%13 = load i32, i32* %3
%14 = and i32 %13, 2
%15 = icmp ne i32 %14, 0
%16 = zext i1 %15 to i64
%17 = select i1 %15, i32 119, i32 45
%18 = trunc i32 %17 to i8
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8 %18, i8* %20
%21 = load i32, i32* %3
%22 = and i32 %21, 4
%23 = icmp ne i32 %22, 0
%24 = zext i1 %23 to i64
%25 = select i1 %23, i32 120, i32 45
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 2
store i8 %26, i8* %28
%29 = load i32, i32* %3
%30 = and i32 %29, 8
%31 = icmp ne i32 %30, 0
%32 = zext i1 %31 to i64
%33 = select i1 %31, i32 97, i32 45
%34 = trunc i32 %33 to i8
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i64 3
store i8 %34, i8* %36
%37 = load i32, i32* %3
%38 = and i32 %37, 16
%39 = icmp ne i32 %38, 0
%40 = zext i1 %39 to i64
%41 = select i1 %39, i32 116, i32 45
%42 = trunc i32 %41 to i8
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i64 4
store i8 %42, i8* %44
%45 = load i8*, i8** %4
%46 = getelementptr inbounds i8, i8* %45, i64 5
store i8 0, i8* %46
ret void
}

LLVM IR (-O2):
define void @int_to_access_type_k(i32 %0, i8* nocapture writeonly %1) {
%3 = and i32 %0, 1
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i8 45, i8 114
store i8 %5, i8* %1
%6 = and i32 %0, 2
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8 45, i8 119
%9 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %8, i8* %9
%10 = and i32 %0, 4
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i8 45, i8 120
%13 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %12, i8* %13
%14 = and i32 %0, 8
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i8 45, i8 97
%17 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %16, i8* %17
%18 = and i32 %0, 16
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i8 45, i8 116
%21 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %20, i8* %21
%22 = getelementptr inbounds i8, i8* %1, i64 5
store i8 0, i8* %22
ret void
}