#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 */
struct stat {
  int st_mode;
};

/* 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 *);
int _print_permission_info(struct stat file_stat) {
  printf((S_ISDIR(file_stat.st_mode)) ? "d" : "-");
  printf((file_stat.st_mode & S_IRUSR) ? "r" : "-");
  printf((file_stat.st_mode & S_IWUSR) ? "w" : "-");
  printf((file_stat.st_mode & S_IXUSR) ? "x" : "-");
  printf((file_stat.st_mode & S_IRGRP) ? "r" : "-");
  printf((file_stat.st_mode & S_IWGRP) ? "w" : "-");
  printf((file_stat.st_mode & S_IXGRP) ? "x" : "-");
  printf((file_stat.st_mode & S_IROTH) ? "r" : "-");
  printf((file_stat.st_mode & S_IWOTH) ? "w" : "-");
  printf((file_stat.st_mode & S_IXOTH) ? "x" : "-");
  return 0;
}


x86 assembly (clang, -O0):
<_print_permission_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%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    -0x8(%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    -0x8(%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    -0x8(%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    -0x8(%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    -0x8(%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    -0x8(%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    -0x8(%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    -0x8(%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    -0x8(%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>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_print_permission_info>:
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
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.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 i32 @_print_permission_info(i32 %0) {
%2 = alloca %struct.stat
%3 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
store i32 %0, i32* %3
%4 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%5 = load i32, i32* %4
%6 = call i64 @S_ISDIR(i32 %5)
%7 = icmp ne i64 %6, 0
%8 = zext i1 %7 to i64
%9 = select i1 %7, 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)
%10 = call i32 @printf(i8* %9)
%11 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%12 = load i32, i32* %11
%13 = load i32, i32* @S_IRUSR
%14 = and i32 %12, %13
%15 = icmp ne i32 %14, 0
%16 = zext i1 %15 to i64
%17 = select i1 %15, 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)
%18 = call i32 @printf(i8* %17)
%19 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%20 = load i32, i32* %19
%21 = load i32, i32* @S_IWUSR
%22 = and i32 %20, %21
%23 = icmp ne i32 %22, 0
%24 = zext i1 %23 to i64
%25 = select i1 %23, 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)
%26 = call i32 @printf(i8* %25)
%27 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%28 = load i32, i32* %27
%29 = load i32, i32* @S_IXUSR
%30 = and i32 %28, %29
%31 = icmp ne i32 %30, 0
%32 = zext i1 %31 to i64
%33 = select i1 %31, 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)
%34 = call i32 @printf(i8* %33)
%35 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%36 = load i32, i32* %35
%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, 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)
%42 = call i32 @printf(i8* %41)
%43 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%44 = load i32, i32* %43
%45 = load i32, i32* @S_IWGRP
%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.3, 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 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%52 = load i32, i32* %51
%53 = load i32, i32* @S_IXGRP
%54 = and i32 %52, %53
%55 = icmp ne i32 %54, 0
%56 = zext i1 %55 to i64
%57 = select i1 %55, 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)
%58 = call i32 @printf(i8* %57)
%59 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%60 = load i32, i32* %59
%61 = load i32, i32* @S_IROTH
%62 = and i32 %60, %61
%63 = icmp ne i32 %62, 0
%64 = zext i1 %63 to i64
%65 = select i1 %63, 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)
%66 = call i32 @printf(i8* %65)
%67 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%68 = load i32, i32* %67
%69 = load i32, i32* @S_IWOTH
%70 = and i32 %68, %69
%71 = icmp ne i32 %70, 0
%72 = zext i1 %71 to i64
%73 = select i1 %71, 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)
%74 = call i32 @printf(i8* %73)
%75 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%76 = load i32, i32* %75
%77 = load i32, i32* @S_IXOTH
%78 = and i32 %76, %77
%79 = icmp ne i32 %78, 0
%80 = zext i1 %79 to i64
%81 = select i1 %79, 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)
%82 = call i32 @printf(i8* %81)
ret i32 0
}

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 i32 @_print_permission_info(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 i32 0
}