#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 */
const char *tcp_error(const int rv) {
  return rv == (-1)   ? "socket"
         : rv == (-2) ? "bind"
         : rv == (-3) ? "listen"
         : rv == (-4) ? "connect"
                      : NULL;
}


x86 assembly (clang, -O0):
<tcp_error>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    1121 <tcp_error+0x21>
lea    0xee8(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    117c <tcp_error+0x7c>
cmpl   $0xfffffffe,-0x4(%rbp)
jne    113b <tcp_error+0x3b>
lea    0xed5(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1174 <tcp_error+0x74>
cmpl   $0xfffffffd,-0x4(%rbp)
jne    1155 <tcp_error+0x55>
lea    0xec0(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    116c <tcp_error+0x6c>
mov    -0x4(%rbp),%edx
xor    %eax,%eax
lea    0xeb2(%rip),%rcx
cmp    $0xfffffffc,%edx
cmove  %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcp_error>:
cmp    $0xfffffffc,%edi
jbe    111a <tcp_error+0x1a>
add    $0x3,%edi
movslq %edi,%rax
lea    0xf0a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
xor    %eax,%eax
cmp    $0xfffffffc,%edi
lea    0xeed(%rip),%rcx
cmove  %rcx,%rax
ret

LLVM IR (-O0):
@.str = [7 x i8] c"socket\00"
@.str.1 = [5 x i8] c"bind\00"
@.str.2 = [7 x i8] c"listen\00"
@.str.3 = [8 x i8] c"connect\00"
define i8* @tcp_error(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %6
5: ; preds = %1
br label %23
6: ; preds = %1
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, -2
br i1 %8, label %9, label %10
9: ; preds = %6
br label %21
10: ; preds = %6
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, -3
br i1 %12, label %13, label %14
13: ; preds = %10
br label %19
14: ; preds = %10
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, -4
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* null
br label %19
19: ; preds = %14, %13
%20 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %13 ], [ %18, %14 ]
br label %21
21: ; preds = %19, %9
%22 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %9 ], [ %20, %19 ]
br label %23
23: ; preds = %21, %5
%24 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %5 ], [ %22, %21 ]
ret i8* %24
}

LLVM IR (-O2):
@.str = [7 x i8] c"socket\00"
@.str.1 = [5 x i8] c"bind\00"
@.str.2 = [7 x i8] c"listen\00"
@.str.3 = [8 x i8] c"connect\00"
@reltable.tcp_error = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.tcp_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.tcp_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.tcp_error to i64)) to i32)]
define i8* @tcp_error(i32 %0) {
%2 = icmp ugt i32 %0, -4
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = icmp eq i32 %0, -4
%5 = select i1 %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* null
br label %11
6: ; preds = %1
%7 = add i32 %0, 3
%8 = sext i32 %7 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.tcp_error to i8*), i64 %9)
br label %11
11: ; preds = %6, %3
%12 = phi i8* [ %5, %3 ], [ %10, %6 ]
ret i8* %12
}