#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 -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;
  }
  return ret;
}


x86 assembly (clang, -O0):
<kas_strerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xf12(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xc,%eax
ja     1241 <kas_strerror+0x131>
mov    -0x18(%rbp),%rax
lea    0xeba(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeec(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1241 <kas_strerror+0x131>
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    0xedd(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1241 <kas_strerror+0x131>
lea    0xf02(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1241 <kas_strerror+0x131>
lea    0xf1a(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1241 <kas_strerror+0x131>
lea    0xf18(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1241 <kas_strerror+0x131>
lea    0xf1f(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1241 <kas_strerror+0x131>
lea    0xf5d(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1241 <kas_strerror+0x131>
lea    0xf99(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1241 <kas_strerror+0x131>
lea    0xf9b(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1241 <kas_strerror+0x131>
lea    0xfa2(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1241 <kas_strerror+0x131>
lea    0xfa0(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1241 <kas_strerror+0x131>
lea    0xfa5(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1241 <kas_strerror+0x131>
lea    0xfd0(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kas_strerror>:
add    $0xd,%edi
cmp    $0xc,%edi
ja     1130 <kas_strerror+0x20>
lea    0xee1(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0x10de(%rip),%rax
ret
lea    0xefd(%rip),%rax
ret
lea    0x1093(%rip),%rax
ret
lea    0x1068(%rip),%rax
ret
lea    0x1049(%rip),%rax
ret
lea    0x1066(%rip),%rax
ret
lea    0x1027(%rip),%rax
ret
lea    0xfd3(%rip),%rax
ret
lea    0xf7d(%rip),%rax
ret
lea    0xf5e(%rip),%rax
ret
lea    0xf48(%rip),%rax
ret
lea    0xf18(%rip),%rax
ret
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
test   %edi,%edi
je     11a2 <kas_strerror+0x92>
jmp    1030 <strerror@plt>
lea    0xea1(%rip),%rax
ret
lea    0xec1(%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 = [14 x i8] c"Out of memory\00"
@.str.5 = [23 x i8] c"File not in KAS format\00"
@.str.6 = [78 x i8] c"File format version is too old. Please upgrade using 'kas upgrade <filename>'\00"
@.str.7 = [76 x i8] c"File format version is too new. Please upgrade your kastore library version\00"
@.str.8 = [18 x i8] c"Unknown data type\00"
@.str.9 = [23 x i8] c"Duplicate key provided\00"
@.str.10 = [14 x i8] c"Key not found\00"
@.str.11 = [21 x i8] c"Keys cannot be empty\00"
@.str.12 = [59 x i8] c"Cannot perform the requested operation in the current mode\00"
@.str.13 = [54 x i8] c"Mismatch between requested and stored types for array\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 %25 [
i32 -1, label %5
i32 -2, label %6
i32 -3, label %14
i32 -4, label %15
i32 -5, label %16
i32 -6, label %17
i32 -7, label %18
i32 -8, label %19
i32 -10, label %20
i32 -11, label %21
i32 -9, label %22
i32 -12, label %23
i32 -13, label %24
]
5: ; preds = %1
store i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %25
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 %25
14: ; preds = %1
store i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %25
15: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %25
16: ; preds = %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %25
17: ; preds = %1
store i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %25
18: ; preds = %1
store i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %25
19: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %25
20: ; preds = %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %25
21: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8** %3
br label %25
22: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8** %3
br label %25
23: ; preds = %1
store i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.12, i64 0, i64 0), i8** %3
br label %25
24: ; preds = %1
store i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.13, i64 0, i64 0), i8** %3
br label %25
25: ; preds = %1, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %5
%26 = load i8*, i8** %3
ret i8* %26
}

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 = [14 x i8] c"Out of memory\00"
@.str.5 = [23 x i8] c"File not in KAS format\00"
@.str.6 = [78 x i8] c"File format version is too old. Please upgrade using 'kas upgrade <filename>'\00"
@.str.7 = [76 x i8] c"File format version is too new. Please upgrade your kastore library version\00"
@.str.8 = [18 x i8] c"Unknown data type\00"
@.str.9 = [23 x i8] c"Duplicate key provided\00"
@.str.10 = [14 x i8] c"Key not found\00"
@.str.11 = [21 x i8] c"Keys cannot be empty\00"
@.str.12 = [59 x i8] c"Cannot perform the requested operation in the current mode\00"
@.str.13 = [54 x i8] c"Mismatch between requested and stored types for array\00"
define i8* @kas_strerror(i32 %0) {
switch i32 %0, label %19 [
i32 -1, label %2
i32 -2, label %3
i32 -3, label %8
i32 -4, label %9
i32 -5, label %10
i32 -6, label %11
i32 -7, label %12
i32 -8, label %13
i32 -10, label %14
i32 -11, label %15
i32 -9, label %16
i32 -12, label %17
i32 -13, label %18
]
2: ; preds = %1
br label %19
3: ; preds = %1
%4 = load i32, i32* @errno
%5 = icmp eq i32 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = tail call i8* @strerror(i32 %4)
br label %19
8: ; preds = %1
br label %19
9: ; preds = %1
br label %19
10: ; preds = %1
br label %19
11: ; preds = %1
br label %19
12: ; preds = %1
br label %19
13: ; preds = %1
br label %19
14: ; preds = %1
br label %19
15: ; preds = %1
br label %19
16: ; preds = %1
br label %19
17: ; preds = %1
br label %19
18: ; preds = %1
br label %19
19: ; preds = %3, %6, %1, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %2
%20 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([54 x i8], [54 x i8]* @.str.13, i64 0, i64 0), %18 ], [ getelementptr inbounds ([59 x i8], [59 x i8]* @.str.12, i64 0, i64 0), %17 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), %16 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), %15 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), %14 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), %13 ], [ getelementptr inbounds ([76 x i8], [76 x i8]* @.str.7, i64 0, i64 0), %12 ], [ getelementptr inbounds ([78 x i8], [78 x i8]* @.str.6, i64 0, i64 0), %11 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), %10 ], [ getelementptr inbounds ([14 x i8], [14 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* %20
}