#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 */

/* Variables and functions */
int S_IROTH;
int S_IWOTH;
int S_IXOTH;
int /*<<< orphan*/ putchar(char);
void print_access(int flags) {
  putchar(flags & S_IROTH ? 'r' : '-');
  putchar(flags & S_IWOTH ? 'w' : '-');
  putchar(flags & S_IXOTH ? 'x' : '-');
}


x86 assembly (clang, -O0):
<print_access>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    0x2eb3(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x72,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%edx
mov    0x2e7f(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x77,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%edx
mov    0x2e7b(%rip),%rax
and    (%rax),%edx
mov    $0x2d,%eax
mov    $0x78,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_access>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2ebc(%rip),%rax
mov    (%rax),%eax
and    %edi,%eax
mov    $0x2d,%ebp
mov    $0x72,%edi
cmove  %ebp,%edi
call   1030 <putchar@plt>
mov    0x2e8f(%rip),%rax
mov    (%rax),%eax
and    %ebx,%eax
mov    $0x77,%edi
cmove  %ebp,%edi
call   1030 <putchar@plt>
mov    0x2e97(%rip),%rax
and    (%rax),%ebx
mov    $0x78,%edi
cmove  %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
define void @print_access(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @S_IROTH
%5 = and i32 %3, %4
%6 = icmp ne i32 %5, 0
%7 = zext i1 %6 to i64
%8 = select i1 %6, i32 114, i32 45
%9 = trunc i32 %8 to i8
%10 = call i32 @putchar(i8 signext %9)
%11 = load i32, i32* %2
%12 = load i32, i32* @S_IWOTH
%13 = and i32 %11, %12
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i64
%16 = select i1 %14, i32 119, i32 45
%17 = trunc i32 %16 to i8
%18 = call i32 @putchar(i8 signext %17)
%19 = load i32, i32* %2
%20 = load i32, i32* @S_IXOTH
%21 = and i32 %19, %20
%22 = icmp ne i32 %21, 0
%23 = zext i1 %22 to i64
%24 = select i1 %22, i32 120, i32 45
%25 = trunc i32 %24 to i8
%26 = call i32 @putchar(i8 signext %25)
ret void
}

LLVM IR (-O2):
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
define void @print_access(i32 %0) {
%2 = load i32, i32* @S_IROTH
%3 = and i32 %2, %0
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i8 45, i8 114
%6 = tail call i32 @putchar(i8 signext %5)
%7 = load i32, i32* @S_IWOTH
%8 = and i32 %7, %0
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8 45, i8 119
%11 = tail call i32 @putchar(i8 signext %10)
%12 = load i32, i32* @S_IXOTH
%13 = and i32 %12, %0
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i8 45, i8 120
%16 = tail call i32 @putchar(i8 signext %15)
ret void
}