#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*/ errno;
char *strerror(int /*<<< orphan*/);
const char *kas_strerror(int err) {
  const char *ret = "Unknown error";
  switch (err) {
  case -1:
    ret = "Generic error; please file a bug report";
    break;
  case -2:
    if (errno != 0) {
      ret = strerror(errno);
    } else {
      ret = "I/O error with errno unset. Please file a bug report";
    }
    break;
  case -3:
    ret = "Bad open mode; must be \"r\", \"w\", or \"a\"";
    break;
  case -15:
    ret = "Unknow flags specified. Only KAS_READ_ALL or 0 allowed.";
    break;
  case -4:
    ret = "Out of memory";
    break;
  case -5:
    ret = "File not in KAS format";
    break;
  case -6:
    ret = "File format version is too old. Please upgrade using "
          "'kas upgrade <filename>'";
    break;
  case -7:
    ret = "File format version is too new. Please upgrade your "
          "kastore library version";
    break;
  case -8:
    ret = "Unknown data type";
    break;
  case -10:
    ret = "Duplicate key provided";
    break;
  case -11:
    ret = "Key not found";
    break;
  case -9:
    ret = "Keys cannot be empty";
    break;
  case -12:
    ret = "Cannot perform the requested operation in the current mode";
    break;
  case -13:
    ret = "Mismatch between requested and stored types for array";
    break;
  case -14:
    ret = "End of file";
    break;
  }
  return ret;
}


x86 assembly (clang, -O0):
<kas_strerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xf1a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xe,%eax
ja     1261 <kas_strerror+0x151>
mov    -0x18(%rbp),%rax
lea    0xeba(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef4(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1261 <kas_strerror+0x151>
mov    0x2e7a(%rip),%rax
cmpl   $0x0,(%rax)
je     1186 <kas_strerror+0x76>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1030 <strerror@plt>
mov    %rax,-0x10(%rbp)
jmp    1191 <kas_strerror+0x81>
lea    0xee5(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1261 <kas_strerror+0x151>
lea    0xf0a(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1261 <kas_strerror+0x151>
lea    0xf22(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1261 <kas_strerror+0x151>
lea    0xf4a(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1261 <kas_strerror+0x151>
lea    0xf48(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1261 <kas_strerror+0x151>
lea    0xf4f(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1261 <kas_strerror+0x151>
lea    0xf8d(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1261 <kas_strerror+0x151>
lea    0xfc9(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1261 <kas_strerror+0x151>
lea    0xfcb(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1261 <kas_strerror+0x151>
lea    0xfd2(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1261 <kas_strerror+0x151>
lea    0xfd0(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1261 <kas_strerror+0x151>
lea    0xfd5(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1261 <kas_strerror+0x151>
lea    0x1000(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1261 <kas_strerror+0x151>
lea    0x1026(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kas_strerror>:
add    $0xf,%edi
cmp    $0xe,%edi
ja     1130 <kas_strerror+0x20>
lea    0xee1(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xfa0(%rip),%rax
ret
lea    0xf05(%rip),%rax
ret
lea    0x1144(%rip),%rax
ret
lea    0x1106(%rip),%rax
ret
lea    0x10c3(%rip),%rax
ret
lea    0x1098(%rip),%rax
ret
lea    0x1079(%rip),%rax
ret
lea    0x1096(%rip),%rax
ret
lea    0x1057(%rip),%rax
ret
lea    0x1003(%rip),%rax
ret
lea    0xfad(%rip),%rax
ret
lea    0xf8e(%rip),%rax
ret
lea    0xf78(%rip),%rax
ret
lea    0xf10(%rip),%rax
ret
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
test   %edi,%edi
je     11b2 <kas_strerror+0xa2>
jmp    1030 <strerror@plt>
lea    0xe99(%rip),%rax
ret
lea    0xeb9(%rip),%rax
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Unknown error\00"
@.str.1 = [40 x i8] c"Generic error; please file a bug report\00"
@errno = global i32 0
@.str.2 = [53 x i8] c"I/O error with errno unset. Please file a bug report\00"
@.str.3 = [40 x i8] c"Bad open mode; must be \22r\22, \22w\22, or \22a\22\00"
@.str.4 = [56 x i8] c"Unknow flags specified. Only KAS_READ_ALL or 0 allowed.\00"
@.str.5 = [14 x i8] c"Out of memory\00"
@.str.6 = [23 x i8] c"File not in KAS format\00"
@.str.7 = [78 x i8] c"File format version is too old. Please upgrade using 'kas upgrade <filename>'\00"
@.str.8 = [76 x i8] c"File format version is too new. Please upgrade your kastore library version\00"
@.str.9 = [18 x i8] c"Unknown data type\00"
@.str.10 = [23 x i8] c"Duplicate key provided\00"
@.str.11 = [14 x i8] c"Key not found\00"
@.str.12 = [21 x i8] c"Keys cannot be empty\00"
@.str.13 = [59 x i8] c"Cannot perform the requested operation in the current mode\00"
@.str.14 = [54 x i8] c"Mismatch between requested and stored types for array\00"
@.str.15 = [12 x i8] c"End of file\00"
define i8* @kas_strerror(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = load i32, i32* %2
switch i32 %4, label %27 [
i32 -1, label %5
i32 -2, label %6
i32 -3, label %14
i32 -15, label %15
i32 -4, label %16
i32 -5, label %17
i32 -6, label %18
i32 -7, label %19
i32 -8, label %20
i32 -10, label %21
i32 -11, label %22
i32 -9, label %23
i32 -12, label %24
i32 -13, label %25
i32 -14, label %26
]
5: ; preds = %1
store i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %27
6: ; preds = %1
%7 = load i32, i32* @errno
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* @errno
%11 = call i8* @strerror(i32 %10)
store i8* %11, i8** %3
br label %13
12: ; preds = %6
store i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %13
13: ; preds = %12, %9
br label %27
14: ; preds = %1
store i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %27
15: ; preds = %1
store i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %27
16: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %27
17: ; preds = %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %27
18: ; preds = %1
store i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %27
19: ; preds = %1
store i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %27
20: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %27
21: ; preds = %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i8** %3
br label %27
22: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8** %3
br label %27
23: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i8** %3
br label %27
24: ; preds = %1
store i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.13, i64 0, i64 0), i8** %3
br label %27
25: ; preds = %1
store i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.14, i64 0, i64 0), i8** %3
br label %27
26: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i8** %3
br label %27
27: ; preds = %1, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %5
%28 = load i8*, i8** %3
ret i8* %28
}

LLVM IR (-O2):
@.str = [14 x i8] c"Unknown error\00"
@.str.1 = [40 x i8] c"Generic error; please file a bug report\00"
@errno = global i32 0
@.str.2 = [53 x i8] c"I/O error with errno unset. Please file a bug report\00"
@.str.3 = [40 x i8] c"Bad open mode; must be \22r\22, \22w\22, or \22a\22\00"
@.str.4 = [56 x i8] c"Unknow flags specified. Only KAS_READ_ALL or 0 allowed.\00"
@.str.5 = [14 x i8] c"Out of memory\00"
@.str.6 = [23 x i8] c"File not in KAS format\00"
@.str.7 = [78 x i8] c"File format version is too old. Please upgrade using 'kas upgrade <filename>'\00"
@.str.8 = [76 x i8] c"File format version is too new. Please upgrade your kastore library version\00"
@.str.9 = [18 x i8] c"Unknown data type\00"
@.str.10 = [23 x i8] c"Duplicate key provided\00"
@.str.11 = [14 x i8] c"Key not found\00"
@.str.12 = [21 x i8] c"Keys cannot be empty\00"
@.str.13 = [59 x i8] c"Cannot perform the requested operation in the current mode\00"
@.str.14 = [54 x i8] c"Mismatch between requested and stored types for array\00"
@.str.15 = [12 x i8] c"End of file\00"
define i8* @kas_strerror(i32 %0) {
switch i32 %0, label %21 [
i32 -1, label %2
i32 -2, label %3
i32 -3, label %8
i32 -15, label %9
i32 -4, label %10
i32 -5, label %11
i32 -6, label %12
i32 -7, label %13
i32 -8, label %14
i32 -10, label %15
i32 -11, label %16
i32 -9, label %17
i32 -12, label %18
i32 -13, label %19
i32 -14, label %20
]
2: ; preds = %1
br label %21
3: ; preds = %1
%4 = load i32, i32* @errno
%5 = icmp eq i32 %4, 0
br i1 %5, label %21, label %6
6: ; preds = %3
%7 = tail call i8* @strerror(i32 %4)
br label %21
8: ; preds = %1
br label %21
9: ; preds = %1
br label %21
10: ; preds = %1
br label %21
11: ; preds = %1
br label %21
12: ; preds = %1
br label %21
13: ; preds = %1
br label %21
14: ; preds = %1
br label %21
15: ; preds = %1
br label %21
16: ; preds = %1
br label %21
17: ; preds = %1
br label %21
18: ; preds = %1
br label %21
19: ; preds = %1
br label %21
20: ; preds = %1
br label %21
21: ; preds = %3, %6, %1, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %2
%22 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), %20 ], [ getelementptr inbounds ([54 x i8], [54 x i8]* @.str.14, i64 0, i64 0), %19 ], [ getelementptr inbounds ([59 x i8], [59 x i8]* @.str.13, i64 0, i64 0), %18 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), %17 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), %16 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), %15 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), %14 ], [ getelementptr inbounds ([76 x i8], [76 x i8]* @.str.8, i64 0, i64 0), %13 ], [ getelementptr inbounds ([78 x i8], [78 x i8]* @.str.7, i64 0, i64 0), %12 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), %11 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), %10 ], [ getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), %9 ], [ getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), %8 ], [ %7, %6 ], [ getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), %3 ]
ret i8* %22
}