#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 */
#define EAI_AGAIN 136
#define EAI_BADFLAGS 135
#define EAI_FAIL 134
#define EAI_FAMILY 133
#define EAI_MEMORY 132
#define EAI_NONAME 131
#define EAI_SERVICE 130
#define EAI_SOCKTYPE 129
#define EAI_SYSTEM 128
int translate_sockerr(int errval) {
  int retval = 0;
  switch (errval) {
  case EAI_AGAIN:
    retval = 7015;
    break;
  case EAI_BADFLAGS:
    retval = 7016;
    break;
  case EAI_FAIL:
    retval = 7017;
    break;
  case EAI_FAMILY:
    retval = 7018;
    break;
  case EAI_MEMORY:
    retval = 7019;
    break;
  case EAI_NONAME:
    retval = 7021;
    break;
  case EAI_SERVICE:
    retval = 7022;
    break;
  case EAI_SOCKTYPE:
    retval = 7023;
    break;
  case EAI_SYSTEM:
    retval = 7024;
    break;
  default:
    retval = 7007;
  }
  return retval;
}


x86 assembly (clang, -O0):
<translate_sockerr>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x8,%eax
ja     11a3 <translate_sockerr+0xa3>
mov    -0x10(%rbp),%rax
lea    0xed2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1b67,-0x8(%rbp)
jmp    11aa <translate_sockerr+0xaa>
movl   $0x1b68,-0x8(%rbp)
jmp    11aa <translate_sockerr+0xaa>
movl   $0x1b69,-0x8(%rbp)
jmp    11aa <translate_sockerr+0xaa>
movl   $0x1b6a,-0x8(%rbp)
jmp    11aa <translate_sockerr+0xaa>
movl   $0x1b6b,-0x8(%rbp)
jmp    11aa <translate_sockerr+0xaa>
movl   $0x1b6d,-0x8(%rbp)
jmp    11aa <translate_sockerr+0xaa>
movl   $0x1b6e,-0x8(%rbp)
jmp    11aa <translate_sockerr+0xaa>
movl   $0x1b6f,-0x8(%rbp)
jmp    11aa <translate_sockerr+0xaa>
movl   $0x1b70,-0x8(%rbp)
jmp    11aa <translate_sockerr+0xaa>
movl   $0x1b5f,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<translate_sockerr>:
add    $0xffffff80,%edi
mov    $0x1b5f,%eax
cmp    $0x8,%edi
ja     111a <translate_sockerr+0x1a>
movslq %edi,%rax
lea    0xee9(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
define i32 @translate_sockerr(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
switch i32 %4, label %14 [
i32 136, label %5
i32 135, label %6
i32 134, label %7
i32 133, label %8
i32 132, label %9
i32 131, label %10
i32 130, label %11
i32 129, label %12
i32 128, label %13
]
5: ; preds = %1
store i32 7015, i32* %3
br label %15
6: ; preds = %1
store i32 7016, i32* %3
br label %15
7: ; preds = %1
store i32 7017, i32* %3
br label %15
8: ; preds = %1
store i32 7018, i32* %3
br label %15
9: ; preds = %1
store i32 7019, i32* %3
br label %15
10: ; preds = %1
store i32 7021, i32* %3
br label %15
11: ; preds = %1
store i32 7022, i32* %3
br label %15
12: ; preds = %1
store i32 7023, i32* %3
br label %15
13: ; preds = %1
store i32 7024, i32* %3
br label %15
14: ; preds = %1
store i32 7007, i32* %3
br label %15
15: ; preds = %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
@switch.table.translate_sockerr = [9 x i32] [i32 7024, i32 7023, i32 7022, i32 7021, i32 7019, i32 7018, i32 7017, i32 7016, i32 7015]
define i32 @translate_sockerr(i32 %0) {
%2 = add i32 %0, -128
%3 = icmp ult i32 %2, 9
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds [9 x i32], [9 x i32]* @switch.table.translate_sockerr, i64 0, i64 %5
%7 = load i32, i32* %6
br label %8
8: ; preds = %1, %4
%9 = phi i32 [ %7, %4 ], [ 7007, %1 ]
ret i32 %9
}