#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 */
unsigned int NIS_CREATE_ACC;
unsigned int NIS_DESTROY_ACC;
unsigned int NIS_MODIFY_ACC;
unsigned int NIS_READ_ACC;
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void nis_print_rights(const unsigned int access) {
  char result[17];
  unsigned int acc;
  int i;
  acc = access;
  result[i = 16] = '\0';
  while (i > 0) {
    i -= 4;
    result[i + 0] = (acc & NIS_READ_ACC) ? 'r' : '-';
    result[i + 1] = (acc & NIS_MODIFY_ACC) ? 'm' : '-';
    result[i + 2] = (acc & NIS_CREATE_ACC) ? 'c' : '-';
    result[i + 3] = (acc & NIS_DESTROY_ACC) ? 'd' : '-';
    acc >>= 8;
  }
  fputs(result, stdout);
}


x86 assembly (clang, -O0):
<nis_print_rights>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x10,-0x28(%rbp)
movb   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    11f5 <nis_print_rights+0xe5>
mov    -0x28(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edx
mov    0x2ea7(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x28(%rbp),%eax
add    $0x0,%eax
cltq
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x24(%rbp),%edx
mov    0x2e75(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x6d,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x28(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x24(%rbp),%edx
mov    0x2e33(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x63,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x28(%rbp),%eax
add    $0x2,%eax
cltq
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x24(%rbp),%edx
mov    0x2df9(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x64,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%cl
mov    -0x28(%rbp),%eax
add    $0x3,%eax
cltq
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x24(%rbp),%eax
shr    $0x8,%eax
mov    %eax,-0x24(%rbp)
jmp    112c <nis_print_rights+0x1c>
lea    -0x20(%rbp),%rdi
mov    0x2dc8(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nis_print_rights>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movb   $0x0,0x10(%rsp)
mov    0x2ecc(%rip),%rax
mov    (%rax),%esi
mov    0x2ebb(%rip),%rcx
mov    (%rcx),%r14d
mov    0x2e99(%rip),%rcx
mov    (%rcx),%r11d
mov    0x2e7f(%rip),%rcx
mov    (%rcx),%r8d
test   %edi,%esi
mov    $0x2d,%ecx
mov    $0x72,%r10d
mov    $0x72,%edx
cmove  %ecx,%edx
mov    %dl,0xc(%rsp)
test   %edi,%r14d
setne  %dl
shl    $0x6,%dl
or     $0x2d,%dl
mov    %dl,0xd(%rsp)
test   %edi,%r11d
mov    $0x63,%r9d
mov    $0x63,%edx
cmove  %ecx,%edx
mov    %dl,0xe(%rsp)
test   %edi,%r8d
mov    $0x64,%edx
cmove  %ecx,%edx
mov    %dl,0xf(%rsp)
mov    %edi,%ebx
shr    $0x8,%ebx
test   %ebx,%esi
mov    $0x72,%edx
cmove  %ecx,%edx
mov    %dl,0x8(%rsp)
test   %ebx,%r14d
setne  %dl
shl    $0x6,%dl
or     $0x2d,%dl
mov    %dl,0x9(%rsp)
test   %ebx,%r11d
mov    $0x63,%ebp
cmove  %ecx,%ebp
mov    $0x64,%edx
mov    %bpl,0xa(%rsp)
test   %ebx,%r8d
mov    $0x64,%ebx
cmove  %ecx,%ebx
mov    %bl,0xb(%rsp)
mov    %edi,%ebx
shr    $0x10,%ebx
test   %ebx,%esi
mov    $0x72,%ebp
cmove  %ecx,%ebp
mov    %bpl,0x4(%rsp)
test   %ebx,%r14d
setne  %al
shl    $0x6,%al
or     $0x2d,%al
mov    %al,0x5(%rsp)
test   %ebx,%r11d
mov    $0x63,%eax
cmove  %ecx,%eax
mov    %al,0x6(%rsp)
test   %ebx,%r8d
mov    $0x64,%eax
cmove  %ecx,%eax
mov    %al,0x7(%rsp)
shr    $0x18,%edi
test   %edi,%esi
cmove  %ecx,%r10d
mov    %r10b,(%rsp)
test   %edi,%r14d
setne  %al
shl    $0x6,%al
or     $0x2d,%al
test   %edi,%r11d
cmove  %ecx,%r9d
mov    %al,0x1(%rsp)
test   %edi,%r8d
cmove  %ecx,%edx
mov    %r9b,0x2(%rsp)
mov    %dl,0x3(%rsp)
mov    0x2d76(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
call   1030 <fputs@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@NIS_READ_ACC = global i32 0
@NIS_MODIFY_ACC = global i32 0
@NIS_CREATE_ACC = global i32 0
@NIS_DESTROY_ACC = global i32 0
@stdout = global i32 0
define void @nis_print_rights(i32 %0) {
%2 = alloca i32
%3 = alloca [17 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
store i32 %6, i32* %4
store i32 16, i32* %5
%7 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 16
store i8 0, i8* %7
br label %8
8: ; preds = %11, %1
%9 = load i32, i32* %5
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %60
11: ; preds = %8
%12 = load i32, i32* %5
%13 = sub nsw i32 %12, 4
store i32 %13, i32* %5
%14 = load i32, i32* %4
%15 = load i32, i32* @NIS_READ_ACC
%16 = and i32 %14, %15
%17 = icmp ne i32 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, i32 114, i32 45
%20 = trunc i32 %19 to i8
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 0
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 %23
store i8 %20, i8* %24
%25 = load i32, i32* %4
%26 = load i32, i32* @NIS_MODIFY_ACC
%27 = and i32 %25, %26
%28 = icmp ne i32 %27, 0
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 109, i32 45
%31 = trunc i32 %30 to i8
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 %34
store i8 %31, i8* %35
%36 = load i32, i32* %4
%37 = load i32, i32* @NIS_CREATE_ACC
%38 = and i32 %36, %37
%39 = icmp ne i32 %38, 0
%40 = zext i1 %39 to i64
%41 = select i1 %39, i32 99, i32 45
%42 = trunc i32 %41 to i8
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 2
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 %45
store i8 %42, i8* %46
%47 = load i32, i32* %4
%48 = load i32, i32* @NIS_DESTROY_ACC
%49 = and i32 %47, %48
%50 = icmp ne i32 %49, 0
%51 = zext i1 %50 to i64
%52 = select i1 %50, i32 100, i32 45
%53 = trunc i32 %52 to i8
%54 = load i32, i32* %5
%55 = add nsw i32 %54, 3
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 %56
store i8 %53, i8* %57
%58 = load i32, i32* %4
%59 = lshr i32 %58, 8
store i32 %59, i32* %4
br label %8
60: ; preds = %8
%61 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%62 = load i32, i32* @stdout
%63 = call i32 @fputs(i8* %61, i32 %62)
ret void
}

LLVM IR (-O2):
@NIS_READ_ACC = global i32 0
@NIS_MODIFY_ACC = global i32 0
@NIS_CREATE_ACC = global i32 0
@NIS_DESTROY_ACC = global i32 0
@stdout = global i32 0
define void @nis_print_rights(i32 %0) {
%2 = alloca [17 x i8]
%3 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 16
store i8 0, i8* %4
%5 = load i32, i32* @NIS_READ_ACC
%6 = load i32, i32* @NIS_MODIFY_ACC
%7 = load i32, i32* @NIS_CREATE_ACC
%8 = load i32, i32* @NIS_DESTROY_ACC
%9 = and i32 %5, %0
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i8 45, i8 114
%12 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 12
store i8 %11, i8* %12
%13 = and i32 %6, %0
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i8 45, i8 109
%16 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 13
store i8 %15, i8* %16
%17 = and i32 %7, %0
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8 45, i8 99
%20 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 14
store i8 %19, i8* %20
%21 = and i32 %8, %0
%22 = icmp eq i32 %21, 0
%23 = select i1 %22, i8 45, i8 100
%24 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 15
store i8 %23, i8* %24
%25 = lshr i32 %0, 8
%26 = and i32 %5, %25
%27 = icmp eq i32 %26, 0
%28 = select i1 %27, i8 45, i8 114
%29 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 8
store i8 %28, i8* %29
%30 = and i32 %6, %25
%31 = icmp eq i32 %30, 0
%32 = select i1 %31, i8 45, i8 109
%33 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 9
store i8 %32, i8* %33
%34 = and i32 %7, %25
%35 = icmp eq i32 %34, 0
%36 = select i1 %35, i8 45, i8 99
%37 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 10
store i8 %36, i8* %37
%38 = and i32 %8, %25
%39 = icmp eq i32 %38, 0
%40 = select i1 %39, i8 45, i8 100
%41 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 11
store i8 %40, i8* %41
%42 = lshr i32 %0, 16
%43 = and i32 %5, %42
%44 = icmp eq i32 %43, 0
%45 = select i1 %44, i8 45, i8 114
%46 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 4
store i8 %45, i8* %46
%47 = and i32 %6, %42
%48 = icmp eq i32 %47, 0
%49 = select i1 %48, i8 45, i8 109
%50 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 5
store i8 %49, i8* %50
%51 = and i32 %7, %42
%52 = icmp eq i32 %51, 0
%53 = select i1 %52, i8 45, i8 99
%54 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 6
store i8 %53, i8* %54
%55 = and i32 %8, %42
%56 = icmp eq i32 %55, 0
%57 = select i1 %56, i8 45, i8 100
%58 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 7
store i8 %57, i8* %58
%59 = lshr i32 %0, 24
%60 = and i32 %5, %59
%61 = icmp eq i32 %60, 0
%62 = select i1 %61, i8 45, i8 114
store i8 %62, i8* %3
%63 = and i32 %6, %59
%64 = icmp eq i32 %63, 0
%65 = select i1 %64, i8 45, i8 109
%66 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 1
store i8 %65, i8* %66
%67 = and i32 %7, %59
%68 = icmp eq i32 %67, 0
%69 = select i1 %68, i8 45, i8 99
%70 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 2
store i8 %69, i8* %70
%71 = and i32 %8, %59
%72 = icmp eq i32 %71, 0
%73 = select i1 %72, i8 45, i8 100
%74 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 3
store i8 %73, i8* %74
%75 = load i32, i32* @stdout
%76 = call i32 @fputs(i8* %3, i32 %75)
ret void
}