#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*/ assert(int /*<<< orphan*/);
void ar_mode_str(mode_t mode, char *str) {
  assert(str != NULL);
  str[0] = (mode & S_IRUSR) ? 'r' : '-';
  str[1] = (mode & S_IWUSR) ? 'w' : '-';
  str[2] = (mode & S_IXUSR) ? 'x' : '-';
  str[3] = (mode & S_IRGRP) ? 'r' : '-';
  str[4] = (mode & S_IWGRP) ? 'w' : '-';
  str[5] = (mode & S_IXGRP) ? 'x' : '-';
  str[6] = (mode & S_IROTH) ? 'r' : '-';
  str[7] = (mode & S_IWOTH) ? 'w' : '-';
  str[8] = (mode & S_IXOTH) ? 'x' : '-';
  str[9] = '\0';
}


x86 assembly (clang, -O0):
<ar_mode_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%edx
mov    0x2e6d(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x4(%rbp),%edx
mov    0x2e71(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x4(%rbp),%edx
mov    0x2e5c(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x78,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x4(%rbp),%edx
mov    0x2e0f(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x4(%rbp),%edx
mov    0x2e0a(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x4(%rbp),%edx
mov    0x2dd5(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x78,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x4(%rbp),%edx
mov    0x2d98(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x4(%rbp),%edx
mov    0x2d5b(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x7(%rax)
mov    -0x4(%rbp),%edx
mov    0x2d86(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x78,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x8(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x9(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ar_mode_str>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
test   %rsi,%rsi
setne  %dil
call   1030 <assert@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x2d,%eax
mov    $0x72,%ecx
cmove  %eax,%ecx
mov    %cl,(%rbx)
mov    0x2e89(%rip),%rcx
mov    (%rcx),%ecx
and    %ebp,%ecx
mov    $0x77,%ecx
cmove  %eax,%ecx
mov    %cl,0x1(%rbx)
mov    0x2e83(%rip),%rcx
mov    (%rcx),%ecx
and    %ebp,%ecx
mov    $0x78,%edx
cmove  %eax,%edx
mov    $0x72,%ecx
mov    %dl,0x2(%rbx)
mov    0x2e40(%rip),%rdx
mov    (%rdx),%edx
and    %ebp,%edx
mov    $0x72,%esi
cmove  %eax,%esi
mov    $0x77,%edx
mov    %sil,0x3(%rbx)
mov    0x2e44(%rip),%rsi
mov    (%rsi),%esi
and    %ebp,%esi
mov    $0x77,%edi
cmove  %eax,%edi
mov    $0x78,%esi
mov    %dil,0x4(%rbx)
mov    0x2e18(%rip),%rdi
mov    (%rdi),%edi
and    %ebp,%edi
mov    $0x78,%edi
cmove  %eax,%edi
mov    %dil,0x5(%rbx)
mov    0x2de9(%rip),%rdi
mov    (%rdi),%edi
and    %ebp,%edi
cmove  %eax,%ecx
mov    %cl,0x6(%rbx)
mov    0x2dc0(%rip),%rcx
mov    (%rcx),%ecx
and    %ebp,%ecx
cmove  %eax,%edx
mov    %dl,0x7(%rbx)
mov    0x2dff(%rip),%rcx
and    (%rcx),%ebp
cmove  %eax,%esi
mov    %sil,0x8(%rbx)
movb   $0x0,0x9(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@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 void @ar_mode_str(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = icmp ne i8* %5, null
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load i32, i32* %3
%10 = load i32, i32* @S_IRUSR
%11 = and i32 %9, %10
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i32 114, i32 45
%15 = trunc i32 %14 to i8
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 0
store i8 %15, i8* %17
%18 = load i32, i32* %3
%19 = load i32, i32* @S_IWUSR
%20 = and i32 %18, %19
%21 = icmp ne i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i32 119, i32 45
%24 = trunc i32 %23 to i8
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 1
store i8 %24, i8* %26
%27 = load i32, i32* %3
%28 = load i32, i32* @S_IXUSR
%29 = and i32 %27, %28
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i64
%32 = select i1 %30, i32 120, i32 45
%33 = trunc i32 %32 to i8
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 2
store i8 %33, i8* %35
%36 = load i32, i32* %3
%37 = load i32, i32* @S_IRGRP
%38 = and i32 %36, %37
%39 = icmp ne i32 %38, 0
%40 = zext i1 %39 to i64
%41 = select i1 %39, i32 114, i32 45
%42 = trunc i32 %41 to i8
%43 = load i8*, i8** %4
%44 = getelementptr inbounds i8, i8* %43, i64 3
store i8 %42, i8* %44
%45 = load i32, i32* %3
%46 = load i32, i32* @S_IWGRP
%47 = and i32 %45, %46
%48 = icmp ne i32 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i32 119, i32 45
%51 = trunc i32 %50 to i8
%52 = load i8*, i8** %4
%53 = getelementptr inbounds i8, i8* %52, i64 4
store i8 %51, i8* %53
%54 = load i32, i32* %3
%55 = load i32, i32* @S_IXGRP
%56 = and i32 %54, %55
%57 = icmp ne i32 %56, 0
%58 = zext i1 %57 to i64
%59 = select i1 %57, i32 120, i32 45
%60 = trunc i32 %59 to i8
%61 = load i8*, i8** %4
%62 = getelementptr inbounds i8, i8* %61, i64 5
store i8 %60, i8* %62
%63 = load i32, i32* %3
%64 = load i32, i32* @S_IROTH
%65 = and i32 %63, %64
%66 = icmp ne i32 %65, 0
%67 = zext i1 %66 to i64
%68 = select i1 %66, i32 114, i32 45
%69 = trunc i32 %68 to i8
%70 = load i8*, i8** %4
%71 = getelementptr inbounds i8, i8* %70, i64 6
store i8 %69, i8* %71
%72 = load i32, i32* %3
%73 = load i32, i32* @S_IWOTH
%74 = and i32 %72, %73
%75 = icmp ne i32 %74, 0
%76 = zext i1 %75 to i64
%77 = select i1 %75, i32 119, i32 45
%78 = trunc i32 %77 to i8
%79 = load i8*, i8** %4
%80 = getelementptr inbounds i8, i8* %79, i64 7
store i8 %78, i8* %80
%81 = load i32, i32* %3
%82 = load i32, i32* @S_IXOTH
%83 = and i32 %81, %82
%84 = icmp ne i32 %83, 0
%85 = zext i1 %84 to i64
%86 = select i1 %84, i32 120, i32 45
%87 = trunc i32 %86 to i8
%88 = load i8*, i8** %4
%89 = getelementptr inbounds i8, i8* %88, i64 8
store i8 %87, i8* %89
%90 = load i8*, i8** %4
%91 = getelementptr inbounds i8, i8* %90, i64 9
store i8 0, i8* %91
ret void
}

LLVM IR (-O2):
@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 void @ar_mode_str(i32 %0, i8* writeonly %1) {
%3 = icmp ne i8* %1, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = load i32, i32* @S_IRUSR
%7 = and i32 %6, %0
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i8 45, i8 114
store i8 %9, i8* %1
%10 = load i32, i32* @S_IWUSR
%11 = and i32 %10, %0
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8 45, i8 119
%14 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %13, i8* %14
%15 = load i32, i32* @S_IXUSR
%16 = and i32 %15, %0
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i8 45, i8 120
%19 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %18, i8* %19
%20 = load i32, i32* @S_IRGRP
%21 = and i32 %20, %0
%22 = icmp eq i32 %21, 0
%23 = select i1 %22, i8 45, i8 114
%24 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %23, i8* %24
%25 = load i32, i32* @S_IWGRP
%26 = and i32 %25, %0
%27 = icmp eq i32 %26, 0
%28 = select i1 %27, i8 45, i8 119
%29 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %28, i8* %29
%30 = load i32, i32* @S_IXGRP
%31 = and i32 %30, %0
%32 = icmp eq i32 %31, 0
%33 = select i1 %32, i8 45, i8 120
%34 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %33, i8* %34
%35 = load i32, i32* @S_IROTH
%36 = and i32 %35, %0
%37 = icmp eq i32 %36, 0
%38 = select i1 %37, i8 45, i8 114
%39 = getelementptr inbounds i8, i8* %1, i64 6
store i8 %38, i8* %39
%40 = load i32, i32* @S_IWOTH
%41 = and i32 %40, %0
%42 = icmp eq i32 %41, 0
%43 = select i1 %42, i8 45, i8 119
%44 = getelementptr inbounds i8, i8* %1, i64 7
store i8 %43, i8* %44
%45 = load i32, i32* @S_IXOTH
%46 = and i32 %45, %0
%47 = icmp eq i32 %46, 0
%48 = select i1 %47, i8 45, i8 120
%49 = getelementptr inbounds i8, i8* %1, i64 8
store i8 %48, i8* %49
%50 = getelementptr inbounds i8, i8* %1, i64 9
store i8 0, i8* %50
ret void
}