#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 /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int);
char *dtn_strerror(int err) {
  switch (err) {
  case 0:
    return "success";
  case (128 + 1):
    return "invalid argument";
  case (128 + 2):
    return "error in xdr routines";
  case (128 + 3):
    return "error in ipc communication";
  case (128 + 4):
    return "error connecting to server";
  case (128 + 5):
    return "operation timed out";
  case (128 + 6):
    return "payload too large";
  case (128 + 7):
    return "not found";
  case (128 + 8):
    return "internal error";
  case (128 + 9):
    return "illegal operation called after dtn_poll";
  case (128 + 10):
    return "registration already in use";
  case (128 + 11):
    return "ipc version mismatch";
  case (128 + 12):
    return "unknown ipc message type";
  case (128 + 13):
    return "no storage space";
  case -1:
    return "(invalid error code -1)";
  }
  static char buf[128];
  snprintf(buf, sizeof(buf), "(unknown error %d)", err);
  return buf;
}


x86 assembly (clang, -O0):
<dtn_strerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x8e,%eax
ja     1236 <dtn_strerror+0x126>
mov    -0x18(%rbp),%rax
lea    0xec3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x10ef(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
lea    0x10e7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
lea    0x10e8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
lea    0x10ee(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
lea    0x10f9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
lea    0x1104(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
lea    0x1108(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
lea    0x110a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
lea    0x1104(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
lea    0x1103(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
lea    0x111b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
lea    0x1127(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
lea    0x112c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
lea    0x1135(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
lea    0x1136(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <dtn_strerror+0x14c>
mov    -0xc(%rbp),%ecx
lea    0x2e00(%rip),%rdi
mov    $0x80,%esi
lea    0x112f(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2de8(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dtn_strerror>:
push   %rbx
mov    %edi,%ecx
lea    0x1(%rcx),%eax
cmp    $0x8e,%eax
ja     1140 <dtn_strerror+0x30>
lea    0x1118(%rip),%rbx
lea    0xed5(%rip),%rdx
movslq (%rdx,%rax,4),%rax
add    %rdx,%rax
jmp    *%rax
lea    0x1228(%rip),%rbx
jmp    11d0 <dtn_strerror+0xc0>
lea    0x2ef9(%rip),%rbx
lea    0x122d(%rip),%rdx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1030 <snprintf@plt>
jmp    11d0 <dtn_strerror+0xc0>
lea    0x10e0(%rip),%rbx
jmp    11d0 <dtn_strerror+0xc0>
lea    0x10e8(%rip),%rbx
jmp    11d0 <dtn_strerror+0xc0>
lea    0x10f5(%rip),%rbx
jmp    11d0 <dtn_strerror+0xc0>
lea    0x1107(%rip),%rbx
jmp    11d0 <dtn_strerror+0xc0>
lea    0x1119(%rip),%rbx
jmp    11d0 <dtn_strerror+0xc0>
lea    0x1124(%rip),%rbx
jmp    11d0 <dtn_strerror+0xc0>
lea    0x1137(%rip),%rbx
jmp    11d0 <dtn_strerror+0xc0>
lea    0x113d(%rip),%rbx
jmp    11d0 <dtn_strerror+0xc0>
lea    0x115c(%rip),%rbx
jmp    11d0 <dtn_strerror+0xc0>
lea    0x116f(%rip),%rbx
jmp    11d0 <dtn_strerror+0xc0>
lea    0x117b(%rip),%rbx
jmp    11d0 <dtn_strerror+0xc0>
lea    0x118b(%rip),%rbx
jmp    11d0 <dtn_strerror+0xc0>
lea    0x10f7(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"success\00"
@.str.1 = [17 x i8] c"invalid argument\00"
@.str.2 = [22 x i8] c"error in xdr routines\00"
@.str.3 = [27 x i8] c"error in ipc communication\00"
@.str.4 = [27 x i8] c"error connecting to server\00"
@.str.5 = [20 x i8] c"operation timed out\00"
@.str.6 = [18 x i8] c"payload too large\00"
@.str.7 = [10 x i8] c"not found\00"
@.str.8 = [15 x i8] c"internal error\00"
@.str.9 = [40 x i8] c"illegal operation called after dtn_poll\00"
@.str.10 = [28 x i8] c"registration already in use\00"
@.str.11 = [21 x i8] c"ipc version mismatch\00"
@.str.12 = [25 x i8] c"unknown ipc message type\00"
@.str.13 = [17 x i8] c"no storage space\00"
@.str.14 = [24 x i8] c"(invalid error code -1)\00"
@dtn_strerror.buf = internal global [128 x i8] zeroinitializer
@.str.15 = [19 x i8] c"(unknown error %d)\00"
define i8* @dtn_strerror(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %20 [
i32 0, label %5
i32 129, label %6
i32 130, label %7
i32 131, label %8
i32 132, label %9
i32 133, label %10
i32 134, label %11
i32 135, label %12
i32 136, label %13
i32 137, label %14
i32 138, label %15
i32 139, label %16
i32 140, label %17
i32 141, label %18
i32 -1, label %19
]
5: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %2
br label %23
6: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %23
7: ; preds = %1
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %23
8: ; preds = %1
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %23
9: ; preds = %1
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %23
10: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %23
11: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %23
12: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %23
13: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %23
14: ; preds = %1
store i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %23
15: ; preds = %1
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %23
16: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %23
17: ; preds = %1
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %23
18: ; preds = %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %23
19: ; preds = %1
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), i8** %2
br label %23
20: ; preds = %1
%21 = load i32, i32* %3
%22 = call i32 @snprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @dtn_strerror.buf, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0), i32 %21)
store i8* getelementptr inbounds ([128 x i8], [128 x i8]* @dtn_strerror.buf, i64 0, i64 0), i8** %2
br label %23
23: ; preds = %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%24 = load i8*, i8** %2
ret i8* %24
}

LLVM IR (-O2):
@.str = [8 x i8] c"success\00"
@.str.1 = [17 x i8] c"invalid argument\00"
@.str.2 = [22 x i8] c"error in xdr routines\00"
@.str.3 = [27 x i8] c"error in ipc communication\00"
@.str.4 = [27 x i8] c"error connecting to server\00"
@.str.5 = [20 x i8] c"operation timed out\00"
@.str.6 = [18 x i8] c"payload too large\00"
@.str.7 = [10 x i8] c"not found\00"
@.str.8 = [15 x i8] c"internal error\00"
@.str.9 = [40 x i8] c"illegal operation called after dtn_poll\00"
@.str.10 = [28 x i8] c"registration already in use\00"
@.str.11 = [21 x i8] c"ipc version mismatch\00"
@.str.12 = [25 x i8] c"unknown ipc message type\00"
@.str.13 = [17 x i8] c"no storage space\00"
@.str.14 = [24 x i8] c"(invalid error code -1)\00"
@dtn_strerror.buf = internal global [128 x i8] zeroinitializer
@.str.15 = [19 x i8] c"(unknown error %d)\00"
define i8* @dtn_strerror(i32 %0) {
switch i32 %0, label %16 [
i32 0, label %18
i32 129, label %2
i32 130, label %3
i32 131, label %4
i32 132, label %5
i32 133, label %6
i32 134, label %7
i32 135, label %8
i32 136, label %9
i32 137, label %10
i32 138, label %11
i32 139, label %12
i32 140, label %13
i32 141, label %14
i32 -1, label %15
]
2: ; preds = %1
br label %18
3: ; preds = %1
br label %18
4: ; preds = %1
br label %18
5: ; preds = %1
br label %18
6: ; preds = %1
br label %18
7: ; preds = %1
br label %18
8: ; preds = %1
br label %18
9: ; preds = %1
br label %18
10: ; preds = %1
br label %18
11: ; preds = %1
br label %18
12: ; preds = %1
br label %18
13: ; preds = %1
br label %18
14: ; preds = %1
br label %18
15: ; preds = %1
br label %18
16: ; preds = %1
%17 = tail call i32 @snprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @dtn_strerror.buf, i64 0, i64 0), i32 128, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0), i32 %0)
br label %18
18: ; preds = %1, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%19 = phi i8* [ getelementptr inbounds ([128 x i8], [128 x i8]* @dtn_strerror.buf, i64 0, i64 0), %16 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), %15 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), %14 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.12, i64 0, i64 0), %13 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0), %12 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), %11 ], [ getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0), %10 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), %9 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %19
}