#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 */
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
int /*<<< orphan*/ snprintf(char *, int, char *, char, char, char, char, char,
                            char, char, char, char);
char *file_perm_str(mode_t perm) {
  static char str[10];
  snprintf(str, 10, "%c%c%c%c%c%c%c%c%c", (perm & S_IRUSR) ? 'r' : '-',
           (perm & S_IWUSR) ? 'w' : '-', (perm & S_IXUSR) ? 'x' : '-',
           (perm & S_IRGRP) ? 'r' : '-', (perm & S_IWGRP) ? 'w' : '-',
           (perm & S_IXGRP) ? 'x' : '-', (perm & S_IROTH) ? 'r' : '-',
           (perm & S_IWOTH) ? 'w' : '-', (perm & S_IXOTH) ? 'x' : '-');
  return str;
}


x86 assembly (clang, -O0):
<file_perm_str>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %edi,-0x1c(%rbp)
mov    -0x1c(%rbp),%edx
mov    0x2e7e(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x1c(%rbp),%esi
mov    0x2e88(%rip),%rax
and    (%rax),%esi
mov    $0x2d,%eax
mov    $0x77,%edx
cmp    $0x0,%esi
cmovne %edx,%eax
mov    %al,%r8b
mov    -0x1c(%rbp),%esi
mov    0x2e79(%rip),%rax
and    (%rax),%esi
mov    $0x2d,%eax
mov    $0x78,%edx
cmp    $0x0,%esi
cmovne %edx,%eax
mov    %al,%r9b
mov    -0x1c(%rbp),%esi
mov    0x2e32(%rip),%rax
and    (%rax),%esi
mov    $0x2d,%eax
mov    $0x72,%edx
cmp    $0x0,%esi
cmovne %edx,%eax
mov    %al,%r15b
mov    -0x1c(%rbp),%esi
mov    0x2e33(%rip),%rax
and    (%rax),%esi
mov    $0x2d,%eax
mov    $0x77,%edx
cmp    $0x0,%esi
cmovne %edx,%eax
mov    %al,%r14b
mov    -0x1c(%rbp),%esi
mov    0x2e04(%rip),%rax
and    (%rax),%esi
mov    $0x2d,%eax
mov    $0x78,%edx
cmp    $0x0,%esi
cmovne %edx,%eax
mov    %al,%bl
mov    -0x1c(%rbp),%esi
mov    0x2dce(%rip),%rax
and    (%rax),%esi
mov    $0x2d,%eax
mov    $0x72,%edx
cmp    $0x0,%esi
cmovne %edx,%eax
mov    %al,%r11b
mov    -0x1c(%rbp),%esi
mov    0x2d97(%rip),%rax
and    (%rax),%esi
mov    $0x2d,%eax
mov    $0x77,%edx
cmp    $0x0,%esi
cmovne %edx,%eax
mov    %al,%r10b
mov    -0x1c(%rbp),%esi
mov    0x2dc8(%rip),%rax
and    (%rax),%esi
mov    $0x2d,%eax
mov    $0x78,%edx
cmp    $0x0,%esi
cmovne %edx,%eax
lea    0x2df3(%rip),%rdi
mov    $0xa,%esi
lea    0xdbb(%rip),%rdx
movsbl %cl,%ecx
movsbl %r8b,%r8d
movsbl %r9b,%r9d
movsbl %r15b,%r15d
mov    %r15d,(%rsp)
movsbl %r14b,%r14d
mov    %r14d,0x8(%rsp)
movsbl %bl,%ebx
mov    %ebx,0x10(%rsp)
movsbl %r11b,%r11d
mov    %r11d,0x18(%rsp)
movsbl %r10b,%r10d
mov    %r10d,0x20(%rsp)
movsbl %al,%eax
mov    %eax,0x28(%rsp)
call   1030 <snprintf@plt>
lea    0x2d9f(%rip),%rax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_perm_str>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2e89(%rip),%rax
mov    (%rax),%r9d
and    %edi,%r9d
mov    0x2ea4(%rip),%rax
mov    (%rax),%esi
and    %edi,%esi
mov    0x2ea9(%rip),%rax
mov    (%rax),%r14d
and    %edi,%r14d
mov    0x2e74(%rip),%rax
mov    (%rax),%r10d
and    %edi,%r10d
mov    0x2e87(%rip),%rbx
mov    (%rbx),%ebx
and    %edi,%ebx
mov    0x2e6c(%rip),%rdx
mov    (%rdx),%edx
and    %edi,%edx
mov    0x2e49(%rip),%rbp
mov    0x0(%rbp),%ebp
and    %edi,%ebp
mov    0x2e25(%rip),%rcx
mov    (%rcx),%eax
and    %edi,%eax
mov    0x2e6a(%rip),%rcx
and    (%rcx),%edi
test   %esi,%esi
mov    $0x2d,%esi
mov    $0x77,%r11d
mov    $0x77,%r8d
cmove  %esi,%r8d
test   %r9d,%r9d
mov    $0x72,%ecx
cmove  %esi,%ecx
test   %r10d,%r10d
mov    $0x72,%r10d
cmove  %esi,%r10d
test   %ebx,%ebx
mov    $0x77,%r15d
cmove  %esi,%r15d
test   %edx,%edx
mov    $0x78,%r12d
cmove  %esi,%r12d
mov    $0x72,%ebx
test   %ebp,%ebp
cmove  %esi,%ebx
mov    $0x78,%r9d
test   %eax,%eax
cmove  %esi,%r11d
test   %edi,%edi
mov    $0x78,%eax
cmove  %esi,%eax
test   %r14d,%r14d
cmove  %esi,%r9d
lea    0x2e37(%rip),%r14
lea    0xe04(%rip),%rdx
mov    %r14,%rdi
mov    $0xa,%esi
push   %rax
push   %r11
push   %rbx
push   %r12
push   %r15
push   %r10
call   1030 <snprintf@plt>
add    $0x30,%rsp
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@file_perm_str.str = internal global [10 x i8] zeroinitializer
@.str = [19 x i8] c"%c%c%c%c%c%c%c%c%c\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@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_IXOTH = global i32 0
define i8* @file_perm_str(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @S_IRUSR
%5 = and i32 %3, %4
%6 = icmp ne i32 %5, 0
%7 = zext i1 %6 to i64
%8 = select i1 %6, i32 114, i32 45
%9 = trunc i32 %8 to i8
%10 = load i32, i32* %2
%11 = load i32, i32* @S_IWUSR
%12 = and i32 %10, %11
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i32 119, i32 45
%16 = trunc i32 %15 to i8
%17 = load i32, i32* %2
%18 = load i32, i32* @S_IXUSR
%19 = and i32 %17, %18
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 120, i32 45
%23 = trunc i32 %22 to i8
%24 = load i32, i32* %2
%25 = load i32, i32* @S_IRGRP
%26 = and i32 %24, %25
%27 = icmp ne i32 %26, 0
%28 = zext i1 %27 to i64
%29 = select i1 %27, i32 114, i32 45
%30 = trunc i32 %29 to i8
%31 = load i32, i32* %2
%32 = load i32, i32* @S_IWGRP
%33 = and i32 %31, %32
%34 = icmp ne i32 %33, 0
%35 = zext i1 %34 to i64
%36 = select i1 %34, i32 119, i32 45
%37 = trunc i32 %36 to i8
%38 = load i32, i32* %2
%39 = load i32, i32* @S_IXGRP
%40 = and i32 %38, %39
%41 = icmp ne i32 %40, 0
%42 = zext i1 %41 to i64
%43 = select i1 %41, i32 120, i32 45
%44 = trunc i32 %43 to i8
%45 = load i32, i32* %2
%46 = load i32, i32* @S_IROTH
%47 = and i32 %45, %46
%48 = icmp ne i32 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i32 114, i32 45
%51 = trunc i32 %50 to i8
%52 = load i32, i32* %2
%53 = load i32, i32* @S_IWOTH
%54 = and i32 %52, %53
%55 = icmp ne i32 %54, 0
%56 = zext i1 %55 to i64
%57 = select i1 %55, i32 119, i32 45
%58 = trunc i32 %57 to i8
%59 = load i32, i32* %2
%60 = load i32, i32* @S_IXOTH
%61 = and i32 %59, %60
%62 = icmp ne i32 %61, 0
%63 = zext i1 %62 to i64
%64 = select i1 %62, i32 120, i32 45
%65 = trunc i32 %64 to i8
%66 = call i32 @snprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @file_perm_str.str, i64 0, i64 0), i32 10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8 signext %9, i8 signext %16, i8 signext %23, i8 signext %30, i8 signext %37, i8 signext %44, i8 signext %51, i8 signext %58, i8 signext %65)
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @file_perm_str.str, i64 0, i64 0)
}

LLVM IR (-O2):
@file_perm_str.str = internal global [10 x i8] zeroinitializer
@.str = [19 x i8] c"%c%c%c%c%c%c%c%c%c\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@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_IXOTH = global i32 0
define i8* @file_perm_str(i32 %0) {
%2 = load i32, i32* @S_IRUSR
%3 = and i32 %2, %0
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i8 45, i8 114
%6 = load i32, i32* @S_IWUSR
%7 = and i32 %6, %0
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i8 45, i8 119
%10 = load i32, i32* @S_IXUSR
%11 = and i32 %10, %0
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8 45, i8 120
%14 = load i32, i32* @S_IRGRP
%15 = and i32 %14, %0
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i8 45, i8 114
%18 = load i32, i32* @S_IWGRP
%19 = and i32 %18, %0
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i8 45, i8 119
%22 = load i32, i32* @S_IXGRP
%23 = and i32 %22, %0
%24 = icmp eq i32 %23, 0
%25 = select i1 %24, i8 45, i8 120
%26 = load i32, i32* @S_IROTH
%27 = and i32 %26, %0
%28 = icmp eq i32 %27, 0
%29 = select i1 %28, i8 45, i8 114
%30 = load i32, i32* @S_IWOTH
%31 = and i32 %30, %0
%32 = icmp eq i32 %31, 0
%33 = select i1 %32, i8 45, i8 119
%34 = load i32, i32* @S_IXOTH
%35 = and i32 %34, %0
%36 = icmp eq i32 %35, 0
%37 = select i1 %36, i8 45, i8 120
%38 = tail call i32 @snprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @file_perm_str.str, i64 0, i64 0), i32 10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8 signext %5, i8 signext %9, i8 signext %13, i8 signext %17, i8 signext %21, i8 signext %25, i8 signext %29, i8 signext %33, i8 signext %37)
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @file_perm_str.str, i64 0, i64 0)
}