#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 */
typedef int mode_t;

/* Variables and functions */
char ftypelet(int);
int /*<<< orphan*/ setst(int, char *);
void mode_string(mode_t mode, char *str) {
  str[0] = ftypelet(mode);
  str[1] = mode & 0000400 ? 'r' : '-';
  str[2] = mode & 0000200 ? 'w' : '-';
  str[3] = mode & 0000100 ? 'x' : '-';
  str[4] = mode & 0000040 ? 'r' : '-';
  str[5] = mode & 0000020 ? 'w' : '-';
  str[6] = mode & 0000010 ? 'x' : '-';
  str[7] = mode & 0000004 ? 'r' : '-';
  str[8] = mode & 0000002 ? 'w' : '-';
  str[9] = mode & 0000001 ? 'x' : '-';
  setst(mode, str);
}


x86 assembly (clang, -O0):
<mode_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <ftypelet@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x4(%rbp),%edx
and    $0x100,%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x4(%rbp),%edx
and    $0x80,%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x4(%rbp),%edx
and    $0x40,%edx
mov    $0x2d,%eax
mov    $0x78,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x4(%rbp),%edx
and    $0x20,%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x4(%rbp),%edx
and    $0x10,%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x4(%rbp),%edx
and    $0x8,%edx
mov    $0x2d,%eax
mov    $0x78,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x4(%rbp),%edx
and    $0x4,%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x7(%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,0x8(%rax)
mov    -0x4(%rbp),%edx
and    $0x1,%edx
mov    $0x2d,%eax
mov    $0x78,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x9(%rax)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <setst@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mode_string>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
call   1040 <ftypelet@plt>
mov    %al,(%rbx)
test   $0x100,%ebp
mov    $0x2d,%eax
mov    $0x72,%r8d
mov    $0x72,%edx
cmove  %eax,%edx
mov    %dl,0x1(%rbx)
movd   %ebp,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0xea4(%rip),%xmm1
pand   %xmm0,%xmm1
pand   0xea8(%rip),%xmm0
pxor   %xmm2,%xmm2
pcmpeqd %xmm2,%xmm0
pcmpeqd %xmm2,%xmm1
packssdw %xmm0,%xmm1
packsswb %xmm1,%xmm1
pmovmskb %xmm1,%edx
test   $0x80,%dl
mov    $0x77,%esi
mov    $0x77,%edi
cmovne %eax,%edi
mov    %dil,0x2(%rbx)
test   $0x40,%dl
mov    $0x78,%edi
cmovne %eax,%edi
mov    %dil,0x3(%rbx)
test   $0x20,%dl
mov    $0x72,%edi
cmovne %eax,%edi
mov    $0x78,%ecx
mov    %dil,0x4(%rbx)
test   $0x10,%dl
mov    $0x77,%edi
cmovne %eax,%edi
mov    %dil,0x5(%rbx)
test   $0x8,%dl
mov    $0x78,%edi
cmovne %eax,%edi
mov    %dil,0x6(%rbx)
test   $0x4,%dl
cmovne %eax,%r8d
mov    %r8b,0x7(%rbx)
test   $0x2,%dl
cmovne %eax,%esi
mov    %sil,0x8(%rbx)
test   $0x1,%dl
cmovne %eax,%ecx
mov    %cl,0x9(%rbx)
mov    %ebp,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <setst@plt>

LLVM IR (-O0):
define void @mode_string(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 = call signext i8 @ftypelet(i32 %5)
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 0
store i8 %6, i8* %8
%9 = load i32, i32* %3
%10 = and i32 %9, 256
%11 = icmp ne i32 %10, 0
%12 = zext i1 %11 to i64
%13 = select i1 %11, i32 114, i32 45
%14 = trunc i32 %13 to i8
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 1
store i8 %14, i8* %16
%17 = load i32, i32* %3
%18 = and i32 %17, 128
%19 = icmp ne i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i32 119, i32 45
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 2
store i8 %22, i8* %24
%25 = load i32, i32* %3
%26 = and i32 %25, 64
%27 = icmp ne i32 %26, 0
%28 = zext i1 %27 to i64
%29 = select i1 %27, i32 120, i32 45
%30 = trunc i32 %29 to i8
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 3
store i8 %30, i8* %32
%33 = load i32, i32* %3
%34 = and i32 %33, 32
%35 = icmp ne i32 %34, 0
%36 = zext i1 %35 to i64
%37 = select i1 %35, i32 114, i32 45
%38 = trunc i32 %37 to i8
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i64 4
store i8 %38, i8* %40
%41 = load i32, i32* %3
%42 = and i32 %41, 16
%43 = icmp ne i32 %42, 0
%44 = zext i1 %43 to i64
%45 = select i1 %43, i32 119, i32 45
%46 = trunc i32 %45 to i8
%47 = load i8*, i8** %4
%48 = getelementptr inbounds i8, i8* %47, i64 5
store i8 %46, i8* %48
%49 = load i32, i32* %3
%50 = and i32 %49, 8
%51 = icmp ne i32 %50, 0
%52 = zext i1 %51 to i64
%53 = select i1 %51, i32 120, i32 45
%54 = trunc i32 %53 to i8
%55 = load i8*, i8** %4
%56 = getelementptr inbounds i8, i8* %55, i64 6
store i8 %54, i8* %56
%57 = load i32, i32* %3
%58 = and i32 %57, 4
%59 = icmp ne i32 %58, 0
%60 = zext i1 %59 to i64
%61 = select i1 %59, i32 114, i32 45
%62 = trunc i32 %61 to i8
%63 = load i8*, i8** %4
%64 = getelementptr inbounds i8, i8* %63, i64 7
store i8 %62, i8* %64
%65 = load i32, i32* %3
%66 = and i32 %65, 2
%67 = icmp ne i32 %66, 0
%68 = zext i1 %67 to i64
%69 = select i1 %67, i32 119, i32 45
%70 = trunc i32 %69 to i8
%71 = load i8*, i8** %4
%72 = getelementptr inbounds i8, i8* %71, i64 8
store i8 %70, i8* %72
%73 = load i32, i32* %3
%74 = and i32 %73, 1
%75 = icmp ne i32 %74, 0
%76 = zext i1 %75 to i64
%77 = select i1 %75, i32 120, i32 45
%78 = trunc i32 %77 to i8
%79 = load i8*, i8** %4
%80 = getelementptr inbounds i8, i8* %79, i64 9
store i8 %78, i8* %80
%81 = load i32, i32* %3
%82 = load i8*, i8** %4
%83 = call i32 @setst(i32 %81, i8* %82)
ret void
}

LLVM IR (-O2):
define void @mode_string(i32 %0, i8* %1) {
%3 = tail call signext i8 @ftypelet(i32 %0)
store i8 %3, i8* %1
%4 = and i32 %0, 256
%5 = icmp eq i32 %4, 0
%6 = select i1 %5, i8 45, i8 114
%7 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %6, i8* %7
%8 = insertelement <8 x i32> poison, i32 %0, i64 0
%9 = shufflevector <8 x i32> %8, <8 x i32> poison, <8 x i32> zeroinitializer
%10 = and <8 x i32> %9, <i32 1, i32 2, i32 4, i32 8, i32 16, i32 32, i32 64, i32 128>
%11 = icmp eq <8 x i32> %10, zeroinitializer
%12 = extractelement <8 x i1> %11, i64 7
%13 = select i1 %12, i8 45, i8 119
%14 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %13, i8* %14
%15 = extractelement <8 x i1> %11, i64 6
%16 = select i1 %15, i8 45, i8 120
%17 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %16, i8* %17
%18 = extractelement <8 x i1> %11, i64 5
%19 = select i1 %18, i8 45, i8 114
%20 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %19, i8* %20
%21 = extractelement <8 x i1> %11, i64 4
%22 = select i1 %21, i8 45, i8 119
%23 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %22, i8* %23
%24 = extractelement <8 x i1> %11, i64 3
%25 = select i1 %24, i8 45, i8 120
%26 = getelementptr inbounds i8, i8* %1, i64 6
store i8 %25, i8* %26
%27 = extractelement <8 x i1> %11, i64 2
%28 = select i1 %27, i8 45, i8 114
%29 = getelementptr inbounds i8, i8* %1, i64 7
store i8 %28, i8* %29
%30 = extractelement <8 x i1> %11, i64 1
%31 = select i1 %30, i8 45, i8 119
%32 = getelementptr inbounds i8, i8* %1, i64 8
store i8 %31, i8* %32
%33 = extractelement <8 x i1> %11, i64 0
%34 = select i1 %33, i8 45, i8 120
%35 = getelementptr inbounds i8, i8* %1, i64 9
store i8 %34, i8* %35
%36 = tail call i32 @setst(i32 %0, i8* %1)
ret void
}