#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_IFDIR;
int S_IFLNK;
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*/ printf(char *);
void printPermission(struct stat statp) {
  if (statp.st_mode & S_IFDIR) {
    printf("[d");
  } else if (statp.st_mode & S_IFLNK)
    printf("[l");
  else {
    printf("[-");
  }
  if (statp.st_mode & S_IRUSR) {
    printf("r");
  } else {
    printf("-");
  }
  if (statp.st_mode & S_IWUSR) {
    printf("w");
  } else {
    printf("-");
  }
  if (statp.st_mode & S_IXUSR) {
    printf("x");
  } else {
    printf("-");
  }
  if (statp.st_mode & S_IRGRP) {
    printf("r");
  } else {
    printf("-");
  }
  if (statp.st_mode & S_IWGRP) {
    printf("w");
  } else {
    printf("-");
  }
  if (statp.st_mode & S_IXGRP) {
    printf("x");
  } else {
    printf("-");
  }
  if (statp.st_mode & S_IROTH) {
    printf("r");
  } else {
    printf("-");
  }
  if (statp.st_mode & S_IWOTH) {
    printf("w");
  } else {
    printf("-");
  }
  if (statp.st_mode & S_IXOTH) {
    printf("x");
  } else {
    printf("-");
  }
  printf("]");
}


x86 assembly (clang, -O0):
<printPermission>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e63(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1141 <printPermission+0x31>
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
jmp    1178 <printPermission+0x68>
mov    -0x8(%rbp),%eax
mov    0x2e85(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1167 <printPermission+0x57>
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
jmp    1173 <printPermission+0x63>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
jmp    1178 <printPermission+0x68>
mov    -0x8(%rbp),%eax
mov    0x2e1e(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     119e <printPermission+0x8e>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
jmp    11aa <printPermission+0x9a>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    0x2e14(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11d0 <printPermission+0xc0>
lea    0xe45(%rip),%rdi
call   1030 <printf@plt>
jmp    11dc <printPermission+0xcc>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    0x2dfa(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1202 <printPermission+0xf2>
lea    0xe15(%rip),%rdi
call   1030 <printf@plt>
jmp    120e <printPermission+0xfe>
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    0x2d98(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1234 <printPermission+0x124>
lea    0xddf(%rip),%rdi
call   1030 <printf@plt>
jmp    1240 <printPermission+0x130>
lea    0xdcc(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    0x2d8e(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1266 <printPermission+0x156>
lea    0xdaf(%rip),%rdi
call   1030 <printf@plt>
jmp    1272 <printPermission+0x162>
lea    0xd9a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    0x2d44(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1298 <printPermission+0x188>
lea    0xd7f(%rip),%rdi
call   1030 <printf@plt>
jmp    12a4 <printPermission+0x194>
lea    0xd68(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    0x2cfa(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12ca <printPermission+0x1ba>
lea    0xd49(%rip),%rdi
call   1030 <printf@plt>
jmp    12d6 <printPermission+0x1c6>
lea    0xd36(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    0x2cb0(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12fc <printPermission+0x1ec>
lea    0xd19(%rip),%rdi
call   1030 <printf@plt>
jmp    1308 <printPermission+0x1f8>
lea    0xd04(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    0x2cd6(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     132e <printPermission+0x21e>
lea    0xce9(%rip),%rdi
call   1030 <printf@plt>
jmp    133a <printPermission+0x22a>
lea    0xcd2(%rip),%rdi
call   1030 <printf@plt>
lea    0xcce(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printPermission>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%ebx
mov    0x2e57(%rip),%rax
mov    (%rax),%eax
and    %edi,%eax
mov    0x2e94(%rip),%rcx
mov    (%rcx),%ecx
and    %edi,%ecx
lea    0xebf(%rip),%rcx
lea    0xeb5(%rip),%rdx
cmove  %rcx,%rdx
test   %eax,%eax
lea    0xea5(%rip),%rdi
cmove  %rdx,%rdi
call   1040 <printf@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    $0x2d,%r12d
mov    $0x72,%r14d
mov    $0x72,%edi
cmove  %r12d,%edi
call   1030 <putchar@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    $0x77,%r15d
mov    $0x77,%edi
cmove  %r12d,%edi
call   1030 <putchar@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    $0x78,%ebp
mov    $0x78,%edi
cmove  %r12d,%edi
call   1030 <putchar@plt>
mov    0x2de3(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    $0x72,%edi
cmove  %r12d,%edi
call   1030 <putchar@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    $0x77,%edi
cmove  %r12d,%edi
call   1030 <putchar@plt>
mov    0x2dc1(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    $0x78,%edi
cmove  %r12d,%edi
call   1030 <putchar@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
cmove  %r12d,%r14d
mov    %r14d,%edi
call   1030 <putchar@plt>
mov    0x2d61(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
cmove  %r12d,%r15d
mov    %r15d,%edi
call   1030 <putchar@plt>
mov    0x2da2(%rip),%rax
and    (%rax),%ebx
cmove  %r12d,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    $0x5d,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@S_IFDIR = global i32 0
@.str = [3 x i8] c"[d\00"
@S_IFLNK = global i32 0
@.str.1 = [3 x i8] c"[l\00"
@.str.2 = [3 x i8] c"[-\00"
@S_IRUSR = global i32 0
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [2 x i8] c"-\00"
@S_IWUSR = global i32 0
@.str.5 = [2 x i8] c"w\00"
@S_IXUSR = global i32 0
@.str.6 = [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
@.str.7 = [2 x i8] c"]\00"
define void @printPermission(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 = load i32, i32* @S_IFDIR
%7 = and i32 %5, %6
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %22
11: ; preds = %1
%12 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%13 = load i32, i32* %12
%14 = load i32, i32* @S_IFLNK
%15 = and i32 %13, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %21
19: ; preds = %11
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
br label %22
22: ; preds = %21, %9
%23 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%24 = load i32, i32* %23
%25 = load i32, i32* @S_IRUSR
%26 = and i32 %24, %25
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %32
30: ; preds = %22
%31 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
%33 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%34 = load i32, i32* %33
%35 = load i32, i32* @S_IWUSR
%36 = and i32 %34, %35
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %32
%39 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %42
40: ; preds = %32
%41 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %42
42: ; preds = %40, %38
%43 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%44 = load i32, i32* %43
%45 = load i32, i32* @S_IXUSR
%46 = and i32 %44, %45
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %42
%49 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %52
50: ; preds = %42
%51 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %52
52: ; preds = %50, %48
%53 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%54 = load i32, i32* %53
%55 = load i32, i32* @S_IRGRP
%56 = and i32 %54, %55
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %52
%59 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %62
60: ; preds = %52
%61 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60, %58
%63 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%64 = load i32, i32* %63
%65 = load i32, i32* @S_IWGRP
%66 = and i32 %64, %65
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %62
%69 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %72
70: ; preds = %62
%71 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %72
72: ; preds = %70, %68
%73 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%74 = load i32, i32* %73
%75 = load i32, i32* @S_IXGRP
%76 = and i32 %74, %75
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %72
%79 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %82
80: ; preds = %72
%81 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %82
82: ; preds = %80, %78
%83 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%84 = load i32, i32* %83
%85 = load i32, i32* @S_IROTH
%86 = and i32 %84, %85
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %82
%89 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %92
90: ; preds = %82
%91 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %92
92: ; preds = %90, %88
%93 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%94 = load i32, i32* %93
%95 = load i32, i32* @S_IWOTH
%96 = and i32 %94, %95
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %100
98: ; preds = %92
%99 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %102
100: ; preds = %92
%101 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %102
102: ; preds = %100, %98
%103 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%104 = load i32, i32* %103
%105 = load i32, i32* @S_IXOTH
%106 = and i32 %104, %105
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %110
108: ; preds = %102
%109 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %112
110: ; preds = %102
%111 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %112
112: ; preds = %110, %108
%113 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
ret void
}

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