#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 */
struct mg_rpc_request {
  int dummy;
};

/* Variables and functions */
int mg_rpc_create_error(char *, int, struct mg_rpc_request *, int, char const *,
                        char *);
int mg_rpc_create_std_error(char *buf, int len, struct mg_rpc_request *req,
                            int code) {
  const char *message = NULL;
  switch (code) {
  case (-32700):
    message = "parse error";
    break;
  case (-32600):
    message = "invalid request";
    break;
  case (-32601):
    message = "method not found";
    break;
  case (-32602):
    message = "invalid parameters";
    break;
  case (-32000):
    message = "server error";
    break;
  default:
    message = "unspecified error";
    break;
  }
  return mg_rpc_create_error(buf, len, req, code, message, "N");
}


x86 assembly (clang, -O0):
<mg_rpc_create_std_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0xffff8044,%eax
je     1190 <mg_rpc_create_std_error+0x80>
jmp    1144 <mg_rpc_create_std_error+0x34>
mov    -0x2c(%rbp),%eax
sub    $0xffff80a6,%eax
je     11c0 <mg_rpc_create_std_error+0xb0>
jmp    1157 <mg_rpc_create_std_error+0x47>
mov    -0x2c(%rbp),%eax
sub    $0xffff80a7,%eax
je     11b0 <mg_rpc_create_std_error+0xa0>
jmp    116a <mg_rpc_create_std_error+0x5a>
mov    -0x2c(%rbp),%eax
sub    $0xffff80a8,%eax
je     11a0 <mg_rpc_create_std_error+0x90>
jmp    117d <mg_rpc_create_std_error+0x6d>
mov    -0x2c(%rbp),%eax
sub    $0xffff8300,%eax
je     11d0 <mg_rpc_create_std_error+0xc0>
jmp    11e0 <mg_rpc_create_std_error+0xd0>
lea    0xe69(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11eb <mg_rpc_create_std_error+0xdb>
lea    0xe65(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11eb <mg_rpc_create_std_error+0xdb>
lea    0xe65(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11eb <mg_rpc_create_std_error+0xdb>
lea    0xe66(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11eb <mg_rpc_create_std_error+0xdb>
lea    0xe69(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11eb <mg_rpc_create_std_error+0xdb>
lea    0xe66(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8
lea    0xe5b(%rip),%r9
call   1030 <mg_rpc_create_error@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mg_rpc_create_std_error>:
cmp    $0xffff80a6,%ecx
jle    1143 <mg_rpc_create_std_error+0x33>
cmp    $0xffff80a7,%ecx
je     1166 <mg_rpc_create_std_error+0x56>
cmp    $0xffff8300,%ecx
je     1179 <mg_rpc_create_std_error+0x69>
cmp    $0xffff80a8,%ecx
jne    119f <mg_rpc_create_std_error+0x8f>
lea    0xed5(%rip),%r8
lea    0xf21(%rip),%r9
jmp    1030 <mg_rpc_create_error@plt>
cmp    $0xffff8044,%ecx
je     118c <mg_rpc_create_std_error+0x7c>
cmp    $0xffff80a6,%ecx
jne    119f <mg_rpc_create_std_error+0x8f>
lea    0xed3(%rip),%r8
lea    0xefe(%rip),%r9
jmp    1030 <mg_rpc_create_error@plt>
lea    0xeaf(%rip),%r8
lea    0xeeb(%rip),%r9
jmp    1030 <mg_rpc_create_error@plt>
lea    0xec0(%rip),%r8
lea    0xed8(%rip),%r9
jmp    1030 <mg_rpc_create_error@plt>
lea    0xe6d(%rip),%r8
lea    0xec5(%rip),%r9
jmp    1030 <mg_rpc_create_error@plt>
lea    0xea7(%rip),%r8
lea    0xeb2(%rip),%r9
jmp    1030 <mg_rpc_create_error@plt>

LLVM IR (-O0):
%struct.mg_rpc_request = type { i32 }
@.str = [12 x i8] c"parse error\00"
@.str.1 = [16 x i8] c"invalid request\00"
@.str.2 = [17 x i8] c"method not found\00"
@.str.3 = [19 x i8] c"invalid parameters\00"
@.str.4 = [13 x i8] c"server error\00"
@.str.5 = [18 x i8] c"unspecified error\00"
@.str.6 = [2 x i8] c"N\00"
define i32 @mg_rpc_create_std_error(i8* %0, i32 %1, %struct.mg_rpc_request* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.mg_rpc_request*
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store %struct.mg_rpc_request* %2, %struct.mg_rpc_request** %7
store i32 %3, i32* %8
store i8* null, i8** %9
%10 = load i32, i32* %8
switch i32 %10, label %16 [
i32 -32700, label %11
i32 -32600, label %12
i32 -32601, label %13
i32 -32602, label %14
i32 -32000, label %15
]
11: ; preds = %4
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %9
br label %17
12: ; preds = %4
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8** %9
br label %17
13: ; preds = %4
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %9
br label %17
14: ; preds = %4
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8** %9
br label %17
15: ; preds = %4
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8** %9
br label %17
16: ; preds = %4
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8** %9
br label %17
17: ; preds = %16, %15, %14, %13, %12, %11
%18 = load i8*, i8** %5
%19 = load i32, i32* %6
%20 = load %struct.mg_rpc_request*, %struct.mg_rpc_request** %7
%21 = load i32, i32* %8
%22 = load i8*, i8** %9
%23 = call i32 @mg_rpc_create_error(i8* %18, i32 %19, %struct.mg_rpc_request* %20, i32 %21, i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret i32 %23
}

LLVM IR (-O2):
%struct.mg_rpc_request = type { i32 }
@.str = [12 x i8] c"parse error\00"
@.str.1 = [16 x i8] c"invalid request\00"
@.str.2 = [17 x i8] c"method not found\00"
@.str.3 = [19 x i8] c"invalid parameters\00"
@.str.4 = [13 x i8] c"server error\00"
@.str.5 = [18 x i8] c"unspecified error\00"
@.str.6 = [2 x i8] c"N\00"
define i32 @mg_rpc_create_std_error(i8* %0, i32 %1, %struct.mg_rpc_request* %2, i32 %3) {
switch i32 %3, label %9 [
i32 -32700, label %10
i32 -32600, label %5
i32 -32601, label %6
i32 -32602, label %7
i32 -32000, label %8
]
5: ; preds = %4
br label %10
6: ; preds = %4
br label %10
7: ; preds = %4
br label %10
8: ; preds = %4
br label %10
9: ; preds = %4
br label %10
10: ; preds = %4, %9, %8, %7, %6, %5
%11 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), %9 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), %8 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %7 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %4 ]
%12 = tail call i32 @mg_rpc_create_error(i8* %0, i32 %1, %struct.mg_rpc_request* %2, i32 %3, i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret i32 %12
}