#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;
};
typedef int mode_t;

/* Variables and functions */
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 *, char *);
void print_perm_string(struct stat file_stat) {
  char perm_string[10] = "---------";
  mode_t mode = file_stat.st_mode;
  (mode & S_IRUSR) ? (perm_string[0] = 'r') : (perm_string[0] = '-');
  (mode & S_IWUSR) ? (perm_string[1] = 'w') : (perm_string[1] = '-');
  (mode & S_IXUSR) ? (perm_string[2] = 'x') : (perm_string[2] = '-');
  (mode & S_IRGRP) ? (perm_string[3] = 'r') : (perm_string[3] = '-');
  (mode & S_IWGRP) ? (perm_string[4] = 'w') : (perm_string[4] = '-');
  (mode & S_IXGRP) ? (perm_string[5] = 'x') : (perm_string[5] = '-');
  (mode & S_IROTH) ? (perm_string[6] = 'r') : (perm_string[6] = '-');
  (mode & S_IWOTH) ? (perm_string[7] = 'w') : (perm_string[7] = '-');
  (mode & S_IXOTH) ? (perm_string[8] = 'x') : (perm_string[8] = '-');
  printf("%s\n", perm_string);
}


x86 assembly (clang, -O0):
<print_perm_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x12(%rbp)
mov    0xedb(%rip),%ax
mov    %ax,-0xa(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e67(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1155 <print_perm_string+0x45>
movb   $0x72,-0x12(%rbp)
jmp    1159 <print_perm_string+0x49>
movb   $0x2d,-0x12(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e6d(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1177 <print_perm_string+0x67>
movb   $0x77,-0x11(%rbp)
jmp    117b <print_perm_string+0x6b>
movb   $0x2d,-0x11(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e5b(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1199 <print_perm_string+0x89>
movb   $0x78,-0x10(%rbp)
jmp    119d <print_perm_string+0x8d>
movb   $0x2d,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e11(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11bb <print_perm_string+0xab>
movb   $0x72,-0xf(%rbp)
jmp    11bf <print_perm_string+0xaf>
movb   $0x2d,-0xf(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e0f(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11dd <print_perm_string+0xcd>
movb   $0x77,-0xe(%rbp)
jmp    11e1 <print_perm_string+0xd1>
movb   $0x2d,-0xe(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2ddd(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11ff <print_perm_string+0xef>
movb   $0x78,-0xd(%rbp)
jmp    1203 <print_perm_string+0xf3>
movb   $0x2d,-0xd(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2da3(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1221 <print_perm_string+0x111>
movb   $0x72,-0xc(%rbp)
jmp    1225 <print_perm_string+0x115>
movb   $0x2d,-0xc(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2d69(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1243 <print_perm_string+0x133>
movb   $0x77,-0xb(%rbp)
jmp    1247 <print_perm_string+0x137>
movb   $0x2d,-0xb(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2d97(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1265 <print_perm_string+0x155>
movb   $0x78,-0xa(%rbp)
jmp    1269 <print_perm_string+0x159>
movb   $0x2d,-0xa(%rbp)
lea    -0x12(%rbp),%rsi
lea    0xd96(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_perm_string>:
sub    $0x18,%rsp
movabs $0x2d2d2d2d2d2d2d2d,%rax
2d 2d 2d
mov    %rax,0x8(%rsp)
movw   $0x2d,0x10(%rsp)
mov    0x2e77(%rip),%rax
mov    (%rax),%eax
and    %edi,%eax
mov    $0x2d,%eax
mov    $0x72,%r8d
mov    $0x72,%edx
cmove  %eax,%edx
mov    %dl,0x8(%rsp)
mov    0x2e7d(%rip),%rdx
mov    (%rdx),%edx
and    %edi,%edx
mov    $0x77,%edx
mov    $0x77,%esi
cmove  %eax,%esi
mov    %sil,0x9(%rsp)
mov    0x2e70(%rip),%rsi
mov    (%rsi),%esi
and    %edi,%esi
mov    $0x78,%esi
cmove  %eax,%esi
mov    %sil,0xa(%rsp)
mov    0x2e30(%rip),%rsi
mov    (%rsi),%esi
and    %edi,%esi
mov    $0x72,%esi
cmove  %eax,%esi
mov    0x2e3d(%rip),%rcx
mov    (%rcx),%ecx
and    %edi,%ecx
mov    $0x77,%ecx
cmove  %eax,%ecx
mov    %sil,0xb(%rsp)
mov    %cl,0xc(%rsp)
mov    0x2e11(%rip),%rcx
mov    (%rcx),%ecx
and    %edi,%ecx
mov    $0x78,%ecx
cmove  %eax,%ecx
mov    $0x78,%esi
mov    %cl,0xd(%rsp)
mov    0x2ddd(%rip),%rcx
mov    (%rcx),%ecx
and    %edi,%ecx
cmove  %eax,%r8d
mov    0x2db6(%rip),%rcx
mov    (%rcx),%ecx
and    %edi,%ecx
cmove  %eax,%edx
mov    %r8b,0xe(%rsp)
mov    0x2df3(%rip),%rcx
and    (%rcx),%edi
mov    %dl,0xf(%rsp)
cmove  %eax,%esi
mov    %sil,0x10(%rsp)
lea    0xe00(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1030 <printf@plt>
add    $0x18,%rsp
ret

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

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