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

/* Variables and functions */
int /*<<< orphan*/ strncpy(char *, char *, int);
char *request_error(int errn) {
  static char err[100];
  err[0] = '\0';
  switch (errn) {
  case 0x01:
    strncpy(err, "Memory error", sizeof(err) - 1);
    break;
  case 0x04:
    strncpy(err, "Service not found on this nterfaced instance",
            sizeof(err) - 1);
    break;
  case 0x03:
    strncpy(err, "Transport handler rejected request", sizeof(err) - 1);
    break;
  case 0x05:
    strncpy(err, "Transport handler closed connection", sizeof(err) - 1);
    break;
  case 0x06:
    strncpy(err, "Transport module not yet loaded for this service",
            sizeof(err) - 1);
    break;
  case 0x07:
    strncpy(err, "Command not found on this service", sizeof(err) - 1);
    break;
  case 0x08:
    strncpy(err, "Wrong number of arguments for this command", sizeof(err) - 1);
    break;
  case 0x09:
    strncpy(err, "Too many arguments supplied", sizeof(err) - 1);
    break;
  case 0x0A:
    strncpy(err, "Service not found on this nterfacer instance",
            sizeof(err) - 1);
    break;
  default:
    strncpy(err, "Unable to find error message", sizeof(err) - 1);
  }
  err[sizeof(err) - 1] = '\0';
  return err;
}


x86 assembly (clang, -O0):
<request_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,0x2f1e(%rip)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x9,%eax
ja     1250 <request_error+0x140>
mov    -0x10(%rbp),%rax
lea    0xebe(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x2eee(%rip),%rdi
lea    0xecf(%rip),%rsi
mov    $0x63,%edx
call   1030 <strncpy@plt>
jmp    1268 <request_error+0x158>
lea    0x2ed1(%rip),%rdi
lea    0xebf(%rip),%rsi
mov    $0x63,%edx
call   1030 <strncpy@plt>
jmp    1268 <request_error+0x158>
lea    0x2eb4(%rip),%rdi
lea    0xecf(%rip),%rsi
mov    $0x63,%edx
call   1030 <strncpy@plt>
jmp    1268 <request_error+0x158>
lea    0x2e97(%rip),%rdi
lea    0xed5(%rip),%rsi
mov    $0x63,%edx
call   1030 <strncpy@plt>
jmp    1268 <request_error+0x158>
lea    0x2e7a(%rip),%rdi
lea    0xedc(%rip),%rsi
mov    $0x63,%edx
call   1030 <strncpy@plt>
jmp    1268 <request_error+0x158>
lea    0x2e5d(%rip),%rdi
lea    0xef0(%rip),%rsi
mov    $0x63,%edx
call   1030 <strncpy@plt>
jmp    1268 <request_error+0x158>
lea    0x2e40(%rip),%rdi
lea    0xef5(%rip),%rsi
mov    $0x63,%edx
call   1030 <strncpy@plt>
jmp    1268 <request_error+0x158>
lea    0x2e23(%rip),%rdi
lea    0xf03(%rip),%rsi
mov    $0x63,%edx
call   1030 <strncpy@plt>
jmp    1268 <request_error+0x158>
lea    0x2e06(%rip),%rdi
lea    0xf02(%rip),%rsi
mov    $0x63,%edx
call   1030 <strncpy@plt>
jmp    1268 <request_error+0x158>
lea    0x2de9(%rip),%rdi
lea    0xf12(%rip),%rsi
mov    $0x63,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x2e34(%rip)
lea    0x2dca(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<request_error>:
push   %rbx
movb   $0x0,0x2f28(%rip)
add    $0xffffffff,%edi
cmp    $0x9,%edi
ja     1133 <request_error+0x23>
movslq %edi,%rax
lea    0x103e(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
jmp    113a <request_error+0x2a>
lea    0x100e(%rip),%rsi
lea    0x2eff(%rip),%rbx
mov    %rbx,%rdi
mov    $0x63,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x2f4e(%rip)
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@request_error.err = internal global [100 x i8] zeroinitializer
@.str = [13 x i8] c"Memory error\00"
@.str.1 = [45 x i8] c"Service not found on this nterfaced instance\00"
@.str.2 = [35 x i8] c"Transport handler rejected request\00"
@.str.3 = [36 x i8] c"Transport handler closed connection\00"
@.str.4 = [49 x i8] c"Transport module not yet loaded for this service\00"
@.str.5 = [34 x i8] c"Command not found on this service\00"
@.str.6 = [43 x i8] c"Wrong number of arguments for this command\00"
@.str.7 = [28 x i8] c"Too many arguments supplied\00"
@.str.8 = [45 x i8] c"Service not found on this nterfacer instance\00"
@.str.9 = [29 x i8] c"Unable to find error message\00"
define i8* @request_error(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
store i8 0, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0)
%3 = load i32, i32* %2
switch i32 %3, label %22 [
i32 1, label %4
i32 4, label %6
i32 3, label %8
i32 5, label %10
i32 6, label %12
i32 7, label %14
i32 8, label %16
i32 9, label %18
i32 10, label %20
]
4: ; preds = %1
%5 = call i32 @strncpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 99)
br label %24
6: ; preds = %1
%7 = call i32 @strncpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 99)
br label %24
8: ; preds = %1
%9 = call i32 @strncpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 99)
br label %24
10: ; preds = %1
%11 = call i32 @strncpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 99)
br label %24
12: ; preds = %1
%13 = call i32 @strncpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0), i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i32 99)
br label %24
14: ; preds = %1
%15 = call i32 @strncpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 99)
br label %24
16: ; preds = %1
%17 = call i32 @strncpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 99)
br label %24
18: ; preds = %1
%19 = call i32 @strncpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 99)
br label %24
20: ; preds = %1
%21 = call i32 @strncpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0), i32 99)
br label %24
22: ; preds = %1
%23 = call i32 @strncpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i32 99)
br label %24
24: ; preds = %22, %20, %18, %16, %14, %12, %10, %8, %6, %4
store i8 0, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 99)
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0)
}

LLVM IR (-O2):
@request_error.err = internal global [100 x i8] zeroinitializer
@.str = [13 x i8] c"Memory error\00"
@.str.1 = [45 x i8] c"Service not found on this nterfaced instance\00"
@.str.2 = [35 x i8] c"Transport handler rejected request\00"
@.str.3 = [36 x i8] c"Transport handler closed connection\00"
@.str.4 = [49 x i8] c"Transport module not yet loaded for this service\00"
@.str.5 = [34 x i8] c"Command not found on this service\00"
@.str.6 = [43 x i8] c"Wrong number of arguments for this command\00"
@.str.7 = [28 x i8] c"Too many arguments supplied\00"
@.str.8 = [45 x i8] c"Service not found on this nterfacer instance\00"
@.str.9 = [29 x i8] c"Unable to find error message\00"
@reltable.request_error = [10 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str to i64), i64 ptrtoint ([10 x i32]* @reltable.request_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @.str.9 to i64), i64 ptrtoint ([10 x i32]* @reltable.request_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @.str.2 to i64), i64 ptrtoint ([10 x i32]* @reltable.request_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([45 x i8]* @.str.1 to i64), i64 ptrtoint ([10 x i32]* @reltable.request_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([36 x i8]* @.str.3 to i64), i64 ptrtoint ([10 x i32]* @reltable.request_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([49 x i8]* @.str.4 to i64), i64 ptrtoint ([10 x i32]* @reltable.request_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([34 x i8]* @.str.5 to i64), i64 ptrtoint ([10 x i32]* @reltable.request_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([43 x i8]* @.str.6 to i64), i64 ptrtoint ([10 x i32]* @reltable.request_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str.7 to i64), i64 ptrtoint ([10 x i32]* @reltable.request_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([45 x i8]* @.str.8 to i64), i64 ptrtoint ([10 x i32]* @reltable.request_error to i64)) to i32)]
define i8* @request_error(i32 %0) {
store i8 0, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0)
%2 = add i32 %0, -1
%3 = icmp ult i32 %2, 10
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([10 x i32]* @reltable.request_error to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), %1 ]
%10 = tail call i32 @strncpy(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0), i8* %9, i32 99)
store i8 0, i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 99)
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @request_error.err, i64 0, i64 0)
}