#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 EADDRINUSE 136
#define EALREADY 135
#define EBADF 134
#define ECONNREFUSED 133
#define EFAULT 132
#define EISCONN 131
#define ENETUNREACH 130
#define ENOTSOCK 129
#define ETIMEDOUT 128
int /*<<< orphan*/ info_log(char *, ...);
void connect_error(int err) {
  switch (err) {
  case EBADF: {
    info_log("connect error: bad file descriptor \n");
    return;
  }
  case EADDRINUSE: {
    info_log("connect error: address in use \n");
    return;
  }
  case EALREADY: {
    info_log("connect error: connect already in progress \n");
    return;
  }
  case EFAULT: {
    info_log("connect error: address fault\n");
    return;
  }
  case ENOTSOCK: {
    info_log("connect error: not a socket\n");
    return;
  }
  case EISCONN: {
    info_log("connect error: socket in use\n");
    return;
  }
  case ECONNREFUSED: {
    info_log("connect error: connection refused\n");
    return;
  }
  case ETIMEDOUT: {
    info_log("connect error: connection timed out\n");
    return;
  }
  case ENETUNREACH: {
    info_log("connect error: network unreachable\n");
    return;
  }
  default: {
    info_log("unknown errror(%i)\n", err);
    return;
  }
  }
}


x86 assembly (clang, -O0):
<connect_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x8,%eax
ja     11ef <connect_error+0xdf>
mov    -0x10(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
jmp    1200 <connect_error+0xf0>
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
jmp    1200 <connect_error+0xf0>
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
jmp    1200 <connect_error+0xf0>
lea    0xf12(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
jmp    1200 <connect_error+0xf0>
lea    0xf1d(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
jmp    1200 <connect_error+0xf0>
lea    0xf27(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
jmp    1200 <connect_error+0xf0>
lea    0xf32(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
jmp    1200 <connect_error+0xf0>
lea    0xf42(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
jmp    1200 <connect_error+0xf0>
lea    0xf54(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
jmp    1200 <connect_error+0xf0>
mov    -0x4(%rbp),%esi
lea    0xf62(%rip),%rdi
mov    $0x0,%al
call   1030 <info_log@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<connect_error>:
mov    %edi,%esi
lea    -0x80(%rsi),%eax
cmp    $0x8,%eax
ja     1138 <connect_error+0x28>
lea    0xedf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xfe1(%rip),%rdi
xor    %eax,%eax
jmp    1030 <info_log@plt>
lea    0x101c(%rip),%rdi
xor    %eax,%eax
jmp    1030 <info_log@plt>
lea    0xf67(%rip),%rdi
xor    %eax,%eax
jmp    1030 <info_log@plt>
lea    0xfdc(%rip),%rdi
xor    %eax,%eax
jmp    1030 <info_log@plt>
lea    0xf68(%rip),%rdi
xor    %eax,%eax
jmp    1030 <info_log@plt>
lea    0xf1f(%rip),%rdi
xor    %eax,%eax
jmp    1030 <info_log@plt>
lea    0xf6a(%rip),%rdi
xor    %eax,%eax
jmp    1030 <info_log@plt>
lea    0xe91(%rip),%rdi
xor    %eax,%eax
jmp    1030 <info_log@plt>
lea    0xec8(%rip),%rdi
xor    %eax,%eax
jmp    1030 <info_log@plt>
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
jmp    1030 <info_log@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"connect error: bad file descriptor \0A\00"
@.str.1 = [32 x i8] c"connect error: address in use \0A\00"
@.str.2 = [45 x i8] c"connect error: connect already in progress \0A\00"
@.str.3 = [30 x i8] c"connect error: address fault\0A\00"
@.str.4 = [29 x i8] c"connect error: not a socket\0A\00"
@.str.5 = [30 x i8] c"connect error: socket in use\0A\00"
@.str.6 = [35 x i8] c"connect error: connection refused\0A\00"
@.str.7 = [37 x i8] c"connect error: connection timed out\0A\00"
@.str.8 = [36 x i8] c"connect error: network unreachable\0A\00"
@.str.9 = [20 x i8] c"unknown errror(%i)\0A\00"
define void @connect_error(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %22 [
i32 134, label %4
i32 136, label %6
i32 135, label %8
i32 132, label %10
i32 129, label %12
i32 131, label %14
i32 133, label %16
i32 128, label %18
i32 130, label %20
]
4: ; preds = %1
%5 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %25
6: ; preds = %1
%7 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %25
8: ; preds = %1
%9 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
br label %25
10: ; preds = %1
%11 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %25
12: ; preds = %1
%13 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %25
14: ; preds = %1
%15 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
br label %25
16: ; preds = %1
%17 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %25
18: ; preds = %1
%19 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %25
20: ; preds = %1
%21 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %25
22: ; preds = %1
%23 = load i32, i32* %2
%24 = call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %22, %20, %18, %16, %14, %12, %10, %8, %6, %4
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"connect error: bad file descriptor \0A\00"
@.str.1 = [32 x i8] c"connect error: address in use \0A\00"
@.str.2 = [45 x i8] c"connect error: connect already in progress \0A\00"
@.str.3 = [30 x i8] c"connect error: address fault\0A\00"
@.str.4 = [29 x i8] c"connect error: not a socket\0A\00"
@.str.5 = [30 x i8] c"connect error: socket in use\0A\00"
@.str.6 = [35 x i8] c"connect error: connection refused\0A\00"
@.str.7 = [37 x i8] c"connect error: connection timed out\0A\00"
@.str.8 = [36 x i8] c"connect error: network unreachable\0A\00"
@.str.9 = [20 x i8] c"unknown errror(%i)\0A\00"
define void @connect_error(i32 %0) {
switch i32 %0, label %20 [
i32 134, label %2
i32 136, label %4
i32 135, label %6
i32 132, label %8
i32 129, label %10
i32 131, label %12
i32 133, label %14
i32 128, label %16
i32 130, label %18
]
2: ; preds = %1
%3 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %22
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %22
6: ; preds = %1
%7 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
br label %22
8: ; preds = %1
%9 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %22
10: ; preds = %1
%11 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %22
12: ; preds = %1
%13 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
br label %22
14: ; preds = %1
%15 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %22
16: ; preds = %1
%17 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0))
br label %22
18: ; preds = %1
%19 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %22
20: ; preds = %1
%21 = tail call i32 (i8*, ...) @info_log(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %0)
br label %22
22: ; preds = %20, %18, %16, %14, %12, %10, %8, %6, %4, %2
ret void
}