#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 /*<<< orphan*/ buffer;

/* Variables and functions */
unsigned int S_IRGRP;
unsigned int S_IROTH;
unsigned int S_IRUSR;
unsigned int S_IWGRP;
unsigned int S_IWOTH;
unsigned int S_IWUSR;
unsigned int S_IXGRP;
unsigned int S_IXOTH;
unsigned int S_IXUSR;
int /*<<< orphan*/ strncpy(char *, char *, int);
char *pretty_print_mode(unsigned int m) {
  static char buffer[32] = {0};
  strncpy(buffer, "---------", sizeof(buffer));
  if (m & S_IRUSR)
    buffer[0] = 'r';
  if (m & S_IWUSR)
    buffer[1] = 'w';
  if (m & S_IXUSR)
    buffer[2] = 'x';
  if (m & S_IRGRP)
    buffer[3] = 'r';
  if (m & S_IWGRP)
    buffer[4] = 'w';
  if (m & S_IXGRP)
    buffer[5] = 'x';
  if (m & S_IROTH)
    buffer[6] = 'r';
  if (m & S_IWOTH)
    buffer[7] = 'w';
  if (m & S_IXOTH)
    buffer[8] = 'x';
  return buffer;
}


x86 assembly (clang, -O0):
<pretty_print_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0x2f1e(%rip),%rdi
lea    0xed7(%rip),%rsi
mov    $0x20,%edx
call   1030 <strncpy@plt>
mov    -0x4(%rbp),%eax
mov    0x2e6b(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     114f <pretty_print_mode+0x3f>
movb   $0x72,0x2ef1(%rip)
mov    -0x4(%rbp),%eax
mov    0x2e77(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     116b <pretty_print_mode+0x5b>
movb   $0x77,0x2ed6(%rip)
mov    -0x4(%rbp),%eax
mov    0x2e6b(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1187 <pretty_print_mode+0x77>
movb   $0x78,0x2ebb(%rip)
mov    -0x4(%rbp),%eax
mov    0x2e27(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11a3 <pretty_print_mode+0x93>
movb   $0x72,0x2ea0(%rip)
mov    -0x4(%rbp),%eax
mov    0x2e2b(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11bf <pretty_print_mode+0xaf>
movb   $0x77,0x2e85(%rip)
mov    -0x4(%rbp),%eax
mov    0x2dff(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11db <pretty_print_mode+0xcb>
movb   $0x78,0x2e6a(%rip)
mov    -0x4(%rbp),%eax
mov    0x2dcb(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11f7 <pretty_print_mode+0xe7>
movb   $0x72,0x2e4f(%rip)
mov    -0x4(%rbp),%eax
mov    0x2d97(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1213 <pretty_print_mode+0x103>
movb   $0x77,0x2e34(%rip)
mov    -0x4(%rbp),%eax
mov    0x2dcb(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     122f <pretty_print_mode+0x11f>
movb   $0x78,0x2e19(%rip)
lea    0x2e0a(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pretty_print_mode>:
push   %rbx
mov    %edi,%ebx
lea    0x2f26(%rip),%rdi
lea    0xedf(%rip),%rsi
mov    $0x20,%edx
call   1030 <strncpy@plt>
mov    0x2e76(%rip),%rax
test   %ebx,(%rax)
je     113d <pretty_print_mode+0x2d>
movb   $0x72,0x2f03(%rip)
mov    0x2e8c(%rip),%rax
test   %ebx,(%rax)
je     114f <pretty_print_mode+0x3f>
movb   $0x77,0x2ef2(%rip)
mov    0x2e8a(%rip),%rax
test   %ebx,(%rax)
je     1161 <pretty_print_mode+0x51>
movb   $0x78,0x2ee1(%rip)
mov    0x2e50(%rip),%rax
test   %ebx,(%rax)
je     1173 <pretty_print_mode+0x63>
movb   $0x72,0x2ed0(%rip)
mov    0x2e5e(%rip),%rax
test   %ebx,(%rax)
je     1185 <pretty_print_mode+0x75>
movb   $0x77,0x2ebf(%rip)
mov    0x2e3c(%rip),%rax
test   %ebx,(%rax)
je     1197 <pretty_print_mode+0x87>
movb   $0x78,0x2eae(%rip)
mov    0x2e12(%rip),%rax
test   %ebx,(%rax)
je     11a9 <pretty_print_mode+0x99>
movb   $0x72,0x2e9d(%rip)
mov    0x2de8(%rip),%rax
test   %ebx,(%rax)
je     11bb <pretty_print_mode+0xab>
movb   $0x77,0x2e8c(%rip)
mov    0x2e26(%rip),%rax
test   %ebx,(%rax)
je     11cd <pretty_print_mode+0xbd>
movb   $0x78,0x2e7b(%rip)
lea    0x2e6c(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@pretty_print_mode.buffer = internal global [32 x i8] zeroinitializer
@.str = [10 x i8] 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* @pretty_print_mode(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @strncpy(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 32)
%4 = load i32, i32* %2
%5 = load i32, i32* @S_IRUSR
%6 = and i32 %4, %5
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i8 114, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 0)
br label %9
9: ; preds = %8, %1
%10 = load i32, i32* %2
%11 = load i32, i32* @S_IWUSR
%12 = and i32 %10, %11
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9
store i8 119, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 1)
br label %15
15: ; preds = %14, %9
%16 = load i32, i32* %2
%17 = load i32, i32* @S_IXUSR
%18 = and i32 %16, %17
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
store i8 120, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 2)
br label %21
21: ; preds = %20, %15
%22 = load i32, i32* %2
%23 = load i32, i32* @S_IRGRP
%24 = and i32 %22, %23
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21
store i8 114, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 3)
br label %27
27: ; preds = %26, %21
%28 = load i32, i32* %2
%29 = load i32, i32* @S_IWGRP
%30 = and i32 %28, %29
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %27
store i8 119, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 4)
br label %33
33: ; preds = %32, %27
%34 = load i32, i32* %2
%35 = load i32, i32* @S_IXGRP
%36 = and i32 %34, %35
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %33
store i8 120, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 5)
br label %39
39: ; preds = %38, %33
%40 = load i32, i32* %2
%41 = load i32, i32* @S_IROTH
%42 = and i32 %40, %41
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %39
store i8 114, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 6)
br label %45
45: ; preds = %44, %39
%46 = load i32, i32* %2
%47 = load i32, i32* @S_IWOTH
%48 = and i32 %46, %47
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %45
store i8 119, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 7)
br label %51
51: ; preds = %50, %45
%52 = load i32, i32* %2
%53 = load i32, i32* @S_IXOTH
%54 = and i32 %52, %53
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %51
store i8 120, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 8)
br label %57
57: ; preds = %56, %51
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@pretty_print_mode.buffer = internal global [32 x i8] zeroinitializer
@.str = [10 x i8] 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* @pretty_print_mode(i32 %0) {
%2 = tail call i32 @strncpy(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 32)
%3 = load i32, i32* @S_IRUSR
%4 = and i32 %3, %0
%5 = icmp eq i32 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %1
store i8 114, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 0)
br label %7
7: ; preds = %6, %1
%8 = load i32, i32* @S_IWUSR
%9 = and i32 %8, %0
%10 = icmp eq i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %7
store i8 119, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 1)
br label %12
12: ; preds = %11, %7
%13 = load i32, i32* @S_IXUSR
%14 = and i32 %13, %0
%15 = icmp eq i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %12
store i8 120, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 2)
br label %17
17: ; preds = %16, %12
%18 = load i32, i32* @S_IRGRP
%19 = and i32 %18, %0
%20 = icmp eq i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %17
store i8 114, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 3)
br label %22
22: ; preds = %21, %17
%23 = load i32, i32* @S_IWGRP
%24 = and i32 %23, %0
%25 = icmp eq i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %22
store i8 119, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 4)
br label %27
27: ; preds = %26, %22
%28 = load i32, i32* @S_IXGRP
%29 = and i32 %28, %0
%30 = icmp eq i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %27
store i8 120, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 5)
br label %32
32: ; preds = %31, %27
%33 = load i32, i32* @S_IROTH
%34 = and i32 %33, %0
%35 = icmp eq i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %32
store i8 114, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 6)
br label %37
37: ; preds = %36, %32
%38 = load i32, i32* @S_IWOTH
%39 = and i32 %38, %0
%40 = icmp eq i32 %39, 0
br i1 %40, label %42, label %41
41: ; preds = %37
store i8 119, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 7)
br label %42
42: ; preds = %41, %37
%43 = load i32, i32* @S_IXOTH
%44 = and i32 %43, %0
%45 = icmp eq i32 %44, 0
br i1 %45, label %47, label %46
46: ; preds = %42
store i8 120, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 8)
br label %47
47: ; preds = %46, %42
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @pretty_print_mode.buffer, i64 0, i64 0)
}