#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 */
#define S_IFBLK 134
#define S_IFCHR 133
#define S_IFDIR 132
#define S_IFIFO 131
#define S_IFLNK 130
int S_IFMT;
#define S_IFREG 129
#define S_IFSOCK 128
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_ISVTX;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
int /*<<< orphan*/ printf(char *);
void octtoperm(int octal) {
  switch (octal & S_IFMT) {
  case S_IFBLK:
    printf("b");
    break;
  case S_IFCHR:
    printf("c");
    break;
  case S_IFDIR:
    printf("d");
    break;
  case S_IFIFO:
    printf("p");
    break;
  case S_IFLNK:
    printf("l");
    break;
  case S_IFREG:
    printf("-");
    break;
  case S_IFSOCK:
    printf("S");
    break;
  default:
    printf("?");
    break;
  }
  printf((octal & S_IRUSR) ? "r" : "-");
  printf((octal & S_IWUSR) ? "w" : "-");
  printf((octal & S_IXUSR) ? "x" : "-");
  printf((octal & S_IRGRP) ? "r" : "-");
  printf((octal & S_IWGRP) ? "w" : "-");
  printf((octal & S_IXGRP) ? "x" : "-");
  printf((octal & S_IROTH) ? "r" : "-");
  printf((octal & S_IWOTH) ? "w" : "-");
  if (octal & S_ISVTX && octal & S_IXOTH)
    printf("t");
  else if (octal & S_ISVTX)
    printf("T");
  else if (octal & S_IXOTH)
    printf("x");
  else
    printf("-");
}


x86 assembly (clang, -O0):
<octtoperm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e8b(%rip),%rcx
mov    (%rcx),%ecx
and    %ecx,%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     11c6 <octtoperm+0xb6>
mov    -0x10(%rbp),%rax
lea    0xeba(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <octtoperm+0xc2>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <octtoperm+0xc2>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <octtoperm+0xc2>
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <octtoperm+0xc2>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <octtoperm+0xc2>
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <octtoperm+0xc2>
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <octtoperm+0xc2>
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2dbc(%rip),%rax
and    (%rax),%ecx
lea    0xe41(%rip),%rdi
lea    0xe40(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2dc6(%rip),%rax
and    (%rax),%ecx
lea    0xe1b(%rip),%rdi
lea    0xe1c(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2db0(%rip),%rax
and    (%rax),%ecx
lea    0xdf5(%rip),%rdi
lea    0xdf8(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2d5a(%rip),%rax
and    (%rax),%ecx
lea    0xdcf(%rip),%rdi
lea    0xdce(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2d5c(%rip),%rax
and    (%rax),%ecx
lea    0xda9(%rip),%rdi
lea    0xdaa(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2d26(%rip),%rax
and    (%rax),%ecx
lea    0xd83(%rip),%rdi
lea    0xd86(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2ce0(%rip),%rax
and    (%rax),%ecx
lea    0xd5d(%rip),%rdi
lea    0xd5c(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2ca2(%rip),%rax
and    (%rax),%ecx
lea    0xd37(%rip),%rdi
lea    0xd38(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    0x2cdc(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     133d <octtoperm+0x22d>
mov    -0x4(%rbp),%eax
mov    0x2cbf(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     133d <octtoperm+0x22d>
lea    0xcff(%rip),%rdi
call   1030 <printf@plt>
jmp    139f <octtoperm+0x28f>
mov    -0x4(%rbp),%eax
mov    0x2ca1(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1363 <octtoperm+0x253>
lea    0xcdb(%rip),%rdi
call   1030 <printf@plt>
jmp    139a <octtoperm+0x28a>
mov    -0x4(%rbp),%eax
mov    0x2c73(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1389 <octtoperm+0x279>
lea    0xcb1(%rip),%rdi
call   1030 <printf@plt>
jmp    1395 <octtoperm+0x285>
lea    0xc96(%rip),%rdi
call   1030 <printf@plt>
jmp    139a <octtoperm+0x28a>
jmp    139f <octtoperm+0x28f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<octtoperm>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %edi,%ebx
mov    0x2e7e(%rip),%rax
mov    (%rax),%eax
and    %edi,%eax
add    $0xffffff80,%eax
mov    $0x3f,%edi
cmp    $0x6,%eax
ja     114f <octtoperm+0x2f>
cltq
lea    0xebc(%rip),%rcx
mov    (%rcx,%rax,4),%edi
call   1030 <putchar@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
lea    0xe9a(%rip),%r13
lea    0xe95(%rip),%r14
mov    %r14,%rdi
cmove  %r13,%rdi
call   1040 <printf@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
lea    0xe79(%rip),%r15
mov    %r15,%rdi
cmove  %r13,%rdi
call   1040 <printf@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
lea    0xe5d(%rip),%r12
mov    %r12,%rdi
cmove  %r13,%rdi
call   1040 <printf@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    %r14,%rdi
cmove  %r13,%rdi
call   1040 <printf@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    %r15,%rdi
cmove  %r13,%rdi
call   1040 <printf@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
cmove  %r13,%r12
mov    %r12,%rdi
call   1040 <printf@plt>
mov    0x2d9f(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
cmove  %r13,%r14
mov    %r14,%rdi
call   1040 <printf@plt>
mov    0x2d70(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
cmove  %r13,%r15
mov    %r15,%rdi
call   1040 <printf@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    0x2da6(%rip),%rcx
xor    %edi,%edi
and    (%rcx),%ebx
setne  %dil
mov    $0x2d,%ecx
mov    $0x78,%edx
cmove  %ecx,%edx
shl    $0x5,%edi
or     $0x54,%edi
test   %eax,%eax
cmove  %edx,%edi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@S_IFMT = global i32 0
@.str = [2 x i8] c"b\00"
@.str.1 = [2 x i8] c"c\00"
@.str.2 = [2 x i8] c"d\00"
@.str.3 = [2 x i8] c"p\00"
@.str.4 = [2 x i8] c"l\00"
@.str.5 = [2 x i8] c"-\00"
@.str.6 = [2 x i8] c"S\00"
@.str.7 = [2 x i8] c"?\00"
@S_IRUSR = global i32 0
@.str.8 = [2 x i8] c"r\00"
@S_IWUSR = global i32 0
@.str.9 = [2 x i8] c"w\00"
@S_IXUSR = global i32 0
@.str.10 = [2 x i8] c"x\00"
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_ISVTX = global i32 0
@S_IXOTH = global i32 0
@.str.11 = [2 x i8] c"t\00"
@.str.12 = [2 x i8] c"T\00"
define void @octtoperm(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @S_IFMT
%5 = and i32 %3, %4
switch i32 %5, label %20 [
i32 134, label %6
i32 133, label %8
i32 132, label %10
i32 131, label %12
i32 130, label %14
i32 129, label %16
i32 128, label %18
]
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %22
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %22
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %22
12: ; preds = %1
%13 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %22
14: ; preds = %1
%15 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %22
16: ; preds = %1
%17 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %22
18: ; preds = %1
%19 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %22
20: ; preds = %1
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %22
22: ; preds = %20, %18, %16, %14, %12, %10, %8, %6
%23 = load i32, i32* %2
%24 = load i32, i32* @S_IRUSR
%25 = and i32 %23, %24
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%29 = call i32 @printf(i8* %28)
%30 = load i32, i32* %2
%31 = load i32, i32* @S_IWUSR
%32 = and i32 %30, %31
%33 = icmp ne i32 %32, 0
%34 = zext i1 %33 to i64
%35 = select i1 %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%36 = call i32 @printf(i8* %35)
%37 = load i32, i32* %2
%38 = load i32, i32* @S_IXUSR
%39 = and i32 %37, %38
%40 = icmp ne i32 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%43 = call i32 @printf(i8* %42)
%44 = load i32, i32* %2
%45 = load i32, i32* @S_IRGRP
%46 = and i32 %44, %45
%47 = icmp ne i32 %46, 0
%48 = zext i1 %47 to i64
%49 = select i1 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%50 = call i32 @printf(i8* %49)
%51 = load i32, i32* %2
%52 = load i32, i32* @S_IWGRP
%53 = and i32 %51, %52
%54 = icmp ne i32 %53, 0
%55 = zext i1 %54 to i64
%56 = select i1 %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%57 = call i32 @printf(i8* %56)
%58 = load i32, i32* %2
%59 = load i32, i32* @S_IXGRP
%60 = and i32 %58, %59
%61 = icmp ne i32 %60, 0
%62 = zext i1 %61 to i64
%63 = select i1 %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%64 = call i32 @printf(i8* %63)
%65 = load i32, i32* %2
%66 = load i32, i32* @S_IROTH
%67 = and i32 %65, %66
%68 = icmp ne i32 %67, 0
%69 = zext i1 %68 to i64
%70 = select i1 %68, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%71 = call i32 @printf(i8* %70)
%72 = load i32, i32* %2
%73 = load i32, i32* @S_IWOTH
%74 = and i32 %72, %73
%75 = icmp ne i32 %74, 0
%76 = zext i1 %75 to i64
%77 = select i1 %75, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%78 = call i32 @printf(i8* %77)
%79 = load i32, i32* %2
%80 = load i32, i32* @S_ISVTX
%81 = and i32 %79, %80
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %90
83: ; preds = %22
%84 = load i32, i32* %2
%85 = load i32, i32* @S_IXOTH
%86 = and i32 %84, %85
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %83
%89 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %108
90: ; preds = %83, %22
%91 = load i32, i32* %2
%92 = load i32, i32* @S_ISVTX
%93 = and i32 %91, %92
%94 = icmp ne i32 %93, 0
br i1 %94, label %95, label %97
95: ; preds = %90
%96 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
br label %107
97: ; preds = %90
%98 = load i32, i32* %2
%99 = load i32, i32* @S_IXOTH
%100 = and i32 %98, %99
%101 = icmp ne i32 %100, 0
br i1 %101, label %102, label %104
102: ; preds = %97
%103 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %106
104: ; preds = %97
%105 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %106
106: ; preds = %104, %102
br label %107
107: ; preds = %106, %95
br label %108
108: ; preds = %107, %88
ret void
}

LLVM IR (-O2):
@S_IFMT = global i32 0
@.str.5 = [2 x i8] c"-\00"
@S_IRUSR = global i32 0
@.str.8 = [2 x i8] c"r\00"
@S_IWUSR = global i32 0
@.str.9 = [2 x i8] c"w\00"
@S_IXUSR = global i32 0
@.str.10 = [2 x i8] c"x\00"
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_ISVTX = global i32 0
@S_IXOTH = global i32 0
@switch.table.octtoperm = [7 x i32] [i32 83, i32 45, i32 108, i32 112, i32 100, i32 99, i32 98]
define void @octtoperm(i32 %0) {
%2 = load i32, i32* @S_IFMT
%3 = and i32 %2, %0
%4 = add i32 %3, -128
%5 = icmp ult i32 %4, 7
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = sext i32 %4 to i64
%8 = getelementptr inbounds [7 x i32], [7 x i32]* @switch.table.octtoperm, i64 0, i64 %7
%9 = load i32, i32* %8
br label %10
10: ; preds = %1, %6
%11 = phi i32 [ %9, %6 ], [ 63, %1 ]
%12 = tail call i32 @putchar(i32 %11)
%13 = load i32, i32* @S_IRUSR
%14 = and i32 %13, %0
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0)
%17 = tail call i32 @printf(i8* dereferenceable(1) %16)
%18 = load i32, i32* @S_IWUSR
%19 = and i32 %18, %0
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0)
%22 = tail call i32 @printf(i8* dereferenceable(1) %21)
%23 = load i32, i32* @S_IXUSR
%24 = and i32 %23, %0
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0)
%27 = tail call i32 @printf(i8* dereferenceable(1) %26)
%28 = load i32, i32* @S_IRGRP
%29 = and i32 %28, %0
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0)
%32 = tail call i32 @printf(i8* dereferenceable(1) %31)
%33 = load i32, i32* @S_IWGRP
%34 = and i32 %33, %0
%35 = icmp eq i32 %34, 0
%36 = select i1 %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0)
%37 = tail call i32 @printf(i8* dereferenceable(1) %36)
%38 = load i32, i32* @S_IXGRP
%39 = and i32 %38, %0
%40 = icmp eq i32 %39, 0
%41 = select i1 %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0)
%42 = tail call i32 @printf(i8* dereferenceable(1) %41)
%43 = load i32, i32* @S_IROTH
%44 = and i32 %43, %0
%45 = icmp eq i32 %44, 0
%46 = select i1 %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0)
%47 = tail call i32 @printf(i8* dereferenceable(1) %46)
%48 = load i32, i32* @S_IWOTH
%49 = and i32 %48, %0
%50 = icmp eq i32 %49, 0
%51 = select i1 %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0)
%52 = tail call i32 @printf(i8* dereferenceable(1) %51)
%53 = load i32, i32* @S_ISVTX
%54 = and i32 %53, %0
%55 = icmp eq i32 %54, 0
%56 = load i32, i32* @S_IXOTH
%57 = and i32 %56, %0
%58 = icmp eq i32 %57, 0
%59 = select i1 %58, i32 84, i32 116
%60 = select i1 %58, i32 45, i32 120
%61 = select i1 %55, i32 %60, i32 %59
%62 = tail call i32 @putchar(i32 %61)
ret void
}