#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 */
scalar_t__ S_ISBLK(int);
scalar_t__ S_ISCHR(int);
scalar_t__ S_ISDIR(int);
scalar_t__ S_ISFIFO(int);
scalar_t__ S_ISLNK(int);
scalar_t__ S_ISREG(int);
scalar_t__ S_ISSOCK(int);
int /*<<< orphan*/ strcpy(char *, char *);
char *get_mode_string(mode_t mode) {
  int m;
  static char mode_string[16];
  char *buff = mode_string;
  char *perm[] = {"---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"};
  if (S_ISREG(mode)) {
    *(buff++) = '-';
  } else if (S_ISDIR(mode)) {
    *(buff++) = 'd';
  } else if (S_ISCHR(mode)) {
    *(buff++) = 'c';
  } else if (S_ISBLK(mode)) {
    *(buff++) = 'b';
  } else if (S_ISFIFO(mode)) {
    *(buff++) = 'p';
  } else if (S_ISLNK(mode)) {
    *(buff++) = 'l';
  } else if (S_ISSOCK(mode)) {
    *(buff++) = 's';
  }
  m = (mode >> 6) & 7;
  strcpy(buff, perm[m]);
  buff += 3;
  m = (mode >> 3) & 7;
  strcpy(buff, perm[m]);
  buff += 3;
  m = (mode >> 0) & 7;
  strcpy(buff, perm[m]);
  buff += 3;
  *buff = 0;
  return (mode_string);
}


x86 assembly (clang, -O0):
<get_mode_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
lea    0x2ede(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2c2f(%rip),%rsi
mov    $0x40,%edx
call   1080 <memcpy@plt>
mov    -0x4(%rbp),%edi
call   1090 <S_ISREG@plt>
cmp    $0x0,%rax
je     11e4 <get_mode_string+0x54>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x2d,(%rax)
jmp    12f3 <get_mode_string+0x163>
mov    -0x4(%rbp),%edi
call   1070 <S_ISDIR@plt>
cmp    $0x0,%rax
je     120d <get_mode_string+0x7d>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x64,(%rax)
jmp    12ee <get_mode_string+0x15e>
mov    -0x4(%rbp),%edi
call   10a0 <S_ISCHR@plt>
cmp    $0x0,%rax
je     1236 <get_mode_string+0xa6>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x63,(%rax)
jmp    12e9 <get_mode_string+0x159>
mov    -0x4(%rbp),%edi
call   10b0 <S_ISBLK@plt>
cmp    $0x0,%rax
je     125f <get_mode_string+0xcf>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x62,(%rax)
jmp    12e4 <get_mode_string+0x154>
mov    -0x4(%rbp),%edi
call   1050 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     1288 <get_mode_string+0xf8>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x70,(%rax)
jmp    12df <get_mode_string+0x14f>
mov    -0x4(%rbp),%edi
call   1040 <S_ISLNK@plt>
cmp    $0x0,%rax
je     12b1 <get_mode_string+0x121>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x6c,(%rax)
jmp    12da <get_mode_string+0x14a>
mov    -0x4(%rbp),%edi
call   1060 <S_ISSOCK@plt>
cmp    $0x0,%rax
je     12d5 <get_mode_string+0x145>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x73,(%rax)
jmp    12da <get_mode_string+0x14a>
jmp    12df <get_mode_string+0x14f>
jmp    12e4 <get_mode_string+0x154>
jmp    12e9 <get_mode_string+0x159>
jmp    12ee <get_mode_string+0x15e>
jmp    12f3 <get_mode_string+0x163>
mov    -0x4(%rbp),%eax
sar    $0x6,%eax
and    $0x7,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x8(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x3,%eax
and    $0x7,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x8(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x0,%eax
and    $0x7,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x8(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2d01(%rip),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mode_string>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%r14d
call   1080 <S_ISREG@plt>
mov    $0x2d,%cl
test   %rax,%rax
jne    11ee <get_mode_string+0x6e>
mov    %r14d,%edi
call   1070 <S_ISDIR@plt>
mov    $0x64,%cl
test   %rax,%rax
jne    11ee <get_mode_string+0x6e>
mov    %r14d,%edi
call   1090 <S_ISCHR@plt>
mov    $0x63,%cl
test   %rax,%rax
jne    11ee <get_mode_string+0x6e>
mov    %r14d,%edi
call   10a0 <S_ISBLK@plt>
mov    $0x62,%cl
test   %rax,%rax
jne    11ee <get_mode_string+0x6e>
mov    %r14d,%edi
call   1050 <S_ISFIFO@plt>
mov    $0x70,%cl
test   %rax,%rax
jne    11ee <get_mode_string+0x6e>
mov    %r14d,%edi
call   1040 <S_ISLNK@plt>
mov    $0x6c,%cl
test   %rax,%rax
jne    11ee <get_mode_string+0x6e>
mov    %r14d,%edi
call   1060 <S_ISSOCK@plt>
mov    $0x73,%cl
test   %rax,%rax
je     124f <get_mode_string+0xcf>
mov    %cl,0x2e7c(%rip)
lea    0x2e76(%rip),%rbx
mov    %r14d,%eax
shr    $0x6,%eax
and    $0x7,%eax
lea    0x2bd5(%rip),%r15
mov    (%r15,%rax,8),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0x3(%rbx),%rdi
mov    %r14d,%eax
shr    $0x3,%eax
and    $0x7,%eax
mov    (%r15,%rax,8),%rsi
call   1030 <strcpy@plt>
lea    0x6(%rbx),%rdi
and    $0x7,%r14d
mov    (%r15,%r14,8),%rsi
call   1030 <strcpy@plt>
movb   $0x0,0x9(%rbx)
lea    0x2e27(%rip),%rax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0x2e1a(%rip),%rbx
jmp    11fb <get_mode_string+0x7b>

LLVM IR (-O0):
@get_mode_string.mode_string = internal global [16 x i8] zeroinitializer
@.str = [4 x i8] c"---\00"
@.str.1 = [4 x i8] c"--x\00"
@.str.2 = [4 x i8] c"-w-\00"
@.str.3 = [4 x i8] c"-wx\00"
@.str.4 = [4 x i8] c"r--\00"
@.str.5 = [4 x i8] c"r-x\00"
@.str.6 = [4 x i8] c"rw-\00"
@.str.7 = [4 x i8] c"rwx\00"
@__const.get_mode_string.perm = [8 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0)]
define i8* @get_mode_string(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [8 x i8*]
store i32 %0, i32* %2
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @get_mode_string.mode_string, i64 0, i64 0), i8** %4
%6 = bitcast [8 x i8*]* %5 to i8*
%7 = load i32, i32* %2
%8 = call i64 @S_ISREG(i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %4
store i8 45, i8* %11
br label %61
13: ; preds = %1
%14 = load i32, i32* %2
%15 = call i64 @S_ISDIR(i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %4
store i8 100, i8* %18
br label %60
20: ; preds = %13
%21 = load i32, i32* %2
%22 = call i64 @S_ISCHR(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %4
store i8 99, i8* %25
br label %59
27: ; preds = %20
%28 = load i32, i32* %2
%29 = call i64 @S_ISBLK(i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %4
store i8 98, i8* %32
br label %58
34: ; preds = %27
%35 = load i32, i32* %2
%36 = call i64 @S_ISFIFO(i32 %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %4
store i8 112, i8* %39
br label %57
41: ; preds = %34
%42 = load i32, i32* %2
%43 = call i64 @S_ISLNK(i32 %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %4
store i8 108, i8* %46
br label %56
48: ; preds = %41
%49 = load i32, i32* %2
%50 = call i64 @S_ISSOCK(i32 %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load i8*, i8** %4
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %4
store i8 115, i8* %53
br label %55
55: ; preds = %52, %48
br label %56
56: ; preds = %55, %45
br label %57
57: ; preds = %56, %38
br label %58
58: ; preds = %57, %31
br label %59
59: ; preds = %58, %24
br label %60
60: ; preds = %59, %17
br label %61
61: ; preds = %60, %10
%62 = load i32, i32* %2
%63 = ashr i32 %62, 6
%64 = and i32 %63, 7
store i32 %64, i32* %3
%65 = load i8*, i8** %4
%66 = load i32, i32* %3
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [8 x i8*], [8 x i8*]* %5, i64 0, i64 %67
%69 = load i8*, i8** %68
%70 = call i32 @strcpy(i8* %65, i8* %69)
%71 = load i8*, i8** %4
%72 = getelementptr inbounds i8, i8* %71, i64 3
store i8* %72, i8** %4
%73 = load i32, i32* %2
%74 = ashr i32 %73, 3
%75 = and i32 %74, 7
store i32 %75, i32* %3
%76 = load i8*, i8** %4
%77 = load i32, i32* %3
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [8 x i8*], [8 x i8*]* %5, i64 0, i64 %78
%80 = load i8*, i8** %79
%81 = call i32 @strcpy(i8* %76, i8* %80)
%82 = load i8*, i8** %4
%83 = getelementptr inbounds i8, i8* %82, i64 3
store i8* %83, i8** %4
%84 = load i32, i32* %2
%85 = ashr i32 %84, 0
%86 = and i32 %85, 7
store i32 %86, i32* %3
%87 = load i8*, i8** %4
%88 = load i32, i32* %3
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [8 x i8*], [8 x i8*]* %5, i64 0, i64 %89
%91 = load i8*, i8** %90
%92 = call i32 @strcpy(i8* %87, i8* %91)
%93 = load i8*, i8** %4
%94 = getelementptr inbounds i8, i8* %93, i64 3
store i8* %94, i8** %4
%95 = load i8*, i8** %4
store i8 0, i8* %95
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @get_mode_string.mode_string, i64 0, i64 0)
}

LLVM IR (-O2):
@get_mode_string.mode_string = internal global [16 x i8] zeroinitializer
@.str = [4 x i8] c"---\00"
@.str.1 = [4 x i8] c"--x\00"
@.str.2 = [4 x i8] c"-w-\00"
@.str.3 = [4 x i8] c"-wx\00"
@.str.4 = [4 x i8] c"r--\00"
@.str.5 = [4 x i8] c"r-x\00"
@.str.6 = [4 x i8] c"rw-\00"
@.str.7 = [4 x i8] c"rwx\00"
@__const.get_mode_string.perm = [8 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0)]
define i8* @get_mode_string(i32 %0) {
%2 = tail call i64 @S_ISREG(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %22
4: ; preds = %1
%5 = tail call i64 @S_ISDIR(i32 %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = tail call i64 @S_ISCHR(i32 %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = tail call i64 @S_ISBLK(i32 %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = tail call i64 @S_ISFIFO(i32 %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = tail call i64 @S_ISLNK(i32 %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = tail call i64 @S_ISSOCK(i32 %0)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %19, %16, %13, %10, %7, %4, %1
%23 = phi i8 [ 45, %1 ], [ 100, %4 ], [ 99, %7 ], [ 98, %10 ], [ 112, %13 ], [ 108, %16 ], [ 115, %19 ]
store i8 %23, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @get_mode_string.mode_string, i64 0, i64 0)
br label %24
24: ; preds = %22, %19
%25 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @get_mode_string.mode_string, i64 0, i64 0), %19 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @get_mode_string.mode_string, i64 0, i64 1), %22 ]
%26 = lshr i32 %0, 6
%27 = and i32 %26, 7
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds [8 x i8*], [8 x i8*]* @__const.get_mode_string.perm, i64 0, i64 %28
%30 = load i8*, i8** %29
%31 = tail call i32 @strcpy(i8* %25, i8* %30)
%32 = getelementptr inbounds i8, i8* %25, i64 3
%33 = lshr i32 %0, 3
%34 = and i32 %33, 7
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds [8 x i8*], [8 x i8*]* @__const.get_mode_string.perm, i64 0, i64 %35
%37 = load i8*, i8** %36
%38 = tail call i32 @strcpy(i8* %32, i8* %37)
%39 = getelementptr inbounds i8, i8* %25, i64 6
%40 = and i32 %0, 7
%41 = zext i32 %40 to i64
%42 = getelementptr inbounds [8 x i8*], [8 x i8*]* @__const.get_mode_string.perm, i64 0, i64 %41
%43 = load i8*, i8** %42
%44 = tail call i32 @strcpy(i8* %39, i8* %43)
%45 = getelementptr inbounds i8, i8* %25, i64 9
store i8 0, i8* %45
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @get_mode_string.mode_string, i64 0, i64 0)
}