#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 /*<<< orphan*/ printf(char *);
void print_rights(int mode) {
  if (4 & mode)
    printf("r");
  else
    printf("-");
  if (2 & mode)
    printf("w");
  else
    printf("-");
  if (1 & mode)
    printf("x");
  else
    printf("-");
}


x86 assembly (clang, -O0):
<print_rights>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     113b <print_rights+0x2b>
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
jmp    1147 <print_rights+0x37>
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1167 <print_rights+0x57>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
jmp    1173 <print_rights+0x63>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1193 <print_rights+0x83>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
jmp    119f <print_rights+0x8f>
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_rights>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
test   $0x4,%bl
mov    $0x2d,%ebp
mov    $0x72,%edi
cmove  %ebp,%edi
call   1030 <putchar@plt>
test   $0x2,%bl
mov    $0x77,%edi
cmove  %ebp,%edi
call   1030 <putchar@plt>
test   $0x1,%bl
mov    $0x78,%edi
cmove  %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [2 x i8] c"x\00"
define void @print_rights(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = and i32 4, %3
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %10
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
%11 = load i32, i32* %2
%12 = and i32 2, %11
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %18
16: ; preds = %10
%17 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
%19 = load i32, i32* %2
%20 = and i32 1, %19
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %26
24: ; preds = %18
%25 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %22
ret void
}

LLVM IR (-O2):
define void @print_rights(i32 %0) {
%2 = and i32 %0, 4
%3 = icmp eq i32 %2, 0
%4 = select i1 %3, i32 45, i32 114
%5 = tail call i32 @putchar(i32 %4)
%6 = and i32 %0, 2
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i32 45, i32 119
%9 = tail call i32 @putchar(i32 %8)
%10 = and i32 %0, 1
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i32 45, i32 120
%13 = tail call i32 @putchar(i32 %12)
ret void
}