#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_flowinfo;
  int /*<<< orphan*/ sin6_port;
  int /*<<< orphan*/ sin6_addr;
  int /*<<< orphan*/ sin6_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ sa;

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, int);
int getsockname(int, struct sockaddr *, int *);
int /*<<< orphan*/ htons(int);
char *inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/ *, char *, int);
int inet_pton(int /*<<< orphan*/, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct sockaddr_in6 *, int /*<<< orphan*/, int);
int ntohl(int /*<<< orphan*/);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  int sock, err;
  struct sockaddr_storage ss;
  struct sockaddr_in6 sa, *sa2 = (struct sockaddr_in6 *)&ss;
  socklen_t ss_len;
  int port = 4444;
  char junk[128];
  char *dest = "::1";
  ss_len = sizeof(struct sockaddr_storage);
  sock = socket(AF_INET6, SOCK_STREAM, 0);
  if (sock == -1) {
    perror("socket");
    return 1;
  }
  if (argc >= 2)
    dest = argv[1];
  if (argc >= 3)
    port = strtol(argv[2], NULL, 10);
  err = getsockname(sock, (struct sockaddr *)&ss, &ss_len);
  if (err != 0) {
    perror("getsockname");
    return 1;
  }
  fprintf(stderr, "Socket bound to %s/%d, flowinfo 0x%x.\n",
          inet_ntop(sa2->sin6_family, &sa2->sin6_addr, junk, ss_len),
          ntohs(sa2->sin6_port), ntohl(sa2->sin6_flowinfo));
  memset(&sa, 0, sizeof(struct sockaddr_in6));
  sa.sin6_family = AF_INET6;
  sa.sin6_port = htons(port);
  err = inet_pton(AF_INET6, dest, &sa.sin6_addr);
  if (err != 1) {
    perror("inet_pton");
    return 1;
  }
  err = connect(sock, (struct sockaddr *)&sa, sizeof(sa));
  if (err == -1) {
    perror("connect");
  }
  err = getsockname(sock, (struct sockaddr *)&ss, &ss_len);
  if (err != 0) {
    perror("getsockname");
    return 1;
  }
  fprintf(stderr,
          "Socket bound to %s/%d, flowinfo 0x%x (after connect called).\n",
          inet_ntop(sa2->sin6_family, &sa2->sin6_addr, junk, ss_len),
          ntohs(sa2->sin6_port), ntohl(sa2->sin6_flowinfo));
  close(sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x115c,-0x40(%rbp)
lea    0xe01(%rip),%rax
mov    %rax,-0xc8(%rbp)
movl   $0x4,-0x3c(%rbp)
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
mov    0x2db3(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    124b <main+0x7b>
lea    0xdca(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1479 <main+0x2a9>
cmpl   $0x2,-0x8(%rbp)
jl     1264 <main+0x94>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0xc8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     1287 <main+0xb7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %eax,-0x40(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   10c0 <getsockname@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     12bc <main+0xec>
lea    0xd60(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1479 <main+0x2a9>
mov    0x2d15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xdc(%rbp)
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%edi
mov    -0x38(%rbp),%rsi
add    $0x8,%rsi
lea    -0xc0(%rbp),%rdx
mov    -0x3c(%rbp),%ecx
call   1030 <inet_ntop@plt>
mov    %rax,-0xd8(%rbp)
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%edi
call   10a0 <ntohs@plt>
mov    %eax,-0xcc(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%edi
call   10e0 <ntohl@plt>
mov    -0xdc(%rbp),%edi
mov    -0xd8(%rbp),%rdx
mov    -0xcc(%rbp),%ecx
mov    %eax,%r8d
lea    0xced(%rip),%rsi
call   1070 <fprintf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    0x2ca2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x40(%rbp),%edi
call   1040 <htons@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2c8b(%rip),%rax
mov    (%rax),%edi
mov    -0xc8(%rbp),%rsi
lea    -0x30(%rbp),%rdx
add    $0x8,%rdx
call   1090 <inet_pton@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
je     1398 <main+0x1c8>
lea    0xcb7(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1479 <main+0x2a9>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   10d0 <connect@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    13c2 <main+0x1f2>
lea    0xc8b(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   10c0 <getsockname@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     13f7 <main+0x227>
lea    0xc25(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1479 <main+0x2a9>
mov    0x2bda(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xec(%rbp)
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%edi
mov    -0x38(%rbp),%rsi
add    $0x8,%rsi
lea    -0xc0(%rbp),%rdx
mov    -0x3c(%rbp),%ecx
call   1030 <inet_ntop@plt>
mov    %rax,-0xe8(%rbp)
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%edi
call   10a0 <ntohs@plt>
mov    %eax,-0xe0(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%edi
call   10e0 <ntohl@plt>
mov    -0xec(%rbp),%edi
mov    -0xe8(%rbp),%rdx
mov    -0xe0(%rbp),%ecx
mov    %eax,%r8d
lea    0xbeb(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
movl   $0x4,0x4(%rsp)
mov    0x2df3(%rip),%r14
mov    (%r14),%edi
mov    0x2dd1(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
cmp    $0xffffffff,%eax
je     1382 <main+0x1b2>
mov    %eax,%r13d
mov    $0x115c,%r15d
cmp    $0x2,%ebx
jl     123a <main+0x6a>
mov    0x8(%rbp),%r12
je     1241 <main+0x71>
mov    0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %eax,%r15d
jmp    1241 <main+0x71>
lea    0xdbf(%rip),%r12
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
mov    %r13d,%edi
call   10c0 <getsockname@plt>
test   %eax,%eax
jne    1379 <main+0x1a9>
mov    0x2d78(%rip),%rax
mov    %r12,0x18(%rsp)
mov    (%rax),%ebx
mov    0xc(%rsp),%edi
lea    0x8(%rsp),%rsi
mov    0x4(%rsp),%ecx
lea    0x20(%rsp),%rdx
call   1030 <inet_ntop@plt>
mov    %rax,%rbp
mov    0x4(%rsp),%edi
call   10a0 <ntohs@plt>
mov    %r14,%r12
mov    %eax,%r14d
mov    (%rsp),%edi
call   10e0 <ntohl@plt>
lea    0xd78(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %r14d,%ecx
mov    %eax,%r8d
call   1070 <fprintf@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    (%r12),%eax
mov    %eax,0x14(%rsp)
mov    %r15d,%edi
call   1040 <htons@plt>
mov    %eax,0xc(%rsp)
mov    (%r12),%edi
lea    0x10(%rsp),%rdx
mov    0x18(%rsp),%rsi
call   1090 <inet_pton@plt>
cmp    $0x1,%eax
jne    138b <main+0x1bb>
lea    0x8(%rsp),%rsi
mov    %r13d,%edi
mov    $0x10,%edx
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
je     13ae <main+0x1de>
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
mov    %r13d,%edi
call   10c0 <getsockname@plt>
test   %eax,%eax
jne    1379 <main+0x1a9>
mov    0x2cb2(%rip),%rax
mov    (%rax),%r14d
mov    0xc(%rsp),%edi
mov    0x4(%rsp),%ecx
lea    0x20(%rsp),%rdx
lea    0x8(%rsp),%rsi
call   1030 <inet_ntop@plt>
mov    %rax,%rbp
mov    0x4(%rsp),%edi
call   10a0 <ntohs@plt>
mov    %eax,%ebx
mov    (%rsp),%edi
call   10e0 <ntohl@plt>
lea    0xcf3(%rip),%rsi
mov    %r14d,%edi
mov    %rbp,%rdx
mov    %ebx,%ecx
mov    %eax,%r8d
call   1070 <fprintf@plt>
mov    %r13d,%edi
call   1060 <close@plt>
xor    %eax,%eax
jmp    139c <main+0x1cc>
lea    0xc8b(%rip),%rdi
jmp    1392 <main+0x1c2>
lea    0xc7b(%rip),%rdi
jmp    1392 <main+0x1c2>
lea    0xcac(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc93(%rip),%rdi
call   10b0 <perror@plt>
jmp    130b <main+0x13b>

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr_in6 = type { i32, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [4 x i8] c"::1\00"
@AF_INET6 = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@.str.2 = [12 x i8] c"getsockname\00"
@stderr = global i32 0
@.str.3 = [39 x i8] c"Socket bound to %s/%d, flowinfo 0x%x.\0A\00"
@.str.4 = [10 x i8] c"inet_pton\00"
@.str.5 = [8 x i8] c"connect\00"
@.str.6 = [62 x i8] c"Socket bound to %s/%d, flowinfo 0x%x (after connect called).\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_storage
%9 = alloca %struct.sockaddr_in6
%10 = alloca %struct.sockaddr_in6*
%11 = alloca i32
%12 = alloca i32
%13 = alloca [128 x i8]
%14 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = bitcast %struct.sockaddr_storage* %8 to %struct.sockaddr_in6*
store %struct.sockaddr_in6* %15, %struct.sockaddr_in6** %10
store i32 4444, i32* %12
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %14
store i32 4, i32* %11
%16 = load i32, i32* @AF_INET6
%17 = load i32, i32* @SOCK_STREAM
%18 = call i32 @socket(i32 %16, i32 %17, i32 0)
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %116
23: ; preds = %2
%24 = load i32, i32* %4
%25 = icmp sge i32 %24, 2
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
store i8* %29, i8** %14
br label %30
30: ; preds = %26, %23
%31 = load i32, i32* %4
%32 = icmp sge i32 %31, 3
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32 @strtol(i8* %36, i32* null, i32 10)
store i32 %37, i32* %12
br label %38
38: ; preds = %33, %30
%39 = load i32, i32* %6
%40 = bitcast %struct.sockaddr_storage* %8 to %struct.sockaddr*
%41 = call i32 @getsockname(i32 %39, %struct.sockaddr* %40, i32* %11)
store i32 %41, i32* %7
%42 = load i32, i32* %7
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %38
%45 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %116
46: ; preds = %38
%47 = load i32, i32* @stderr
%48 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %10
%49 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %48, i32 0, i32 3
%50 = load i32, i32* %49
%51 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %10
%52 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %51, i32 0, i32 2
%53 = getelementptr inbounds [128 x i8], [128 x i8]* %13, i64 0, i64 0
%54 = load i32, i32* %11
%55 = call i8* @inet_ntop(i32 %50, i32* %52, i8* %53, i32 %54)
%56 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %10
%57 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %56, i32 0, i32 1
%58 = load i32, i32* %57
%59 = call i32 @ntohs(i32 %58)
%60 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %10
%61 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %60, i32 0, i32 0
%62 = load i32, i32* %61
%63 = call i32 @ntohl(i32 %62)
%64 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %55, i32 %59, i32 %63)
%65 = call i32 @memset(%struct.sockaddr_in6* %9, i32 0, i32 16)
%66 = load i32, i32* @AF_INET6
%67 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %9, i32 0, i32 3
store i32 %66, i32* %67
%68 = load i32, i32* %12
%69 = call i32 @htons(i32 %68)
%70 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %9, i32 0, i32 1
store i32 %69, i32* %70
%71 = load i32, i32* @AF_INET6
%72 = load i8*, i8** %14
%73 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %9, i32 0, i32 2
%74 = call i32 @inet_pton(i32 %71, i8* %72, i32* %73)
store i32 %74, i32* %7
%75 = load i32, i32* %7
%76 = icmp ne i32 %75, 1
br i1 %76, label %77, label %79
77: ; preds = %46
%78 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %116
79: ; preds = %46
%80 = load i32, i32* %6
%81 = bitcast %struct.sockaddr_in6* %9 to %struct.sockaddr*
%82 = call i32 @connect(i32 %80, %struct.sockaddr* %81, i32 16)
store i32 %82, i32* %7
%83 = load i32, i32* %7
%84 = icmp eq i32 %83, -1
br i1 %84, label %85, label %87
85: ; preds = %79
%86 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %87
87: ; preds = %85, %79
%88 = load i32, i32* %6
%89 = bitcast %struct.sockaddr_storage* %8 to %struct.sockaddr*
%90 = call i32 @getsockname(i32 %88, %struct.sockaddr* %89, i32* %11)
store i32 %90, i32* %7
%91 = load i32, i32* %7
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %95
93: ; preds = %87
%94 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %116
95: ; preds = %87
%96 = load i32, i32* @stderr
%97 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %10
%98 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %97, i32 0, i32 3
%99 = load i32, i32* %98
%100 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %10
%101 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %100, i32 0, i32 2
%102 = getelementptr inbounds [128 x i8], [128 x i8]* %13, i64 0, i64 0
%103 = load i32, i32* %11
%104 = call i8* @inet_ntop(i32 %99, i32* %101, i8* %102, i32 %103)
%105 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %10
%106 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %105, i32 0, i32 1
%107 = load i32, i32* %106
%108 = call i32 @ntohs(i32 %107)
%109 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %10
%110 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %109, i32 0, i32 0
%111 = load i32, i32* %110
%112 = call i32 @ntohl(i32 %111)
%113 = call i32 @fprintf(i32 %96, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.6, i64 0, i64 0), i8* %104, i32 %108, i32 %112)
%114 = load i32, i32* %6
%115 = call i32 @close(i32 %114)
store i32 0, i32* %3
br label %116
116: ; preds = %95, %93, %77, %44, %21
%117 = load i32, i32* %3
ret i32 %117
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr_in6 = type { i32, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [4 x i8] c"::1\00"
@AF_INET6 = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@.str.2 = [12 x i8] c"getsockname\00"
@stderr = global i32 0
@.str.3 = [39 x i8] c"Socket bound to %s/%d, flowinfo 0x%x.\0A\00"
@.str.4 = [10 x i8] c"inet_pton\00"
@.str.5 = [8 x i8] c"connect\00"
@.str.6 = [62 x i8] c"Socket bound to %s/%d, flowinfo 0x%x (after connect called).\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_storage
%4 = alloca %struct.sockaddr_in6
%5 = alloca i32
%6 = alloca [128 x i8]
%7 = bitcast %struct.sockaddr_storage* %3 to i8*
%8 = bitcast %struct.sockaddr_in6* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
store i32 4, i32* %5
%11 = load i32, i32* @AF_INET6
%12 = load i32, i32* @SOCK_STREAM
%13 = tail call i32 @socket(i32 %11, i32 %12, i32 0)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %82
17: ; preds = %2
%18 = icmp sgt i32 %0, 1
br i1 %18, label %19, label %27
19: ; preds = %17
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = icmp eq i32 %0, 2
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32 @strtol(i8* nocapture %25, i32* null, i32 10)
br label %27
27: ; preds = %17, %23, %19
%28 = phi i8* [ %21, %23 ], [ %21, %19 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %17 ]
%29 = phi i32 [ %26, %23 ], [ 4444, %19 ], [ 4444, %17 ]
%30 = bitcast %struct.sockaddr_storage* %3 to %struct.sockaddr*
%31 = call i32 @getsockname(i32 %13, %struct.sockaddr* %30, i32* %5)
%32 = icmp eq i32 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %27
%34 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %82
35: ; preds = %27
%36 = load i32, i32* @stderr
%37 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %3, i64 3, i32 0
%38 = load i32, i32* %37
%39 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %3, i64 2, i32 0
%40 = load i32, i32* %5
%41 = call i8* @inet_ntop(i32 %38, i32* %39, i8* %10, i32 %40)
%42 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %3, i64 1, i32 0
%43 = load i32, i32* %42
%44 = call i32 @ntohs(i32 %43)
%45 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %3, i64 0, i32 0
%46 = load i32, i32* %45
%47 = call i32 @ntohl(i32 %46)
%48 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %41, i32 %44, i32 %47)
%49 = call i32 @memset(%struct.sockaddr_in6* %4, i32 0, i32 16)
%50 = load i32, i32* @AF_INET6
%51 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %4, i64 0, i32 3
store i32 %50, i32* %51
%52 = call i32 @htons(i32 %29)
%53 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %4, i64 0, i32 1
store i32 %52, i32* %53
%54 = load i32, i32* @AF_INET6
%55 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %4, i64 0, i32 2
%56 = call i32 @inet_pton(i32 %54, i8* %28, i32* %55)
%57 = icmp eq i32 %56, 1
br i1 %57, label %60, label %58
58: ; preds = %35
%59 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %82
60: ; preds = %35
%61 = bitcast %struct.sockaddr_in6* %4 to %struct.sockaddr*
%62 = call i32 @connect(i32 %13, %struct.sockaddr* %61, i32 16)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %66
64: ; preds = %60
%65 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %66
66: ; preds = %64, %60
%67 = call i32 @getsockname(i32 %13, %struct.sockaddr* %30, i32* %5)
%68 = icmp eq i32 %67, 0
br i1 %68, label %71, label %69
69: ; preds = %66
%70 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %82
71: ; preds = %66
%72 = load i32, i32* @stderr
%73 = load i32, i32* %37
%74 = load i32, i32* %5
%75 = call i8* @inet_ntop(i32 %73, i32* %39, i8* %10, i32 %74)
%76 = load i32, i32* %42
%77 = call i32 @ntohs(i32 %76)
%78 = load i32, i32* %45
%79 = call i32 @ntohl(i32 %78)
%80 = call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.6, i64 0, i64 0), i8* %75, i32 %77, i32 %79)
%81 = call i32 @close(i32 %13)
br label %82
82: ; preds = %71, %69, %58, %33, %15
%83 = phi i32 [ 1, %15 ], [ 1, %33 ], [ 1, %58 ], [ 1, %69 ], [ 0, %71 ]
ret i32 %83
}