#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_ISGID;
int S_ISUID;
int S_ISVTX;
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, int flags) {
  static char str[sizeof("rwxrwxrwx")];
  snprintf(str, sizeof("rwxrwxrwx"), "%c%c%c%c%c%c%c%c%c",
           (perm & S_IRUSR) ? 'r' : '-', (perm & S_IWUSR) ? 'w' : '-',
           (perm & S_IXUSR) ? (((perm & S_ISUID) && (flags & 1)) ? 's' : 'x')
                            : (((perm & S_ISUID) && (flags & 1)) ? 'S' : '-'),
           (perm & S_IRGRP) ? 'r' : '-', (perm & S_IWGRP) ? 'w' : '-',
           (perm & S_IXGRP) ? (((perm & S_ISGID) && (flags & 1)) ? 's' : 'x')
                            : (((perm & S_ISGID) && (flags & 1)) ? 'S' : '-'),
           (perm & S_IROTH) ? 'r' : '-', (perm & S_IWOTH) ? 'w' : '-',
           (perm & S_IXOTH) ? (((perm & S_ISVTX) && (flags & 1)) ? 't' : 'x')
                            : (((perm & S_ISVTX) && (flags & 1)) ? 'T' : '-'));
  return str;
}


x86 assembly (clang, -O0):
<file_perm_str>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %edi,-0x1c(%rbp)
mov    %esi,-0x20(%rbp)
mov    -0x1c(%rbp),%edx
mov    0x2e63(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x22(%rbp)
mov    -0x1c(%rbp),%edx
mov    0x2e74(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x21(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e6d(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11ba <file_perm_str+0xaa>
mov    -0x1c(%rbp),%ecx
mov    0x2e50(%rip),%rax
and    (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x23(%rbp)
je     119f <file_perm_str+0x8f>
mov    -0x20(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x23(%rbp)
mov    -0x23(%rbp),%dl
mov    $0x78,%eax
mov    $0x73,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0x28(%rbp)
jmp    11f9 <file_perm_str+0xe9>
mov    -0x1c(%rbp),%ecx
mov    0x2e0c(%rip),%rax
and    (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     11e3 <file_perm_str+0xd3>
mov    -0x20(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%dl
mov    $0x2d,%eax
mov    $0x53,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %al,-0x2c(%rbp)
mov    -0x1c(%rbp),%edx
mov    0x2d97(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x2b(%rbp)
mov    -0x1c(%rbp),%edx
mov    0x2da0(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x2a(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2d71(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1296 <file_perm_str+0x186>
mov    -0x1c(%rbp),%ecx
mov    0x2d4c(%rip),%rax
and    (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2d(%rbp)
je     127b <file_perm_str+0x16b>
mov    -0x20(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%dl
mov    $0x78,%eax
mov    $0x73,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0x34(%rbp)
jmp    12d5 <file_perm_str+0x1c5>
mov    -0x1c(%rbp),%ecx
mov    0x2d08(%rip),%rax
and    (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x35(%rbp)
je     12bf <file_perm_str+0x1af>
mov    -0x20(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%dl
mov    $0x2d,%eax
mov    $0x53,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %al,-0x38(%rbp)
mov    -0x1c(%rbp),%edx
mov    0x2cb3(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x37(%rbp)
mov    -0x1c(%rbp),%edx
mov    0x2c7c(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x36(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2cbd(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1372 <file_perm_str+0x262>
mov    -0x1c(%rbp),%ecx
mov    0x2cb0(%rip),%rax
and    (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x39(%rbp)
je     1357 <file_perm_str+0x247>
mov    -0x20(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%dl
mov    $0x78,%eax
mov    $0x74,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0x40(%rbp)
jmp    13b1 <file_perm_str+0x2a1>
mov    -0x1c(%rbp),%ecx
mov    0x2c6c(%rip),%rax
and    (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x41(%rbp)
je     139b <file_perm_str+0x28b>
mov    -0x20(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%dl
mov    $0x2d,%eax
mov    $0x54,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    -0x36(%rbp),%r10b
mov    -0x37(%rbp),%r11b
mov    -0x38(%rbp),%bl
mov    -0x2a(%rbp),%r14b
mov    -0x2b(%rbp),%r15b
mov    -0x2c(%rbp),%r9b
mov    -0x21(%rbp),%r8b
mov    -0x22(%rbp),%cl
mov    -0x40(%rbp),%eax
lea    0x2c53(%rip),%rdi
mov    $0xa,%esi
lea    0xc1b(%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    0x2bff(%rip),%rax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_perm_str>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e6e(%rip),%r8
mov    0x2e97(%rip),%r9
mov    0x2ea8(%rip),%rax
mov    (%rax),%ecx
and    %edi,%ecx
mov    0x2e95(%rip),%rax
mov    (%rax),%eax
and    %edi,%eax
setne  %al
xor    %edx,%edx
test   %al,%sil
sete   %dl
mov    $0x53,%eax
mov    $0x2d,%ebp
cmovne %eax,%ebp
test   %ecx,%ecx
lea    0x73(%rdx,%rdx,4),%r11d
cmove  %ebp,%r11d
mov    $0x2d,%r14d
mov    0x2e31(%rip),%r10
mov    0x2e52(%rip),%r15
mov    0x2e3b(%rip),%rdx
mov    (%rdx),%edx
and    %edi,%edx
mov    0x2e20(%rip),%rbx
mov    (%rbx),%ebx
and    %edi,%ebx
setne  %bl
xor    %ebp,%ebp
test   %bl,%sil
sete   %bpl
cmove  %r14d,%eax
test   %edx,%edx
lea    0x73(%rbp,%rbp,4),%r13d
cmove  %eax,%r13d
mov    0x2dea(%rip),%r12
mov    0x2dcb(%rip),%rbx
mov    0x2e24(%rip),%rbp
mov    0x0(%rbp),%ebp
and    %edi,%ebp
mov    0x2e20(%rip),%rcx
mov    (%rcx),%ecx
and    %edi,%ecx
setne  %al
and    %sil,%al
mov    %eax,%ecx
xor    $0x1,%cl
shl    $0x2,%cl
add    $0x74,%cl
test   %al,%al
mov    $0x54,%eax
cmove  %r14d,%eax
test   %ebp,%ebp
movzbl %cl,%esi
cmove  %eax,%esi
mov    (%rbx),%edx
and    %edi,%edx
mov    (%r12),%r12d
and    %edi,%r12d
mov    (%r15),%ebp
and    %edi,%ebp
mov    (%r10),%ebx
and    %edi,%ebx
mov    (%r9),%eax
and    %edi,%eax
and    (%r8),%edi
mov    $0x72,%r15d
mov    $0x72,%ecx
cmove  %r14d,%ecx
test   %ebx,%ebx
mov    $0x72,%r10d
cmove  %r14d,%r10d
test   %ebp,%ebp
mov    $0x77,%ebp
cmove  %r14d,%ebp
mov    $0x77,%r8d
test   %r12d,%r12d
cmove  %r14d,%r15d
test   %edx,%edx
mov    $0x77,%ebx
cmove  %r14d,%ebx
test   %eax,%eax
movzbl %sil,%eax
movzbl %r13b,%r12d
cmove  %r14d,%r8d
movzbl %r11b,%r9d
lea    0x2dc8(%rip),%r14
lea    0xd95(%rip),%rdx
mov    %r14,%rdi
mov    $0xa,%esi
push   %rax
push   %rbx
push   %r15
push   %r12
push   %rbp
push   %r10
call   1030 <snprintf@plt>
add    $0x30,%rsp
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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_ISUID = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IXGRP = global i32 0
@S_ISGID = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
@S_ISVTX = global i32 0
define i8* @file_perm_str(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = load i32, i32* @S_IRUSR
%7 = and i32 %5, %6
%8 = icmp ne i32 %7, 0
%9 = zext i1 %8 to i64
%10 = select i1 %8, i32 114, i32 45
%11 = trunc i32 %10 to i8
%12 = load i32, i32* %3
%13 = load i32, i32* @S_IWUSR
%14 = and i32 %12, %13
%15 = icmp ne i32 %14, 0
%16 = zext i1 %15 to i64
%17 = select i1 %15, i32 119, i32 45
%18 = trunc i32 %17 to i8
%19 = load i32, i32* %3
%20 = load i32, i32* @S_IXUSR
%21 = and i32 %19, %20
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %36
23: ; preds = %2
%24 = load i32, i32* %3
%25 = load i32, i32* @S_ISUID
%26 = and i32 %24, %25
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i32, i32* %4
%30 = and i32 %29, 1
%31 = icmp ne i32 %30, 0
br label %32
32: ; preds = %28, %23
%33 = phi i1 [ false, %23 ], [ %31, %28 ]
%34 = zext i1 %33 to i64
%35 = select i1 %33, i32 115, i32 120
br label %49
36: ; preds = %2
%37 = load i32, i32* %3
%38 = load i32, i32* @S_ISUID
%39 = and i32 %37, %38
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %36
%42 = load i32, i32* %4
%43 = and i32 %42, 1
%44 = icmp ne i32 %43, 0
br label %45
45: ; preds = %41, %36
%46 = phi i1 [ false, %36 ], [ %44, %41 ]
%47 = zext i1 %46 to i64
%48 = select i1 %46, i32 83, i32 45
br label %49
49: ; preds = %45, %32
%50 = phi i32 [ %35, %32 ], [ %48, %45 ]
%51 = trunc i32 %50 to i8
%52 = load i32, i32* %3
%53 = load i32, i32* @S_IRGRP
%54 = and i32 %52, %53
%55 = icmp ne i32 %54, 0
%56 = zext i1 %55 to i64
%57 = select i1 %55, i32 114, i32 45
%58 = trunc i32 %57 to i8
%59 = load i32, i32* %3
%60 = load i32, i32* @S_IWGRP
%61 = and i32 %59, %60
%62 = icmp ne i32 %61, 0
%63 = zext i1 %62 to i64
%64 = select i1 %62, i32 119, i32 45
%65 = trunc i32 %64 to i8
%66 = load i32, i32* %3
%67 = load i32, i32* @S_IXGRP
%68 = and i32 %66, %67
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %83
70: ; preds = %49
%71 = load i32, i32* %3
%72 = load i32, i32* @S_ISGID
%73 = and i32 %71, %72
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %79
75: ; preds = %70
%76 = load i32, i32* %4
%77 = and i32 %76, 1
%78 = icmp ne i32 %77, 0
br label %79
79: ; preds = %75, %70
%80 = phi i1 [ false, %70 ], [ %78, %75 ]
%81 = zext i1 %80 to i64
%82 = select i1 %80, i32 115, i32 120
br label %96
83: ; preds = %49
%84 = load i32, i32* %3
%85 = load i32, i32* @S_ISGID
%86 = and i32 %84, %85
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %92
88: ; preds = %83
%89 = load i32, i32* %4
%90 = and i32 %89, 1
%91 = icmp ne i32 %90, 0
br label %92
92: ; preds = %88, %83
%93 = phi i1 [ false, %83 ], [ %91, %88 ]
%94 = zext i1 %93 to i64
%95 = select i1 %93, i32 83, i32 45
br label %96
96: ; preds = %92, %79
%97 = phi i32 [ %82, %79 ], [ %95, %92 ]
%98 = trunc i32 %97 to i8
%99 = load i32, i32* %3
%100 = load i32, i32* @S_IROTH
%101 = and i32 %99, %100
%102 = icmp ne i32 %101, 0
%103 = zext i1 %102 to i64
%104 = select i1 %102, i32 114, i32 45
%105 = trunc i32 %104 to i8
%106 = load i32, i32* %3
%107 = load i32, i32* @S_IWOTH
%108 = and i32 %106, %107
%109 = icmp ne i32 %108, 0
%110 = zext i1 %109 to i64
%111 = select i1 %109, i32 119, i32 45
%112 = trunc i32 %111 to i8
%113 = load i32, i32* %3
%114 = load i32, i32* @S_IXOTH
%115 = and i32 %113, %114
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %130
117: ; preds = %96
%118 = load i32, i32* %3
%119 = load i32, i32* @S_ISVTX
%120 = and i32 %118, %119
%121 = icmp ne i32 %120, 0
br i1 %121, label %122, label %126
122: ; preds = %117
%123 = load i32, i32* %4
%124 = and i32 %123, 1
%125 = icmp ne i32 %124, 0
br label %126
126: ; preds = %122, %117
%127 = phi i1 [ false, %117 ], [ %125, %122 ]
%128 = zext i1 %127 to i64
%129 = select i1 %127, i32 116, i32 120
br label %143
130: ; preds = %96
%131 = load i32, i32* %3
%132 = load i32, i32* @S_ISVTX
%133 = and i32 %131, %132
%134 = icmp ne i32 %133, 0
br i1 %134, label %135, label %139
135: ; preds = %130
%136 = load i32, i32* %4
%137 = and i32 %136, 1
%138 = icmp ne i32 %137, 0
br label %139
139: ; preds = %135, %130
%140 = phi i1 [ false, %130 ], [ %138, %135 ]
%141 = zext i1 %140 to i64
%142 = select i1 %140, i32 84, i32 45
br label %143
143: ; preds = %139, %126
%144 = phi i32 [ %129, %126 ], [ %142, %139 ]
%145 = trunc i32 %144 to i8
%146 = 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 %11, i8 signext %18, i8 signext %51, i8 signext %58, i8 signext %65, i8 signext %98, i8 signext %105, i8 signext %112, i8 signext %145)
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_ISUID = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IXGRP = global i32 0
@S_ISGID = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
@S_ISVTX = global i32 0
define i8* @file_perm_str(i32 %0, i32 %1) {
%3 = load i32, i32* @S_IRUSR
%4 = load i32, i32* @S_IWUSR
%5 = load i32, i32* @S_IXUSR
%6 = and i32 %5, %0
%7 = icmp eq i32 %6, 0
%8 = load i32, i32* @S_ISUID
%9 = and i32 %8, %0
%10 = icmp ne i32 %9, 0
%11 = and i32 %1, 1
%12 = icmp ne i32 %11, 0
%13 = and i1 %12, %10
%14 = select i1 %13, i8 115, i8 120
%15 = select i1 %13, i8 83, i8 45
%16 = select i1 %7, i8 %15, i8 %14
%17 = load i32, i32* @S_IRGRP
%18 = load i32, i32* @S_IWGRP
%19 = load i32, i32* @S_IXGRP
%20 = and i32 %19, %0
%21 = icmp eq i32 %20, 0
%22 = load i32, i32* @S_ISGID
%23 = and i32 %22, %0
%24 = icmp ne i32 %23, 0
%25 = and i32 %1, 1
%26 = icmp ne i32 %25, 0
%27 = and i1 %26, %24
%28 = select i1 %27, i8 115, i8 120
%29 = select i1 %27, i8 83, i8 45
%30 = select i1 %21, i8 %29, i8 %28
%31 = load i32, i32* @S_IROTH
%32 = load i32, i32* @S_IWOTH
%33 = load i32, i32* @S_IXOTH
%34 = and i32 %33, %0
%35 = icmp eq i32 %34, 0
%36 = load i32, i32* @S_ISVTX
%37 = and i32 %36, %0
%38 = icmp ne i32 %37, 0
%39 = and i32 %1, 1
%40 = icmp ne i32 %39, 0
%41 = and i1 %40, %38
%42 = select i1 %41, i8 116, i8 120
%43 = select i1 %41, i8 84, i8 45
%44 = select i1 %35, i8 %43, i8 %42
%45 = and i32 %32, %0
%46 = icmp eq i32 %45, 0
%47 = select i1 %46, i8 45, i8 119
%48 = and i32 %31, %0
%49 = icmp eq i32 %48, 0
%50 = select i1 %49, i8 45, i8 114
%51 = and i32 %18, %0
%52 = icmp eq i32 %51, 0
%53 = select i1 %52, i8 45, i8 119
%54 = and i32 %17, %0
%55 = icmp eq i32 %54, 0
%56 = select i1 %55, i8 45, i8 114
%57 = and i32 %4, %0
%58 = icmp eq i32 %57, 0
%59 = select i1 %58, i8 45, i8 119
%60 = and i32 %3, %0
%61 = icmp eq i32 %60, 0
%62 = select i1 %61, i8 45, i8 114
%63 = 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 %62, i8 signext %59, i8 signext %16, i8 signext %56, i8 signext %53, i8 signext %30, i8 signext %50, i8 signext %47, i8 signext %44)
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @file_perm_str.str, i64 0, i64 0)
}