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

/* Variables and functions */
char *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
char *gen_file_perm_string(uint16_t x) {
  char *perm = malloc(10);
  strcpy(perm, "---------");
  if (x & 0x4000)
    perm[0] = 'd';
  if (x & 0x0100)
    perm[1] = 'r';
  if (x & 0x0080)
    perm[2] = 'w';
  if (x & 0x0040)
    perm[3] = 'x';
  if (x & 0x0020)
    perm[4] = 'r';
  if (x & 0x0010)
    perm[5] = 'w';
  if (x & 0x0008)
    perm[6] = 'x';
  if (x & 0x0004)
    perm[7] = 'r';
  if (x & 0x0002)
    perm[8] = 'w';
  if (x & 0x0001)
    perm[9] = 'x';
  return perm;
}


x86 assembly (clang, -O0):
<gen_file_perm_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0xa,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
je     1161 <gen_file_perm_string+0x41>
mov    -0x10(%rbp),%rax
movb   $0x64,(%rax)
mov    -0x4(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
je     117a <gen_file_perm_string+0x5a>
mov    -0x10(%rbp),%rax
movb   $0x72,0x1(%rax)
mov    -0x4(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1193 <gen_file_perm_string+0x73>
mov    -0x10(%rbp),%rax
movb   $0x77,0x2(%rax)
mov    -0x4(%rbp),%eax
and    $0x40,%eax
cmp    $0x0,%eax
je     11aa <gen_file_perm_string+0x8a>
mov    -0x10(%rbp),%rax
movb   $0x78,0x3(%rax)
mov    -0x4(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     11c1 <gen_file_perm_string+0xa1>
mov    -0x10(%rbp),%rax
movb   $0x72,0x4(%rax)
mov    -0x4(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     11d8 <gen_file_perm_string+0xb8>
mov    -0x10(%rbp),%rax
movb   $0x77,0x5(%rax)
mov    -0x4(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11ef <gen_file_perm_string+0xcf>
mov    -0x10(%rbp),%rax
movb   $0x78,0x6(%rax)
mov    -0x4(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1206 <gen_file_perm_string+0xe6>
mov    -0x10(%rbp),%rax
movb   $0x72,0x7(%rax)
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     121d <gen_file_perm_string+0xfd>
mov    -0x10(%rbp),%rax
movb   $0x77,0x8(%rax)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1234 <gen_file_perm_string+0x114>
mov    -0x10(%rbp),%rax
movb   $0x78,0x9(%rax)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_file_perm_string>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0xa,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xec7(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
test   $0x4000,%ebp
jne    118f <gen_file_perm_string+0x6f>
test   $0x100,%ebp
jne    119a <gen_file_perm_string+0x7a>
test   $0x80,%bpl
jne    11a4 <gen_file_perm_string+0x84>
test   $0x40,%bpl
jne    11ae <gen_file_perm_string+0x8e>
test   $0x20,%bpl
jne    11b8 <gen_file_perm_string+0x98>
test   $0x10,%bpl
jne    11c2 <gen_file_perm_string+0xa2>
test   $0x8,%bpl
jne    11cc <gen_file_perm_string+0xac>
test   $0x4,%bpl
jne    11d6 <gen_file_perm_string+0xb6>
test   $0x2,%bpl
jne    11e0 <gen_file_perm_string+0xc0>
test   $0x1,%bpl
je     1185 <gen_file_perm_string+0x65>
movb   $0x78,0x9(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
movb   $0x64,(%rbx)
test   $0x100,%ebp
je     1151 <gen_file_perm_string+0x31>
movb   $0x72,0x1(%rbx)
test   $0x80,%bpl
je     1157 <gen_file_perm_string+0x37>
movb   $0x77,0x2(%rbx)
test   $0x40,%bpl
je     115d <gen_file_perm_string+0x3d>
movb   $0x78,0x3(%rbx)
test   $0x20,%bpl
je     1163 <gen_file_perm_string+0x43>
movb   $0x72,0x4(%rbx)
test   $0x10,%bpl
je     1169 <gen_file_perm_string+0x49>
movb   $0x77,0x5(%rbx)
test   $0x8,%bpl
je     116f <gen_file_perm_string+0x4f>
movb   $0x78,0x6(%rbx)
test   $0x4,%bpl
je     1175 <gen_file_perm_string+0x55>
movb   $0x72,0x7(%rbx)
test   $0x2,%bpl
je     117b <gen_file_perm_string+0x5b>
movb   $0x77,0x8(%rbx)
test   $0x1,%bpl
jne    1181 <gen_file_perm_string+0x61>
jmp    1185 <gen_file_perm_string+0x65>

LLVM IR (-O0):
@.str = [10 x i8] c"---------\00"
define i8* @gen_file_perm_string(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = call i8* @malloc(i32 10)
store i8* %4, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = and i32 %7, 16384
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 0
store i8 100, i8* %12
br label %13
13: ; preds = %10, %1
%14 = load i32, i32* %2
%15 = and i32 %14, 256
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 1
store i8 114, i8* %19
br label %20
20: ; preds = %17, %13
%21 = load i32, i32* %2
%22 = and i32 %21, 128
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 2
store i8 119, i8* %26
br label %27
27: ; preds = %24, %20
%28 = load i32, i32* %2
%29 = and i32 %28, 64
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 3
store i8 120, i8* %33
br label %34
34: ; preds = %31, %27
%35 = load i32, i32* %2
%36 = and i32 %35, 32
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i8*, i8** %3
%40 = getelementptr inbounds i8, i8* %39, i64 4
store i8 114, i8* %40
br label %41
41: ; preds = %38, %34
%42 = load i32, i32* %2
%43 = and i32 %42, 16
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i64 5
store i8 119, i8* %47
br label %48
48: ; preds = %45, %41
%49 = load i32, i32* %2
%50 = and i32 %49, 8
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load i8*, i8** %3
%54 = getelementptr inbounds i8, i8* %53, i64 6
store i8 120, i8* %54
br label %55
55: ; preds = %52, %48
%56 = load i32, i32* %2
%57 = and i32 %56, 4
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %55
%60 = load i8*, i8** %3
%61 = getelementptr inbounds i8, i8* %60, i64 7
store i8 114, i8* %61
br label %62
62: ; preds = %59, %55
%63 = load i32, i32* %2
%64 = and i32 %63, 2
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %62
%67 = load i8*, i8** %3
%68 = getelementptr inbounds i8, i8* %67, i64 8
store i8 119, i8* %68
br label %69
69: ; preds = %66, %62
%70 = load i32, i32* %2
%71 = and i32 %70, 1
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %69
%74 = load i8*, i8** %3
%75 = getelementptr inbounds i8, i8* %74, i64 9
store i8 120, i8* %75
br label %76
76: ; preds = %73, %69
%77 = load i8*, i8** %3
ret i8* %77
}

LLVM IR (-O2):
@.str = [10 x i8] c"---------\00"
define i8* @gen_file_perm_string(i32 %0) {
%2 = tail call dereferenceable_or_null(10) i8* @malloc(i32 10)
%3 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%4 = and i32 %0, 16384
%5 = icmp eq i32 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %1
store i8 100, i8* %2
br label %7
7: ; preds = %6, %1
%8 = and i32 %0, 256
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %2, i64 1
store i8 114, i8* %11
br label %12
12: ; preds = %10, %7
%13 = and i32 %0, 128
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %2, i64 2
store i8 119, i8* %16
br label %17
17: ; preds = %15, %12
%18 = and i32 %0, 64
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = getelementptr inbounds i8, i8* %2, i64 3
store i8 120, i8* %21
br label %22
22: ; preds = %20, %17
%23 = and i32 %0, 32
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = getelementptr inbounds i8, i8* %2, i64 4
store i8 114, i8* %26
br label %27
27: ; preds = %25, %22
%28 = and i32 %0, 16
%29 = icmp eq i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = getelementptr inbounds i8, i8* %2, i64 5
store i8 119, i8* %31
br label %32
32: ; preds = %30, %27
%33 = and i32 %0, 8
%34 = icmp eq i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = getelementptr inbounds i8, i8* %2, i64 6
store i8 120, i8* %36
br label %37
37: ; preds = %35, %32
%38 = and i32 %0, 4
%39 = icmp eq i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = getelementptr inbounds i8, i8* %2, i64 7
store i8 114, i8* %41
br label %42
42: ; preds = %40, %37
%43 = and i32 %0, 2
%44 = icmp eq i32 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %42
%46 = getelementptr inbounds i8, i8* %2, i64 8
store i8 119, i8* %46
br label %47
47: ; preds = %45, %42
%48 = and i32 %0, 1
%49 = icmp eq i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %47
%51 = getelementptr inbounds i8, i8* %2, i64 9
store i8 120, i8* %51
br label %52
52: ; preds = %50, %47
ret i8* %2
}