#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;
scalar_t__ S_ISDIR(int);
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
int /*<<< orphan*/ printf(char *);
void printPermission(mode_t perms) {
  printf(S_ISDIR(perms) ? "d" : "-");
  printf((perms & S_IRUSR) ? "r" : "-");
  printf((perms & S_IWUSR) ? "w" : "-");
  printf((perms & S_IXUSR) ? "x" : "-");
  printf((perms & S_IRGRP) ? "r" : "-");
  printf((perms & S_IWGRP) ? "w" : "-");
  printf((perms & S_IXGRP) ? "x" : "-");
  printf((perms & S_IROTH) ? "r" : "-");
  printf((perms & S_IWOTH) ? "w" : "-");
  printf((perms & S_IXOTH) ? "x" : "-");
}


x86 assembly (clang, -O0):
<printPermission>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <S_ISDIR@plt>
mov    %rax,%rcx
lea    0xec5(%rip),%rdi
lea    0xebc(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2e4d(%rip),%rax
and    (%rax),%ecx
lea    0xe9e(%rip),%rdi
lea    0xe99(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2e4f(%rip),%rax
and    (%rax),%ecx
lea    0xe78(%rip),%rdi
lea    0xe75(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2e39(%rip),%rax
and    (%rax),%ecx
lea    0xe52(%rip),%rdi
lea    0xe51(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2deb(%rip),%rax
and    (%rax),%ecx
lea    0xe2c(%rip),%rdi
lea    0xe27(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2de5(%rip),%rax
and    (%rax),%ecx
lea    0xe06(%rip),%rdi
lea    0xe03(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2daf(%rip),%rax
and    (%rax),%ecx
lea    0xde0(%rip),%rdi
lea    0xddf(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2d71(%rip),%rax
and    (%rax),%ecx
lea    0xdba(%rip),%rdi
lea    0xdb5(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2d33(%rip),%rax
and    (%rax),%ecx
lea    0xd94(%rip),%rdi
lea    0xd91(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
mov    0x2d5d(%rip),%rax
and    (%rax),%ecx
lea    0xd6e(%rip),%rdi
lea    0xd6d(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printPermission>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %edi,%ebx
call   1040 <S_ISDIR@plt>
test   %rax,%rax
lea    0xec8(%rip),%r13
lea    0xebf(%rip),%rdi
cmove  %r13,%rdi
call   1030 <printf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
lea    0xea8(%rip),%r14
mov    %r14,%rdi
cmove  %r13,%rdi
call   1030 <printf@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
lea    0xe8c(%rip),%r15
mov    %r15,%rdi
cmove  %r13,%rdi
call   1030 <printf@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
lea    0xe70(%rip),%r12
mov    %r12,%rdi
cmove  %r13,%rdi
call   1030 <printf@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    %r14,%rdi
cmove  %r13,%rdi
call   1030 <printf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    %r15,%rdi
cmove  %r13,%rdi
call   1030 <printf@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    %r12,%rdi
cmove  %r13,%rdi
call   1030 <printf@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
cmove  %r13,%r14
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x2d91(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
cmove  %r13,%r15
mov    %r15,%rdi
call   1030 <printf@plt>
mov    0x2dca(%rip),%rax
and    (%rax),%ebx
cmove  %r13,%r12
mov    %r12,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"d\00"
@.str.1 = [2 x i8] c"-\00"
@S_IRUSR = global i32 0
@.str.2 = [2 x i8] c"r\00"
@S_IWUSR = global i32 0
@.str.3 = [2 x i8] c"w\00"
@S_IXUSR = global i32 0
@.str.4 = [2 x i8] c"x\00"
@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 @printPermission(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i64 @S_ISDIR(i32 %3)
%5 = icmp ne i64 %4, 0
%6 = zext i1 %5 to i64
%7 = select i1 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%8 = call i32 @printf(i8* %7)
%9 = load i32, i32* %2
%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, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%15 = call i32 @printf(i8* %14)
%16 = load i32, i32* %2
%17 = load i32, i32* @S_IWUSR
%18 = and i32 %16, %17
%19 = icmp ne i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%22 = call i32 @printf(i8* %21)
%23 = load i32, i32* %2
%24 = load i32, i32* @S_IXUSR
%25 = and i32 %23, %24
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%29 = call i32 @printf(i8* %28)
%30 = load i32, i32* %2
%31 = load i32, i32* @S_IRGRP
%32 = and i32 %30, %31
%33 = icmp ne i32 %32, 0
%34 = zext i1 %33 to i64
%35 = select i1 %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%36 = call i32 @printf(i8* %35)
%37 = load i32, i32* %2
%38 = load i32, i32* @S_IWGRP
%39 = and i32 %37, %38
%40 = icmp ne i32 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%43 = call i32 @printf(i8* %42)
%44 = load i32, i32* %2
%45 = load i32, i32* @S_IXGRP
%46 = and i32 %44, %45
%47 = icmp ne i32 %46, 0
%48 = zext i1 %47 to i64
%49 = select i1 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%50 = call i32 @printf(i8* %49)
%51 = load i32, i32* %2
%52 = load i32, i32* @S_IROTH
%53 = and i32 %51, %52
%54 = icmp ne i32 %53, 0
%55 = zext i1 %54 to i64
%56 = select i1 %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%57 = call i32 @printf(i8* %56)
%58 = load i32, i32* %2
%59 = load i32, i32* @S_IWOTH
%60 = and i32 %58, %59
%61 = icmp ne i32 %60, 0
%62 = zext i1 %61 to i64
%63 = select i1 %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%64 = call i32 @printf(i8* %63)
%65 = load i32, i32* %2
%66 = load i32, i32* @S_IXOTH
%67 = and i32 %65, %66
%68 = icmp ne i32 %67, 0
%69 = zext i1 %68 to i64
%70 = select i1 %68, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%71 = call i32 @printf(i8* %70)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"d\00"
@.str.1 = [2 x i8] c"-\00"
@S_IRUSR = global i32 0
@.str.2 = [2 x i8] c"r\00"
@S_IWUSR = global i32 0
@.str.3 = [2 x i8] c"w\00"
@S_IXUSR = global i32 0
@.str.4 = [2 x i8] c"x\00"
@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 @printPermission(i32 %0) {
%2 = tail call i64 @S_ISDIR(i32 %0)
%3 = icmp eq i64 %2, 0
%4 = select i1 %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%5 = tail call i32 @printf(i8* dereferenceable(1) %4)
%6 = load i32, i32* @S_IRUSR
%7 = and i32 %6, %0
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%10 = tail call i32 @printf(i8* dereferenceable(1) %9)
%11 = load i32, i32* @S_IWUSR
%12 = and i32 %11, %0
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%15 = tail call i32 @printf(i8* dereferenceable(1) %14)
%16 = load i32, i32* @S_IXUSR
%17 = and i32 %16, %0
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%20 = tail call i32 @printf(i8* dereferenceable(1) %19)
%21 = load i32, i32* @S_IRGRP
%22 = and i32 %21, %0
%23 = icmp eq i32 %22, 0
%24 = select i1 %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%25 = tail call i32 @printf(i8* dereferenceable(1) %24)
%26 = load i32, i32* @S_IWGRP
%27 = and i32 %26, %0
%28 = icmp eq i32 %27, 0
%29 = select i1 %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%30 = tail call i32 @printf(i8* dereferenceable(1) %29)
%31 = load i32, i32* @S_IXGRP
%32 = and i32 %31, %0
%33 = icmp eq i32 %32, 0
%34 = select i1 %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%35 = tail call i32 @printf(i8* dereferenceable(1) %34)
%36 = load i32, i32* @S_IROTH
%37 = and i32 %36, %0
%38 = icmp eq i32 %37, 0
%39 = select i1 %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%40 = tail call i32 @printf(i8* dereferenceable(1) %39)
%41 = load i32, i32* @S_IWOTH
%42 = and i32 %41, %0
%43 = icmp eq i32 %42, 0
%44 = select i1 %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%45 = tail call i32 @printf(i8* dereferenceable(1) %44)
%46 = load i32, i32* @S_IXOTH
%47 = and i32 %46, %0
%48 = icmp eq i32 %47, 0
%49 = select i1 %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
%50 = tail call i32 @printf(i8* dereferenceable(1) %49)
ret void
}