#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 sockaddr_storage {
  int dummy;
};
struct sockaddr_in6 {
  int /*<<< orphan*/ sin6_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};
struct sockaddr {
  int sa_family;
};
typedef int /*<<< orphan*/ str;

/* Variables and functions */
#define AF_INET 129
#define AF_INET6 128
int /*<<< orphan*/ EXIT_FAILURE;
int LOG_DAEMON;
int LOG_INFO;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *inet_ntop(int const, int /*<<< orphan*/ *, char *, int);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int, char *, ...);
void print_connection_info(struct sockaddr_storage *ss) {
  char str[256] = {'\0'};
  struct sockaddr *sa;
  struct sockaddr_in *sin;
  struct sockaddr_in6 *sin6;
  sa = (struct sockaddr *)ss;
  switch (sa->sa_family) {
  case AF_INET:
    syslog(LOG_INFO | LOG_DAEMON, "AF_INET.\n");
    sin = (struct sockaddr_in *)ss;
    if (NULL == inet_ntop(AF_INET, &(sin->sin_addr), str, sizeof(str))) {
      syslog(LOG_INFO | LOG_DAEMON, "inet_ntop : %s\n", strerror(errno));
      exit(EXIT_FAILURE);
    }
    break;
  case AF_INET6:
    syslog(LOG_INFO | LOG_DAEMON, "AF_INET6.\n");
    sin6 = (struct sockaddr_in6 *)ss;
    if (NULL == inet_ntop(AF_INET6, &(sin6->sin6_addr), str, sizeof(str))) {
      syslog(LOG_INFO | LOG_DAEMON, "inet_ntop : %s\n", strerror(errno));
      exit(EXIT_FAILURE);
    }
    break;
  default:
    syslog(LOG_INFO | LOG_DAEMON, "unknown type.\n");
    exit(EXIT_FAILURE);
  }
  syslog(LOG_INFO | LOG_DAEMON, "connect to %s\n", str);
}


x86 assembly (clang, -O0):
<print_connection_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
mov    %rdi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movaps %xmm0,-0x140(%rbp)
movaps %xmm0,-0x20(%rbp)
movaps %xmm0,-0x30(%rbp)
movaps %xmm0,-0x40(%rbp)
movaps %xmm0,-0x50(%rbp)
movaps %xmm0,-0x60(%rbp)
movaps %xmm0,-0x70(%rbp)
movaps %xmm0,-0x80(%rbp)
movaps %xmm0,-0x90(%rbp)
movaps %xmm0,-0xa0(%rbp)
movaps %xmm0,-0xb0(%rbp)
movaps %xmm0,-0xc0(%rbp)
movaps %xmm0,-0xd0(%rbp)
movaps %xmm0,-0xe0(%rbp)
movaps %xmm0,-0xf0(%rbp)
movaps %xmm0,-0x100(%rbp)
movaps %xmm0,-0x110(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x12c(%rbp)
sub    $0x80,%eax
je     129a <print_connection_info+0x15a>
jmp    11de <print_connection_info+0x9e>
mov    -0x12c(%rbp),%eax
sub    $0x81,%eax
jne    1340 <print_connection_info+0x200>
jmp    11f4 <print_connection_info+0xb4>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    0x2de4(%rip),%rax
or     (%rax),%edi
lea    0xdf3(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x120(%rbp),%rsi
lea    -0x110(%rbp),%rdx
mov    $0x81,%edi
mov    $0x100,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1295 <print_connection_info+0x155>
mov    0x2d77(%rip),%rax
mov    (%rax),%eax
mov    0x2d8e(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x144(%rbp)
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x144(%rbp),%edi
mov    %rax,%rdx
lea    0xd8a(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2d42(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    136e <print_connection_info+0x22e>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
mov    0x2d3e(%rip),%rax
or     (%rax),%edi
lea    0xd67(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rsi
lea    -0x110(%rbp),%rdx
mov    $0x80,%edi
mov    $0x100,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    133b <print_connection_info+0x1fb>
mov    0x2cd1(%rip),%rax
mov    (%rax),%eax
mov    0x2ce8(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x148(%rbp)
mov    0x2cc9(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x148(%rbp),%edi
mov    %rax,%rdx
lea    0xce4(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2c9c(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    136e <print_connection_info+0x22e>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
mov    0x2c98(%rip),%rax
or     (%rax),%edi
lea    0xccc(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2c69(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    0x2c53(%rip),%rax
mov    (%rax),%edi
mov    0x2c6a(%rip),%rax
or     (%rax),%edi
lea    -0x110(%rbp),%rdx
lea    0xca6(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_connection_info>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    (%rdi),%eax
cmp    $0x80,%eax
je     11f9 <print_connection_info+0xb9>
cmp    $0x81,%eax
jne    128e <print_connection_info+0x14e>
mov    0x2df4(%rip),%r14
mov    0x2e0d(%rip),%r15
mov    (%r15),%edi
or     (%r14),%edi
lea    0xe18(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
mov    %rsp,%rdx
mov    $0x81,%edi
jmp    1223 <print_connection_info+0xe3>
mov    0x2dc8(%rip),%r14
mov    0x2de1(%rip),%r15
mov    (%r15),%edi
or     (%r14),%edi
lea    0xe06(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
mov    %rsp,%rdx
mov    $0x80,%edi
mov    %rbx,%rsi
mov    $0x100,%ecx
call   1030 <inet_ntop@plt>
test   %rax,%rax
je     1265 <print_connection_info+0x125>
mov    0x2d8c(%rip),%rax
mov    0x2da5(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
lea    0xde6(%rip),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1040 <syslog@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    (%r15),%ebx
or     (%r14),%ebx
mov    0x2d66(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xd8a(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <syslog@plt>
jmp    12ae <print_connection_info+0x16e>
mov    0x2d33(%rip),%rax
mov    0x2d4c(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
lea    0xd7e(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr_in6 = type { i32 }
@LOG_INFO = global i32 0
@LOG_DAEMON = global i32 0
@.str = [10 x i8] c"AF_INET.\0A\00"
@.str.1 = [16 x i8] c"inet_ntop : %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [11 x i8] c"AF_INET6.\0A\00"
@.str.3 = [15 x i8] c"unknown type.\0A\00"
@.str.4 = [15 x i8] c"connect to %s\0A\00"
define void @print_connection_info(%struct.sockaddr_storage* %0) {
%2 = alloca %struct.sockaddr_storage*
%3 = alloca [256 x i8]
%4 = alloca %struct.sockaddr*
%5 = alloca %struct.sockaddr_in*
%6 = alloca %struct.sockaddr_in6*
store %struct.sockaddr_storage* %0, %struct.sockaddr_storage** %2
%7 = bitcast [256 x i8]* %3 to i8*
%8 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %2
%9 = bitcast %struct.sockaddr_storage* %8 to %struct.sockaddr*
store %struct.sockaddr* %9, %struct.sockaddr** %4
%10 = load %struct.sockaddr*, %struct.sockaddr** %4
%11 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %10, i32 0, i32 0
%12 = load i32, i32* %11
switch i32 %12, label %57 [
i32 129, label %13
i32 128, label %35
]
13: ; preds = %1
%14 = load i32, i32* @LOG_INFO
%15 = load i32, i32* @LOG_DAEMON
%16 = or i32 %14, %15
%17 = call i32 (i32, i8*, ...) @syslog(i32 %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%18 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %2
%19 = bitcast %struct.sockaddr_storage* %18 to %struct.sockaddr_in*
store %struct.sockaddr_in* %19, %struct.sockaddr_in** %5
%20 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %20, i32 0, i32 0
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%23 = call i32* @inet_ntop(i32 129, i32* %21, i8* %22, i32 256)
%24 = icmp eq i32* null, %23
br i1 %24, label %25, label %34
25: ; preds = %13
%26 = load i32, i32* @LOG_INFO
%27 = load i32, i32* @LOG_DAEMON
%28 = or i32 %26, %27
%29 = load i32, i32* @errno
%30 = call i8* @strerror(i32 %29)
%31 = call i32 (i32, i8*, ...) @syslog(i32 %28, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %13
br label %64
35: ; preds = %1
%36 = load i32, i32* @LOG_INFO
%37 = load i32, i32* @LOG_DAEMON
%38 = or i32 %36, %37
%39 = call i32 (i32, i8*, ...) @syslog(i32 %38, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%40 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %2
%41 = bitcast %struct.sockaddr_storage* %40 to %struct.sockaddr_in6*
store %struct.sockaddr_in6* %41, %struct.sockaddr_in6** %6
%42 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %6
%43 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %42, i32 0, i32 0
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%45 = call i32* @inet_ntop(i32 128, i32* %43, i8* %44, i32 256)
%46 = icmp eq i32* null, %45
br i1 %46, label %47, label %56
47: ; preds = %35
%48 = load i32, i32* @LOG_INFO
%49 = load i32, i32* @LOG_DAEMON
%50 = or i32 %48, %49
%51 = load i32, i32* @errno
%52 = call i8* @strerror(i32 %51)
%53 = call i32 (i32, i8*, ...) @syslog(i32 %50, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %52)
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %35
br label %64
57: ; preds = %1
%58 = load i32, i32* @LOG_INFO
%59 = load i32, i32* @LOG_DAEMON
%60 = or i32 %58, %59
%61 = call i32 (i32, i8*, ...) @syslog(i32 %60, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%62 = load i32, i32* @EXIT_FAILURE
%63 = call i32 @exit(i32 %62)
unreachable
64: ; preds = %56, %34
%65 = load i32, i32* @LOG_INFO
%66 = load i32, i32* @LOG_DAEMON
%67 = or i32 %65, %66
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%69 = call i32 (i32, i8*, ...) @syslog(i32 %67, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %68)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
@LOG_INFO = global i32 0
@LOG_DAEMON = global i32 0
@.str = [10 x i8] c"AF_INET.\0A\00"
@.str.1 = [16 x i8] c"inet_ntop : %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [11 x i8] c"AF_INET6.\0A\00"
@.str.3 = [15 x i8] c"unknown type.\0A\00"
@.str.4 = [15 x i8] c"connect to %s\0A\00"
define void @print_connection_info(%struct.sockaddr_storage* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = getelementptr %struct.sockaddr_storage, %struct.sockaddr_storage* %0, i64 0, i32 0
%5 = load i32, i32* %4
switch i32 %5, label %38 [
i32 129, label %6
i32 128, label %22
]
6: ; preds = %1
%7 = load i32, i32* @LOG_INFO
%8 = load i32, i32* @LOG_DAEMON
%9 = or i32 %8, %7
%10 = tail call i32 (i32, i8*, ...) @syslog(i32 %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%11 = call i32* @inet_ntop(i32 129, i32* %4, i8* %3, i32 256)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %45
13: ; preds = %6
%14 = load i32, i32* @LOG_INFO
%15 = load i32, i32* @LOG_DAEMON
%16 = or i32 %15, %14
%17 = load i32, i32* @errno
%18 = call i8* @strerror(i32 %17)
%19 = call i32 (i32, i8*, ...) @syslog(i32 %16, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %1
%23 = load i32, i32* @LOG_INFO
%24 = load i32, i32* @LOG_DAEMON
%25 = or i32 %24, %23
%26 = tail call i32 (i32, i8*, ...) @syslog(i32 %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32* @inet_ntop(i32 128, i32* %4, i8* %3, i32 256)
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %45
29: ; preds = %22
%30 = load i32, i32* @LOG_INFO
%31 = load i32, i32* @LOG_DAEMON
%32 = or i32 %31, %30
%33 = load i32, i32* @errno
%34 = call i8* @strerror(i32 %33)
%35 = call i32 (i32, i8*, ...) @syslog(i32 %32, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %1
%39 = load i32, i32* @LOG_INFO
%40 = load i32, i32* @LOG_DAEMON
%41 = or i32 %40, %39
%42 = tail call i32 (i32, i8*, ...) @syslog(i32 %41, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32, i32* @EXIT_FAILURE
%44 = tail call i32 @exit(i32 %43)
unreachable
45: ; preds = %22, %6
%46 = load i32, i32* @LOG_INFO
%47 = load i32, i32* @LOG_DAEMON
%48 = or i32 %47, %46
%49 = call i32 (i32, i8*, ...) @syslog(i32 %48, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %3)
ret void
}