#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 */
char *talloc_asprintf(void *, char *, unsigned char);
char *talloc_strdup(void *, char const *);
char *regfi_ace_type2str(void *ctx, unsigned char type) {
  static const char *map[7] = {"ALLOW",     "DENY",      "AUDIT",   "ALARM",
                               "ALLOW CPD", "OBJ ALLOW", "OBJ DENY"};
  if (type < 7)
    return talloc_strdup(ctx, map[type]);
  else
    return talloc_asprintf(ctx, "UNKNOWN (%d)", type);
}


x86 assembly (clang, -O0):
<regfi_ace_type2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x7,%eax
jge    1162 <regfi_ace_type2str+0x42>
mov    -0x10(%rbp),%rdi
movzbl -0x11(%rbp),%eax
mov    %eax,%ecx
lea    0x2ef0(%rip),%rax
mov    (%rax,%rcx,8),%rsi
call   1040 <talloc_strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    117a <regfi_ace_type2str+0x5a>
mov    -0x10(%rbp),%rdi
lea    0xebc(%rip),%rsi
movzbl -0x11(%rbp),%edx
call   1030 <talloc_asprintf@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<regfi_ace_type2str>:
cmp    $0x6,%sil
ja     113d <regfi_ace_type2str+0x1d>
movzbl %sil,%eax
lea    0xecf(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
jmp    1040 <talloc_strdup@plt>
movzbl %sil,%edx
lea    0xefd(%rip),%rsi
jmp    1030 <talloc_asprintf@plt>

LLVM IR (-O0):
@regfi_ace_type2str.map = internal global [7 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i32 0, i32 0)]
@.str = [6 x i8] c"ALLOW\00"
@.str.1 = [5 x i8] c"DENY\00"
@.str.2 = [6 x i8] c"AUDIT\00"
@.str.3 = [6 x i8] c"ALARM\00"
@.str.4 = [10 x i8] c"ALLOW CPD\00"
@.str.5 = [10 x i8] c"OBJ ALLOW\00"
@.str.6 = [9 x i8] c"OBJ DENY\00"
@.str.7 = [13 x i8] c"UNKNOWN (%d)\00"
define i8* @regfi_ace_type2str(i8* %0, i8 zeroext %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
store i8* %0, i8** %4
store i8 %1, i8* %5
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = icmp slt i32 %7, 7
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = load i8, i8* %5
%12 = zext i8 %11 to i64
%13 = getelementptr inbounds [7 x i8*], [7 x i8*]* @regfi_ace_type2str.map, i64 0, i64 %12
%14 = load i8*, i8** %13
%15 = call i8* @talloc_strdup(i8* %10, i8* %14)
store i8* %15, i8** %3
br label %20
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = load i8, i8* %5
%19 = call i8* @talloc_asprintf(i8* %17, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8 zeroext %18)
store i8* %19, i8** %3
br label %20
20: ; preds = %16, %9
%21 = load i8*, i8** %3
ret i8* %21
}

LLVM IR (-O2):
@reltable.regfi_ace_type2str = internal unnamed_addr constant [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.regfi_ace_type2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.regfi_ace_type2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.regfi_ace_type2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.regfi_ace_type2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.regfi_ace_type2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.regfi_ace_type2str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.regfi_ace_type2str to i64)) to i32)]
@.str = [6 x i8] c"ALLOW\00"
@.str.1 = [5 x i8] c"DENY\00"
@.str.2 = [6 x i8] c"AUDIT\00"
@.str.3 = [6 x i8] c"ALARM\00"
@.str.4 = [10 x i8] c"ALLOW CPD\00"
@.str.5 = [10 x i8] c"OBJ ALLOW\00"
@.str.6 = [9 x i8] c"OBJ DENY\00"
@.str.7 = [13 x i8] c"UNKNOWN (%d)\00"
define i8* @regfi_ace_type2str(i8* %0, i8 zeroext %1) {
%3 = icmp ult i8 %1, 7
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = zext i8 %1 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.regfi_ace_type2str to i8*), i64 %6)
%8 = tail call i8* @talloc_strdup(i8* %0, i8* %7)
br label %11
9: ; preds = %2
%10 = tail call i8* @talloc_asprintf(i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8 zeroext %1)
br label %11
11: ; preds = %9, %4
%12 = phi i8* [ %8, %4 ], [ %10, %9 ]
ret i8* %12
}