#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 */
struct stat {
  int st_mode;
};
typedef int mode_t;

/* Variables and functions */
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
scalar_t__ S_ISBLK(int);
scalar_t__ S_ISCHR(int);
scalar_t__ S_ISFIFO(int);
int S_ISGID;
scalar_t__ S_ISLNK(int);
scalar_t__ S_ISSOCK(int);
int S_ISUID;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
int /*<<< orphan*/ snprintf(char *, size_t, char *, char, char, char, char,
                            char, char, char, char, char, char);
void get_perms(struct stat *st, char *buf, size_t len) {
  mode_t m = st->st_mode;
  snprintf(buf, len, "[%c%c%c%c%c%c%c%c%c%c] ",
           S_ISCHR(m)    ? 'c'
           : S_ISBLK(m)  ? 'b'
           : S_ISFIFO(m) ? 'p'
           : S_ISLNK(m)  ? 'l'
           : S_ISSOCK(m) ? 's'
                         : '-',
           (m & S_IRUSR) ? 'r' : '-', (m & S_IWUSR) ? 'w' : '-',
           (m & S_ISUID)   ? 's'
           : (m & S_IXUSR) ? 'x'
                           : '-',
           (m & S_IRGRP) ? 'r' : '-', (m & S_IWGRP) ? 'w' : '-',
           (m & S_ISGID)   ? 's'
           : (m & S_IXGRP) ? 'x'
                           : '-',
           (m & S_IROTH) ? 'r' : '-', (m & S_IWOTH) ? 'w' : '-',
           (m & S_IXOTH) ? 'x' : '-');
}


x86 assembly (clang, -O0):
<get_perms>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x44(%rbp),%edi
call   1070 <S_ISCHR@plt>
cmp    $0x0,%rax
je     11b8 <get_perms+0x58>
mov    $0x63,%eax
mov    %eax,-0x5c(%rbp)
jmp    1246 <get_perms+0xe6>
mov    -0x44(%rbp),%edi
call   1080 <S_ISBLK@plt>
cmp    $0x0,%rax
je     11d7 <get_perms+0x77>
mov    $0x62,%eax
mov    %eax,-0x60(%rbp)
jmp    1240 <get_perms+0xe0>
mov    -0x44(%rbp),%edi
call   1040 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     11f6 <get_perms+0x96>
mov    $0x70,%eax
mov    %eax,-0x64(%rbp)
jmp    123a <get_perms+0xda>
mov    -0x44(%rbp),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     1215 <get_perms+0xb5>
mov    $0x6c,%eax
mov    %eax,-0x68(%rbp)
jmp    1234 <get_perms+0xd4>
mov    -0x44(%rbp),%edi
call   1050 <S_ISSOCK@plt>
mov    %rax,%rdx
mov    $0x2d,%eax
mov    $0x73,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    %al,-0x6b(%rbp)
mov    -0x44(%rbp),%edx
mov    0x2d42(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x6a(%rbp)
mov    -0x44(%rbp),%edx
mov    0x2d53(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x69(%rbp)
mov    -0x44(%rbp),%eax
mov    0x2d44(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12ac <get_perms+0x14c>
mov    $0x73,%eax
mov    %eax,-0x70(%rbp)
jmp    12cb <get_perms+0x16b>
mov    -0x44(%rbp),%edx
mov    0x2d2a(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x78,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%eax
mov    %al,-0x73(%rbp)
mov    -0x44(%rbp),%edx
mov    0x2ccd(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x72(%rbp)
mov    -0x44(%rbp),%edx
mov    0x2cd6(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x71(%rbp)
mov    -0x44(%rbp),%eax
mov    0x2c97(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1331 <get_perms+0x1d1>
mov    $0x73,%eax
mov    %eax,-0x78(%rbp)
jmp    1350 <get_perms+0x1f0>
mov    -0x44(%rbp),%edx
mov    0x2c85(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x78,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x78(%rbp)
mov    -0x71(%rbp),%r14b
mov    -0x72(%rbp),%r15b
mov    -0x73(%rbp),%r12b
mov    -0x69(%rbp),%r9b
mov    -0x6a(%rbp),%r8b
mov    -0x6b(%rbp),%cl
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rdi
mov    -0x78(%rbp),%eax
mov    %al,%bl
mov    -0x44(%rbp),%r10d
mov    0x2c21(%rip),%rax
and    (%rax),%r10d
mov    $0x2d,%eax
mov    $0x72,%edx
cmp    $0x0,%r10d
cmovne %edx,%eax
mov    %al,%r11b
mov    -0x44(%rbp),%r10d
mov    0x2be7(%rip),%rax
and    (%rax),%r10d
mov    $0x2d,%eax
mov    $0x77,%edx
cmp    $0x0,%r10d
cmovne %edx,%eax
mov    %al,%r10b
mov    -0x44(%rbp),%r13d
mov    0x2c25(%rip),%rax
and    (%rax),%r13d
mov    $0x2d,%eax
mov    $0x78,%edx
cmp    $0x0,%r13d
cmovne %edx,%eax
lea    0xc22(%rip),%rdx
movsbl %cl,%ecx
movsbl %r8b,%r8d
movsbl %r9b,%r9d
movsbl %r12b,%r12d
mov    %r12d,(%rsp)
movsbl %r15b,%r15d
mov    %r15d,0x8(%rsp)
movsbl %r14b,%r14d
mov    %r14d,0x10(%rsp)
movsbl %bl,%ebx
mov    %ebx,0x18(%rsp)
movsbl %r11b,%r11d
mov    %r11d,0x20(%rsp)
movsbl %r10b,%r10d
mov    %r10d,0x28(%rsp)
movsbl %al,%eax
mov    %eax,0x30(%rsp)
call   1060 <snprintf@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_perms>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %rsi,0x8(%rsp)
mov    (%rdi),%ebp
mov    %ebp,%edi
call   1070 <S_ISCHR@plt>
mov    $0x63,%cl
test   %rax,%rax
jne    11c9 <get_perms+0x69>
mov    %ebp,%edi
call   1080 <S_ISBLK@plt>
mov    $0x62,%cl
test   %rax,%rax
jne    11c9 <get_perms+0x69>
mov    %ebp,%edi
call   1040 <S_ISFIFO@plt>
mov    $0x70,%cl
test   %rax,%rax
jne    11c9 <get_perms+0x69>
mov    %ebp,%edi
call   1030 <S_ISLNK@plt>
mov    $0x6c,%cl
test   %rax,%rax
jne    11c9 <get_perms+0x69>
mov    %ebp,%edi
call   1050 <S_ISSOCK@plt>
test   %rax,%rax
mov    $0x2d,%eax
mov    $0x73,%ecx
cmove  %eax,%ecx
mov    %ecx,0x4(%rsp)
mov    0x2dc4(%rip),%r8
mov    0x2ded(%rip),%r9
mov    0x2df6(%rip),%rdx
mov    (%rdx),%edi
and    %ebp,%edi
mov    0x2df3(%rip),%rdx
mov    (%rdx),%edx
and    %ebp,%edx
mov    $0x2d,%r14d
mov    $0x78,%r11d
cmove  %r14d,%r11d
test   %edi,%edi
mov    $0x73,%edi
cmovne %edi,%r11d
mov    0x2d95(%rip),%rax
mov    0x2db6(%rip),%rsi
mov    0x2d8f(%rip),%rbx
mov    (%rbx),%ecx
and    %ebp,%ecx
mov    0x2d94(%rip),%rbx
mov    (%rbx),%ebx
and    %ebp,%ebx
mov    $0x78,%r15d
cmove  %r14d,%r15d
test   %ecx,%ecx
cmovne %edi,%r15d
mov    (%rsi),%ecx
and    %ebp,%ecx
mov    (%rax),%eax
and    %ebp,%eax
mov    (%r9),%r13d
and    %ebp,%r13d
mov    (%r8),%edi
and    %ebp,%edi
mov    0x2d46(%rip),%rdx
mov    (%rdx),%edx
and    %ebp,%edx
mov    0x2d23(%rip),%rbx
mov    (%rbx),%ebx
and    %ebp,%ebx
mov    0x2d78(%rip),%rsi
and    (%rsi),%ebp
test   %edi,%edi
mov    $0x72,%r8d
cmove  %r14d,%r8d
test   %eax,%eax
mov    $0x72,%r10d
cmove  %r14d,%r10d
test   %ecx,%ecx
mov    $0x77,%eax
cmove  %r14d,%eax
mov    $0x72,%r12d
test   %edx,%edx
cmove  %r14d,%r12d
test   %ebx,%ebx
mov    $0x77,%ebx
cmove  %r14d,%ebx
mov    $0x77,%r9d
test   %ebp,%ebp
mov    $0x78,%ebp
cmove  %r14d,%ebp
sub    $0x8,%rsp
test   %r13d,%r13d
cmove  %r14d,%r9d
movzbl 0xc(%rsp),%ecx
lea    0xd2c(%rip),%rdx
mov    0x10(%rsp),%rdi
mov    0x18(%rsp),%rsi
push   %rbp
push   %rbx
push   %r12
push   %r15
push   %rax
push   %r10
push   %r11
call   1060 <snprintf@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [24 x i8] c"[%c%c%c%c%c%c%c%c%c%c] \00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_ISUID = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_ISGID = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
define void @get_perms(%struct.stat* %0, i8* %1, i64 %2) {
%4 = alloca %struct.stat*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store %struct.stat* %0, %struct.stat** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load %struct.stat*, %struct.stat** %4
%9 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%10 = load i32, i32* %9
store i32 %10, i32* %7
%11 = load i8*, i8** %5
%12 = load i64, i64* %6
%13 = load i32, i32* %7
%14 = call i64 @S_ISCHR(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %3
br label %44
17: ; preds = %3
%18 = load i32, i32* %7
%19 = call i64 @S_ISBLK(i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
br label %42
22: ; preds = %17
%23 = load i32, i32* %7
%24 = call i64 @S_ISFIFO(i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
br label %40
27: ; preds = %22
%28 = load i32, i32* %7
%29 = call i64 @S_ISLNK(i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
br label %38
32: ; preds = %27
%33 = load i32, i32* %7
%34 = call i64 @S_ISSOCK(i32 %33)
%35 = icmp ne i64 %34, 0
%36 = zext i1 %35 to i64
%37 = select i1 %35, i32 115, i32 45
br label %38
38: ; preds = %32, %31
%39 = phi i32 [ 108, %31 ], [ %37, %32 ]
br label %40
40: ; preds = %38, %26
%41 = phi i32 [ 112, %26 ], [ %39, %38 ]
br label %42
42: ; preds = %40, %21
%43 = phi i32 [ 98, %21 ], [ %41, %40 ]
br label %44
44: ; preds = %42, %16
%45 = phi i32 [ 99, %16 ], [ %43, %42 ]
%46 = trunc i32 %45 to i8
%47 = load i32, i32* %7
%48 = load i32, i32* @S_IRUSR
%49 = and i32 %47, %48
%50 = icmp ne i32 %49, 0
%51 = zext i1 %50 to i64
%52 = select i1 %50, i32 114, i32 45
%53 = trunc i32 %52 to i8
%54 = load i32, i32* %7
%55 = load i32, i32* @S_IWUSR
%56 = and i32 %54, %55
%57 = icmp ne i32 %56, 0
%58 = zext i1 %57 to i64
%59 = select i1 %57, i32 119, i32 45
%60 = trunc i32 %59 to i8
%61 = load i32, i32* %7
%62 = load i32, i32* @S_ISUID
%63 = and i32 %61, %62
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %44
br label %73
66: ; preds = %44
%67 = load i32, i32* %7
%68 = load i32, i32* @S_IXUSR
%69 = and i32 %67, %68
%70 = icmp ne i32 %69, 0
%71 = zext i1 %70 to i64
%72 = select i1 %70, i32 120, i32 45
br label %73
73: ; preds = %66, %65
%74 = phi i32 [ 115, %65 ], [ %72, %66 ]
%75 = trunc i32 %74 to i8
%76 = load i32, i32* %7
%77 = load i32, i32* @S_IRGRP
%78 = and i32 %76, %77
%79 = icmp ne i32 %78, 0
%80 = zext i1 %79 to i64
%81 = select i1 %79, i32 114, i32 45
%82 = trunc i32 %81 to i8
%83 = load i32, i32* %7
%84 = load i32, i32* @S_IWGRP
%85 = and i32 %83, %84
%86 = icmp ne i32 %85, 0
%87 = zext i1 %86 to i64
%88 = select i1 %86, i32 119, i32 45
%89 = trunc i32 %88 to i8
%90 = load i32, i32* %7
%91 = load i32, i32* @S_ISGID
%92 = and i32 %90, %91
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %95
94: ; preds = %73
br label %102
95: ; preds = %73
%96 = load i32, i32* %7
%97 = load i32, i32* @S_IXGRP
%98 = and i32 %96, %97
%99 = icmp ne i32 %98, 0
%100 = zext i1 %99 to i64
%101 = select i1 %99, i32 120, i32 45
br label %102
102: ; preds = %95, %94
%103 = phi i32 [ 115, %94 ], [ %101, %95 ]
%104 = trunc i32 %103 to i8
%105 = load i32, i32* %7
%106 = load i32, i32* @S_IROTH
%107 = and i32 %105, %106
%108 = icmp ne i32 %107, 0
%109 = zext i1 %108 to i64
%110 = select i1 %108, i32 114, i32 45
%111 = trunc i32 %110 to i8
%112 = load i32, i32* %7
%113 = load i32, i32* @S_IWOTH
%114 = and i32 %112, %113
%115 = icmp ne i32 %114, 0
%116 = zext i1 %115 to i64
%117 = select i1 %115, i32 119, i32 45
%118 = trunc i32 %117 to i8
%119 = load i32, i32* %7
%120 = load i32, i32* @S_IXOTH
%121 = and i32 %119, %120
%122 = icmp ne i32 %121, 0
%123 = zext i1 %122 to i64
%124 = select i1 %122, i32 120, i32 45
%125 = trunc i32 %124 to i8
%126 = call i32 @snprintf(i8* %11, i64 %12, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8 signext %46, i8 signext %53, i8 signext %60, i8 signext %75, i8 signext %82, i8 signext %89, i8 signext %104, i8 signext %111, i8 signext %118, i8 signext %125)
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [24 x i8] c"[%c%c%c%c%c%c%c%c%c%c] \00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_ISUID = global i32 0
@S_IXUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_ISGID = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
define void @get_perms(%struct.stat* nocapture %0, i8* %1, i64 %2) {
%4 = getelementptr inbounds %struct.stat, %struct.stat* %0, i64 0, i32 0
%5 = load i32, i32* %4
%6 = tail call i64 @S_ISCHR(i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %3
%9 = tail call i64 @S_ISBLK(i32 %5)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = tail call i64 @S_ISFIFO(i32 %5)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = tail call i64 @S_ISLNK(i32 %5)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = tail call i64 @S_ISSOCK(i32 %5)
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i8 45, i8 115
br label %21
21: ; preds = %8, %17, %14, %11, %3
%22 = phi i8 [ 99, %3 ], [ 98, %8 ], [ 112, %11 ], [ %20, %17 ], [ 108, %14 ]
%23 = load i32, i32* @S_IRUSR
%24 = load i32, i32* @S_IWUSR
%25 = load i32, i32* @S_ISUID
%26 = and i32 %25, %5
%27 = icmp eq i32 %26, 0
%28 = load i32, i32* @S_IXUSR
%29 = and i32 %28, %5
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i8 45, i8 120
%32 = select i1 %27, i8 %31, i8 115
%33 = load i32, i32* @S_IRGRP
%34 = load i32, i32* @S_IWGRP
%35 = load i32, i32* @S_ISGID
%36 = and i32 %35, %5
%37 = icmp eq i32 %36, 0
%38 = load i32, i32* @S_IXGRP
%39 = and i32 %38, %5
%40 = icmp eq i32 %39, 0
%41 = select i1 %40, i8 45, i8 120
%42 = select i1 %37, i8 %41, i8 115
%43 = and i32 %34, %5
%44 = icmp eq i32 %43, 0
%45 = select i1 %44, i8 45, i8 119
%46 = and i32 %33, %5
%47 = icmp eq i32 %46, 0
%48 = select i1 %47, i8 45, i8 114
%49 = and i32 %24, %5
%50 = icmp eq i32 %49, 0
%51 = select i1 %50, i8 45, i8 119
%52 = and i32 %23, %5
%53 = icmp eq i32 %52, 0
%54 = select i1 %53, i8 45, i8 114
%55 = load i32, i32* @S_IROTH
%56 = and i32 %55, %5
%57 = icmp eq i32 %56, 0
%58 = select i1 %57, i8 45, i8 114
%59 = load i32, i32* @S_IWOTH
%60 = and i32 %59, %5
%61 = icmp eq i32 %60, 0
%62 = select i1 %61, i8 45, i8 119
%63 = load i32, i32* @S_IXOTH
%64 = and i32 %63, %5
%65 = icmp eq i32 %64, 0
%66 = select i1 %65, i8 45, i8 120
%67 = tail call i32 @snprintf(i8* %1, i64 %2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8 signext %22, i8 signext %54, i8 signext %51, i8 signext %32, i8 signext %48, i8 signext %45, i8 signext %42, i8 signext %58, i8 signext %62, i8 signext %66)
ret void
}