#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 */
typedef int u_int;

/* Variables and functions */
int S_IRUSR;
int S_IWUSR;
int S_IXUSR;
int /*<<< orphan*/ putchar(char);
void printmode(u_int mode) {
  if (mode & S_IRUSR)
    putchar('r');
  else
    putchar('-');
  if (mode & S_IWUSR)
    putchar('w');
  else
    putchar('-');
  if (mode & S_IXUSR)
    putchar('x');
  else
    putchar('-');
}


x86 assembly (clang, -O0):
<printmode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eab(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     113f <printmode+0x2f>
mov    $0x72,%edi
call   1030 <putchar@plt>
jmp    1149 <printmode+0x39>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%eax
mov    0x2e8d(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     116d <printmode+0x5d>
mov    $0x77,%edi
call   1030 <putchar@plt>
jmp    1177 <printmode+0x67>
mov    $0x2d,%edi
call   1030 <putchar@plt>
mov    -0x4(%rbp),%eax
mov    0x2e67(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     119b <printmode+0x8b>
mov    $0x78,%edi
call   1030 <putchar@plt>
jmp    11a5 <printmode+0x95>
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printmode>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2eb4(%rip),%rax
mov    (%rax),%eax
and    %edi,%eax
mov    $0x2d,%ebp
mov    $0x72,%edi
cmove  %ebp,%edi
call   1030 <putchar@plt>
mov    0x2ea7(%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_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
define void @printmode(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @S_IRUSR
%5 = and i32 %3, %4
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @putchar(i8 signext 114)
br label %11
9: ; preds = %1
%10 = call i32 @putchar(i8 signext 45)
br label %11
11: ; preds = %9, %7
%12 = load i32, i32* %2
%13 = load i32, i32* @S_IWUSR
%14 = and i32 %12, %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 @putchar(i8 signext 119)
br label %20
18: ; preds = %11
%19 = call i32 @putchar(i8 signext 45)
br label %20
20: ; preds = %18, %16
%21 = load i32, i32* %2
%22 = load i32, i32* @S_IXUSR
%23 = and i32 %21, %22
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 @putchar(i8 signext 120)
br label %29
27: ; preds = %20
%28 = call i32 @putchar(i8 signext 45)
br label %29
29: ; preds = %27, %25
ret void
}

LLVM IR (-O2):
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
define void @printmode(i32 %0) {
%2 = load i32, i32* @S_IRUSR
%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_IWUSR
%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_IXUSR
%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
}