#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 mode_t;

/* Variables and functions */
void str_long_mode(mode_t mode, char *str) {
  if (mode & 1) {
    str[2] = 'x';
  } else {
    str[2] = '-';
  }
  if (mode & 2) {
    str[1] = 'w';
  } else {
    str[1] = '-';
  }
  if (mode & 4) {
    str[0] = 'r';
  } else {
    str[0] = '-';
  }
}


x86 assembly (clang, -O0):
<str_long_mode>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1127 <str_long_mode+0x27>
mov    -0x10(%rbp),%rax
movb   $0x78,0x2(%rax)
jmp    112f <str_long_mode+0x2f>
mov    -0x10(%rbp),%rax
movb   $0x2d,0x2(%rax)
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     114b <str_long_mode+0x4b>
mov    -0x10(%rbp),%rax
movb   $0x77,0x1(%rax)
jmp    1153 <str_long_mode+0x53>
mov    -0x10(%rbp),%rax
movb   $0x2d,0x1(%rax)
mov    -0x4(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     116e <str_long_mode+0x6e>
mov    -0x10(%rbp),%rax
movb   $0x72,(%rax)
jmp    1175 <str_long_mode+0x75>
mov    -0x10(%rbp),%rax
movb   $0x2d,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_long_mode>:
test   $0x1,%dil
mov    $0x2d,%eax
mov    $0x78,%ecx
cmove  %eax,%ecx
mov    %cl,0x2(%rsi)
test   $0x2,%dil
mov    $0x77,%ecx
cmove  %eax,%ecx
mov    %cl,0x1(%rsi)
test   $0x4,%dil
mov    $0x72,%ecx
cmove  %eax,%ecx
mov    %cl,(%rsi)
ret

LLVM IR (-O0):
define void @str_long_mode(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
%6 = and i32 %5, 1
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 2
store i8 120, i8* %10
br label %14
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 2
store i8 45, i8* %13
br label %14
14: ; preds = %11, %8
%15 = load i32, i32* %3
%16 = and i32 %15, 2
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8 119, i8* %20
br label %24
21: ; preds = %14
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i64 1
store i8 45, i8* %23
br label %24
24: ; preds = %21, %18
%25 = load i32, i32* %3
%26 = and i32 %25, 4
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 0
store i8 114, i8* %30
br label %34
31: ; preds = %24
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 0
store i8 45, i8* %33
br label %34
34: ; preds = %31, %28
ret void
}

LLVM IR (-O2):
define void @str_long_mode(i32 %0, i8* nocapture writeonly %1) {
%3 = and i32 %0, 1
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i8 45, i8 120
%6 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %5, i8* %6
%7 = and i32 %0, 2
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i8 45, i8 119
%10 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %9, i8* %10
%11 = and i32 %0, 4
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8 45, i8 114
store i8 %13, i8* %1
ret void
}