#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 */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char, char, int);
char *parse_mode(int mode) {
  static char m[6];
  memset(m, 0, 6);
  char suid, guid;
  suid = (mode & 04000) ? 'u' : '-';
  guid = (mode & 02000) ? 'g' : '-';
  snprintf(m, 6, "%c%c%3o", suid, guid, mode & 0777);
  return m;
}


x86 assembly (clang, -O0):
<parse_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0x2eff(%rip),%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1040 <memset@plt>
mov    -0x4(%rbp),%edx
and    $0x800,%edx
mov    $0x2d,%eax
mov    $0x75,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x5(%rbp)
mov    -0x4(%rbp),%edx
and    $0x400,%edx
mov    $0x2d,%eax
mov    $0x67,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,-0x6(%rbp)
mov    -0x5(%rbp),%cl
mov    -0x6(%rbp),%al
mov    -0x4(%rbp),%r9d
and    $0x1ff,%r9d
lea    0x2ea3(%rip),%rdi
mov    $0x6,%esi
lea    0xe66(%rip),%rdx
movsbl %cl,%ecx
movsbl %al,%r8d
call   1030 <snprintf@plt>
lea    0x2e84(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_mode>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0x2f04(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1040 <memset@plt>
mov    %ebx,%r9d
and    $0x1ff,%r9d
test   $0x800,%ebx
mov    $0x2d,%eax
mov    $0x75,%ecx
cmove  %eax,%ecx
test   $0x400,%ebx
mov    $0x67,%r8d
cmove  %eax,%r8d
lea    0xe90(%rip),%rdx
mov    %r14,%rdi
mov    $0x6,%esi
call   1030 <snprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@parse_mode.m = internal global [6 x i8] zeroinitializer
@.str = [8 x i8] c"%c%c%3o\00"
define i8* @parse_mode(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8
store i32 %0, i32* %2
%5 = call i32 @memset(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @parse_mode.m, i64 0, i64 0), i32 0, i32 6)
%6 = load i32, i32* %2
%7 = and i32 %6, 2048
%8 = icmp ne i32 %7, 0
%9 = zext i1 %8 to i64
%10 = select i1 %8, i32 117, i32 45
%11 = trunc i32 %10 to i8
store i8 %11, i8* %3
%12 = load i32, i32* %2
%13 = and i32 %12, 1024
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i64
%16 = select i1 %14, i32 103, i32 45
%17 = trunc i32 %16 to i8
store i8 %17, i8* %4
%18 = load i8, i8* %3
%19 = load i8, i8* %4
%20 = load i32, i32* %2
%21 = and i32 %20, 511
%22 = call i32 @snprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @parse_mode.m, i64 0, i64 0), i32 6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 signext %18, i8 signext %19, i32 %21)
ret i8* getelementptr inbounds ([6 x i8], [6 x i8]* @parse_mode.m, i64 0, i64 0)
}

LLVM IR (-O2):
@parse_mode.m = internal global [6 x i8] zeroinitializer
@.str = [8 x i8] c"%c%c%3o\00"
define i8* @parse_mode(i32 %0) {
%2 = tail call i32 @memset(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @parse_mode.m, i64 0, i64 0), i32 0, i32 6)
%3 = and i32 %0, 2048
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i8 45, i8 117
%6 = and i32 %0, 1024
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8 45, i8 103
%9 = and i32 %0, 511
%10 = tail call i32 @snprintf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @parse_mode.m, i64 0, i64 0), i32 6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 signext %5, i8 signext %8, i32 %9)
ret i8* getelementptr inbounds ([6 x i8], [6 x i8]* @parse_mode.m, i64 0, i64 0)
}