#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_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ sa;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int getsockname(int, struct sockaddr *, int /*<<< orphan*/ *);
int /*<<< orphan*/ htons(int);
char *inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/ *, char *,
                int /*<<< orphan*/);
int inet_pton(int /*<<< orphan*/, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
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_in sa, sa2;
  socklen_t sa_len;
  int port = 4444;
  char junk[128];
  char *dest = "127.0.0.1";
  sock = socket(AF_INET, 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 *)&sa2, &sa_len);
  if (err != 0) {
    perror("getsockname");
    return 1;
  }
  fprintf(stderr, "Socket bound to %s/%d.\n",
          inet_ntop(sa2.sin_family, &sa2.sin_addr, junk, sa_len),
          ntohs(sa2.sin_port));
  memset(&sa, 0, sizeof(struct sockaddr));
  sa.sin_family = AF_INET;
  sa.sin_port = htons(port);
  err = inet_pton(AF_INET, dest, &sa.sin_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 *)&sa2, &sa_len);
  if (err != 0) {
    perror("getsockname");
    return 1;
  }
  fprintf(stderr, "Socket bound to %s/%d (after connect called).\n",
          inet_ntop(sa2.sin_family, &sa2.sin_addr, junk, sa_len),
          ntohs(sa2.sin_port));
  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)
movl   $0x115c,-0x40(%rbp)
lea    0xe19(%rip),%rax
mov    %rax,-0xc8(%rbp)
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
mov    0x2dd2(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    122c <main+0x6c>
lea    0xdef(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    141a <main+0x25a>
cmpl   $0x2,-0x8(%rbp)
jl     1245 <main+0x85>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0xc8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     1268 <main+0xa8>
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    -0x38(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   10c0 <getsockname@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     129d <main+0xdd>
lea    0xd85(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    141a <main+0x25a>
mov    0x2d34(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xd4(%rbp)
mov    -0x30(%rbp),%edi
lea    -0x38(%rbp),%rsi
add    $0x4,%rsi
lea    -0xc0(%rbp),%rdx
mov    -0x3c(%rbp),%ecx
call   1030 <inet_ntop@plt>
mov    %rax,-0xd0(%rbp)
mov    -0x38(%rbp),%edi
call   10a0 <ntohs@plt>
mov    -0xd4(%rbp),%edi
mov    -0xd0(%rbp),%rdx
mov    %eax,%ecx
lea    0xd32(%rip),%rsi
call   1070 <fprintf@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    0x2ce1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x40(%rbp),%edi
call   1040 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    0x2cca(%rip),%rax
mov    (%rax),%edi
mov    -0xc8(%rbp),%rsi
lea    -0x28(%rbp),%rdx
add    $0x4,%rdx
call   1090 <inet_pton@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
je     1359 <main+0x199>
lea    0xced(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    141a <main+0x25a>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <connect@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1383 <main+0x1c3>
lea    0xcc1(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   10c0 <getsockname@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     13b8 <main+0x1f8>
lea    0xc6a(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    141a <main+0x25a>
mov    0x2c19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xe4(%rbp)
mov    -0x30(%rbp),%edi
lea    -0x38(%rbp),%rsi
add    $0x4,%rsi
lea    -0xc0(%rbp),%rdx
mov    -0x3c(%rbp),%ecx
call   1030 <inet_ntop@plt>
mov    %rax,-0xe0(%rbp)
mov    -0x38(%rbp),%edi
call   10a0 <ntohs@plt>
mov    -0xe4(%rbp),%edi
mov    -0xe0(%rbp),%rdx
mov    %eax,%ecx
lea    0xc41(%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    $0xb8,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
mov    0x2e0b(%rip),%r14
mov    (%r14),%edi
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
cmp    $0xffffffff,%eax
je     1344 <main+0x184>
mov    %eax,%r13d
mov    $0x115c,%r12d
cmp    $0x2,%ebx
jl     1222 <main+0x62>
mov    0x8(%rbp),%r15
je     1229 <main+0x69>
mov    0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %eax,%r12d
jmp    1229 <main+0x69>
lea    0xdd7(%rip),%r15
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %r13d,%edi
call   10c0 <getsockname@plt>
test   %eax,%eax
jne    133b <main+0x17b>
mov    0x2d8e(%rip),%rax
mov    (%rax),%ebx
mov    0x18(%rsp),%edi
lea    0x14(%rsp),%rsi
mov    0xc(%rsp),%ecx
lea    0x30(%rsp),%rdx
call   1030 <inet_ntop@plt>
mov    %rax,%rbp
mov    0x10(%rsp),%edi
call   10a0 <ntohs@plt>
lea    0xda7(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %eax,%ecx
call   1070 <fprintf@plt>
lea    0x20(%rsp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    (%r14),%eax
mov    %eax,0x28(%rsp)
mov    %r12d,%edi
call   1040 <htons@plt>
mov    %eax,0x20(%rsp)
mov    (%r14),%edi
lea    0x24(%rsp),%rdx
mov    %r15,%rsi
call   1090 <inet_pton@plt>
cmp    $0x1,%eax
jne    134d <main+0x18d>
lea    0x20(%rsp),%rsi
mov    %r13d,%edi
mov    $0xc,%edx
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
je     1370 <main+0x1b0>
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %r13d,%edi
call   10c0 <getsockname@plt>
test   %eax,%eax
jne    133b <main+0x17b>
mov    0x2ce1(%rip),%rax
mov    (%rax),%ebx
mov    0x18(%rsp),%edi
mov    0xc(%rsp),%ecx
lea    0x30(%rsp),%rdx
lea    0x14(%rsp),%rsi
call   1030 <inet_ntop@plt>
mov    %rax,%rbp
mov    0x10(%rsp),%edi
call   10a0 <ntohs@plt>
lea    0xd24(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %eax,%ecx
call   1070 <fprintf@plt>
mov    %r13d,%edi
call   1060 <close@plt>
xor    %eax,%eax
jmp    135e <main+0x19e>
lea    0xccf(%rip),%rdi
jmp    1354 <main+0x194>
lea    0xcbf(%rip),%rdi
jmp    1354 <main+0x194>
lea    0xce1(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcc8(%rip),%rdi
call   10b0 <perror@plt>
jmp    12da <main+0x11a>

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

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [10 x i8] c"127.0.0.1\00"
@AF_INET = 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 = [24 x i8] c"Socket bound to %s/%d.\0A\00"
@.str.4 = [10 x i8] c"inet_pton\00"
@.str.5 = [8 x i8] c"connect\00"
@.str.6 = [47 x i8] c"Socket bound to %s/%d (after connect called).\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca [128 x i8]
%7 = bitcast %struct.sockaddr_in* %3 to i8*
%8 = bitcast %struct.sockaddr_in* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%11 = load i32, i32* @AF_INET
%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 %77
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 ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %17 ]
%29 = phi i32 [ %26, %23 ], [ 4444, %19 ], [ 4444, %17 ]
%30 = bitcast %struct.sockaddr_in* %4 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 %77
35: ; preds = %27
%36 = load i32, i32* @stderr
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
%38 = load i32, i32* %37
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
%40 = load i32, i32* %5
%41 = call i8* @inet_ntop(i32 %38, i32* %39, i8* %10, i32 %40)
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
%43 = load i32, i32* %42
%44 = call i32 @ntohs(i32 %43)
%45 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %41, i32 %44)
%46 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 4)
%47 = load i32, i32* @AF_INET
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %47, i32* %48
%49 = call i32 @htons(i32 %29)
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %49, i32* %50
%51 = load i32, i32* @AF_INET
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%53 = call i32 @inet_pton(i32 %51, i8* %28, i32* %52)
%54 = icmp eq i32 %53, 1
br i1 %54, label %57, label %55
55: ; preds = %35
%56 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %77
57: ; preds = %35
%58 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%59 = call i32 @connect(i32 %13, %struct.sockaddr* %58, i32 12)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %63
61: ; preds = %57
%62 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %63
63: ; preds = %61, %57
%64 = call i32 @getsockname(i32 %13, %struct.sockaddr* %30, i32* %5)
%65 = icmp eq i32 %64, 0
br i1 %65, label %68, label %66
66: ; preds = %63
%67 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %77
68: ; preds = %63
%69 = load i32, i32* @stderr
%70 = load i32, i32* %37
%71 = load i32, i32* %5
%72 = call i8* @inet_ntop(i32 %70, i32* %39, i8* %10, i32 %71)
%73 = load i32, i32* %42
%74 = call i32 @ntohs(i32 %73)
%75 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i8* %72, i32 %74)
%76 = call i32 @close(i32 %13)
br label %77
77: ; preds = %68, %66, %55, %33, %15
%78 = phi i32 [ 1, %15 ], [ 1, %33 ], [ 1, %55 ], [ 1, %66 ], [ 0, %68 ]
ret i32 %78
}