#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 const *strerror(int /*<<< orphan*/);
const char *err_ipv4_str(int code) {
  if (code == -1)
    return strerror(errno);
  else if (code == -2)
    return "Not enough memory";
  else if (code == -3)
    return "Permission denied";
  else if (code == -4)
    return "Route not found";
  else if (code == -5)
    return "Parsing /proc/net/route failed";
  return "unknown";
}


x86 assembly (clang, -O0):
<err_ipv4_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    113c <err_ipv4_str+0x2c>
mov    0x2eb4(%rip),%rax
mov    (%rax),%edi
call   1030 <strerror@plt>
mov    %rax,-0x8(%rbp)
jmp    11c3 <err_ipv4_str+0xb3>
cmpl   $0xfffffffe,-0xc(%rbp)
jne    1156 <err_ipv4_str+0x46>
lea    0xeb3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c3 <err_ipv4_str+0xb3>
cmpl   $0xfffffffd,-0xc(%rbp)
jne    1170 <err_ipv4_str+0x60>
lea    0xeab(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c3 <err_ipv4_str+0xb3>
cmpl   $0xfffffffc,-0xc(%rbp)
jne    118a <err_ipv4_str+0x7a>
lea    0xea3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c3 <err_ipv4_str+0xb3>
cmpl   $0xfffffffb,-0xc(%rbp)
jne    11a4 <err_ipv4_str+0x94>
lea    0xe99(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c3 <err_ipv4_str+0xb3>
jmp    11a9 <err_ipv4_str+0x99>
jmp    11ae <err_ipv4_str+0x9e>
jmp    11b3 <err_ipv4_str+0xa3>
jmp    11b8 <err_ipv4_str+0xa8>
lea    0xe94(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<err_ipv4_str>:
add    $0x5,%edi
cmp    $0x4,%edi
ja     1137 <err_ipv4_str+0x27>
lea    0xef5(%rip),%rax
lea    0xeda(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
lea    0xf12(%rip),%rax
ret
lea    0xf29(%rip),%rax
ret
lea    0xef2(%rip),%rax
ret
lea    0xed8(%rip),%rax
ret
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
jmp    1030 <strerror@plt>

LLVM IR (-O0):
@errno = global i32 0
@.str = [18 x i8] c"Not enough memory\00"
@.str.1 = [18 x i8] c"Permission denied\00"
@.str.2 = [16 x i8] c"Route not found\00"
@.str.3 = [31 x i8] c"Parsing /proc/net/route failed\00"
@.str.4 = [8 x i8] c"unknown\00"
define i8* @err_ipv4_str(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @errno
%8 = call i8* @strerror(i32 %7)
store i8* %8, i8** %2
br label %30
9: ; preds = %1
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, -2
br i1 %11, label %12, label %13
12: ; preds = %9
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8** %2
br label %30
13: ; preds = %9
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, -3
br i1 %15, label %16, label %17
16: ; preds = %13
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %30
17: ; preds = %13
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, -4
br i1 %19, label %20, label %21
20: ; preds = %17
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %30
21: ; preds = %17
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, -5
br i1 %23, label %24, label %25
24: ; preds = %21
store i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %30
25: ; preds = %21
br label %26
26: ; preds = %25
br label %27
27: ; preds = %26
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %30
30: ; preds = %29, %24, %20, %16, %12, %6
%31 = load i8*, i8** %2
ret i8* %31
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [18 x i8] c"Not enough memory\00"
@.str.1 = [18 x i8] c"Permission denied\00"
@.str.2 = [16 x i8] c"Route not found\00"
@.str.3 = [31 x i8] c"Parsing /proc/net/route failed\00"
@.str.4 = [8 x i8] c"unknown\00"
define i8* @err_ipv4_str(i32 %0) {
switch i32 %0, label %8 [
i32 -1, label %2
i32 -2, label %9
i32 -3, label %5
i32 -4, label %6
i32 -5, label %7
]
2: ; preds = %1
%3 = load i32, i32* @errno
%4 = tail call i8* @strerror(i32 %3)
br label %9
5: ; preds = %1
br label %9
6: ; preds = %1
br label %9
7: ; preds = %1
br label %9
8: ; preds = %1
br label %9
9: ; preds = %1, %8, %7, %6, %5, %2
%10 = phi i8* [ %4, %2 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), %7 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %8 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %10
}