#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 {
  int dummy;
};
struct addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ ai_socktype;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ so_reuseaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int close(int);
int connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
scalar_t__ getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int getsockname(int, struct sockaddr *, int *);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int read(int, char *, int);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int write(int, char *, int);
int registerToMM(char *MM_IP, char *MM_port, char map_nr,
                 struct sockaddr_storage *my_IP) {
  int sock;
  struct addrinfo *addr, hints;
  char message[2];
  socklen_t my_IP_len = sizeof(struct sockaddr_storage);
  int so_reuseaddr = 1;
  message[0] = 'S';
  message[1] = map_nr;
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  if (getaddrinfo(MM_IP, MM_port, &hints, &addr) != 0) {
    perror("getaddrinfo");
    return -1;
  }
  if ((sock = socket(addr->ai_family, SOCK_STREAM, 0)) < 0) {
    perror("MM socket, create");
    return -1;
  }
  if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &so_reuseaddr,
                 sizeof(so_reuseaddr)) == -1) {
    perror("setsockopt");
    exit(EXIT_FAILURE);
  }
  if (connect(sock, addr->ai_addr, addr->ai_addrlen) == -1) {
    perror("MM socket, connect");
    return -1;
  }
  if (write(sock, message, 2) == -1) {
    perror("MM socket, write");
    return -1;
  }
  if (read(sock, message, 1) == -1) {
    perror("MM socket, read");
    return -1;
  }
  if (message[0] == 'O') {
    if (getsockname(sock, (struct sockaddr *)my_IP, &my_IP_len) == -1) {
      perror("getsockname");
      return -1;
    }
    if (close(sock) == -1) {
      perror("close");
    }
    freeaddrinfo(addr);
    return 0;
  } else {
    if (close(sock) == -1) {
      perror("close");
    }
    return -2;
  }
}


x86 assembly (clang, -O0):
<registerToMM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %dl,%al
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %al,-0x19(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x4,-0x50(%rbp)
movl   $0x1,-0x54(%rbp)
movb   $0x53,-0x4a(%rbp)
mov    -0x19(%rbp),%al
mov    %al,-0x49(%rbp)
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    0x2dd8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x48(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   10c0 <getaddrinfo@plt>
cmp    $0x0,%rax
je     1250 <registerToMM+0x90>
lea    0xdc1(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1400 <registerToMM+0x240>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%edi
mov    0x2d72(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jge    128b <registerToMM+0xcb>
lea    0xd92(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1400 <registerToMM+0x240>
mov    -0x2c(%rbp),%edi
mov    0x2d53(%rip),%rax
mov    (%rax),%esi
mov    0x2d22(%rip),%rax
mov    (%rax),%edx
lea    -0x54(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    12d2 <registerToMM+0x112>
lea    0xd5f(%rip),%rdi
call   1080 <perror@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x2c(%rbp),%edi
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x38(%rbp),%rax
mov    (%rax),%edx
call   10b0 <connect@plt>
cmp    $0xffffffff,%eax
jne    1308 <registerToMM+0x148>
lea    0xd32(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1400 <registerToMM+0x240>
mov    -0x2c(%rbp),%edi
lea    -0x4a(%rbp),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
jne    133a <registerToMM+0x17a>
lea    0xd13(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1400 <registerToMM+0x240>
mov    -0x2c(%rbp),%edi
lea    -0x4a(%rbp),%rsi
mov    $0x1,%edx
call   1070 <read@plt>
cmp    $0xffffffff,%eax
jne    136c <registerToMM+0x1ac>
lea    0xcf2(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1400 <registerToMM+0x240>
movsbl -0x4a(%rbp),%eax
cmp    $0x4f,%eax
jne    13dc <registerToMM+0x21c>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1090 <getsockname@plt>
cmp    $0xffffffff,%eax
jne    13aa <registerToMM+0x1ea>
lea    0xcc4(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1400 <registerToMM+0x240>
mov    -0x2c(%rbp),%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    13c7 <registerToMM+0x207>
lea    0xca7(%rip),%rdi
call   1080 <perror@plt>
mov    -0x38(%rbp),%rdi
call   10d0 <freeaddrinfo@plt>
movl   $0x0,-0x4(%rbp)
jmp    1400 <registerToMM+0x240>
mov    -0x2c(%rbp),%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    13f9 <registerToMM+0x239>
lea    0xc75(%rip),%rdi
call   1080 <perror@plt>
movl   $0xfffffffe,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<registerToMM>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rcx,%r14
mov    %rsi,%rbp
mov    %rdi,%rbx
movl   $0x4,0x1c(%rsp)
movl   $0x1,0x18(%rsp)
movb   $0x53,0xe(%rsp)
mov    %dl,0xf(%rsp)
lea    0x20(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    0x2dd7(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    0x2dba(%rip),%r12
mov    (%r12),%eax
mov    %eax,0x2c(%rsp)
lea    0x10(%rsp),%rcx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   10c0 <getaddrinfo@plt>
test   %rax,%rax
jne    1322 <registerToMM+0x162>
mov    0x10(%rsp),%rax
mov    0x8(%rax),%edi
mov    (%r12),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
test   %eax,%eax
js     132b <registerToMM+0x16b>
mov    %eax,%ebp
mov    0x2d8a(%rip),%rax
mov    (%rax),%esi
mov    0x2d59(%rip),%rax
mov    (%rax),%edx
lea    0x18(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     1380 <registerToMM+0x1c0>
mov    0x10(%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %ebp,%edi
call   10b0 <connect@plt>
cmp    $0xffffffff,%eax
je     1334 <registerToMM+0x174>
lea    0xe(%rsp),%rsi
mov    %ebp,%edi
mov    $0x2,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
je     133d <registerToMM+0x17d>
lea    0xe(%rsp),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1070 <read@plt>
cmp    $0xffffffff,%eax
je     1346 <registerToMM+0x186>
cmpb   $0x4f,0xe(%rsp)
jne    1303 <registerToMM+0x143>
lea    0x1c(%rsp),%rdx
mov    %ebp,%edi
mov    %r14,%rsi
call   1090 <getsockname@plt>
cmp    $0xffffffff,%eax
je     134f <registerToMM+0x18f>
mov    %ebp,%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
je     136f <registerToMM+0x1af>
mov    0x10(%rsp),%rdi
call   10d0 <freeaddrinfo@plt>
xor    %ebx,%ebx
jmp    1360 <registerToMM+0x1a0>
mov    %ebp,%edi
call   1060 <close@plt>
mov    $0xfffffffe,%ebx
cmp    $0xffffffff,%eax
jne    1360 <registerToMM+0x1a0>
lea    0xd4e(%rip),%rdi
call   1080 <perror@plt>
jmp    1360 <registerToMM+0x1a0>
lea    0xcd7(%rip),%rdi
jmp    1356 <registerToMM+0x196>
lea    0xcda(%rip),%rdi
jmp    1356 <registerToMM+0x196>
lea    0xcee(%rip),%rdi
jmp    1356 <registerToMM+0x196>
lea    0xcf8(%rip),%rdi
jmp    1356 <registerToMM+0x196>
lea    0xd00(%rip),%rdi
jmp    1356 <registerToMM+0x196>
lea    0xd07(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcf3(%rip),%rdi
call   1080 <perror@plt>
jmp    12f5 <registerToMM+0x135>
lea    0xc97(%rip),%rdi
call   1080 <perror@plt>
mov    0x2c35(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i32, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str = [12 x i8] c"getaddrinfo\00"
@.str.1 = [18 x i8] c"MM socket, create\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [11 x i8] c"setsockopt\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [19 x i8] c"MM socket, connect\00"
@.str.4 = [17 x i8] c"MM socket, write\00"
@.str.5 = [16 x i8] c"MM socket, read\00"
@.str.6 = [12 x i8] c"getsockname\00"
@.str.7 = [6 x i8] c"close\00"
define i32 @registerToMM(i8* %0, i8* %1, i8 signext %2, %struct.sockaddr_storage* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8
%9 = alloca %struct.sockaddr_storage*
%10 = alloca i32
%11 = alloca %struct.addrinfo*
%12 = alloca %struct.addrinfo
%13 = alloca [2 x i8]
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8 %2, i8* %8
store %struct.sockaddr_storage* %3, %struct.sockaddr_storage** %9
store i32 4, i32* %14
store i32 1, i32* %15
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
store i8 83, i8* %16
%17 = load i8, i8* %8
%18 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 1
store i8 %17, i8* %18
%19 = call i32 @memset(%struct.addrinfo* %12, i32 0, i32 16)
%20 = load i32, i32* @AF_UNSPEC
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 2
store i32 %20, i32* %21
%22 = load i32, i32* @SOCK_STREAM
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %12, i32 0, i32 3
store i32 %22, i32* %23
%24 = load i8*, i8** %6
%25 = load i8*, i8** %7
%26 = call i64 @getaddrinfo(i8* %24, i8* %25, %struct.addrinfo* %12, %struct.addrinfo** %11)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %4
%29 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %5
br label %104
30: ; preds = %4
%31 = load %struct.addrinfo*, %struct.addrinfo** %11
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %31, i32 0, i32 2
%33 = load i32, i32* %32
%34 = load i32, i32* @SOCK_STREAM
%35 = call i32 @socket(i32 %33, i32 %34, i32 0)
store i32 %35, i32* %10
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %30
%38 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %104
39: ; preds = %30
%40 = load i32, i32* %10
%41 = load i32, i32* @SOL_SOCKET
%42 = load i32, i32* @SO_REUSEADDR
%43 = call i32 @setsockopt(i32 %40, i32 %41, i32 %42, i32* %15, i32 4)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %49
45: ; preds = %39
%46 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %39
%50 = load i32, i32* %10
%51 = load %struct.addrinfo*, %struct.addrinfo** %11
%52 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %51, i32 0, i32 1
%53 = load i32, i32* %52
%54 = load %struct.addrinfo*, %struct.addrinfo** %11
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %54, i32 0, i32 0
%56 = load i32, i32* %55
%57 = call i32 @connect(i32 %50, i32 %53, i32 %56)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %61
59: ; preds = %49
%60 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %5
br label %104
61: ; preds = %49
%62 = load i32, i32* %10
%63 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%64 = call i32 @write(i32 %62, i8* %63, i32 2)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %68
66: ; preds = %61
%67 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %5
br label %104
68: ; preds = %61
%69 = load i32, i32* %10
%70 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%71 = call i32 @read(i32 %69, i8* %70, i32 1)
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %75
73: ; preds = %68
%74 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %5
br label %104
75: ; preds = %68
%76 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
%79 = icmp eq i32 %78, 79
br i1 %79, label %80, label %97
80: ; preds = %75
%81 = load i32, i32* %10
%82 = load %struct.sockaddr_storage*, %struct.sockaddr_storage** %9
%83 = bitcast %struct.sockaddr_storage* %82 to %struct.sockaddr*
%84 = call i32 @getsockname(i32 %81, %struct.sockaddr* %83, i32* %14)
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %88
86: ; preds = %80
%87 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %5
br label %104
88: ; preds = %80
%89 = load i32, i32* %10
%90 = call i32 @close(i32 %89)
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %94
92: ; preds = %88
%93 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %94
94: ; preds = %92, %88
%95 = load %struct.addrinfo*, %struct.addrinfo** %11
%96 = call i32 @freeaddrinfo(%struct.addrinfo* %95)
store i32 0, i32* %5
br label %104
97: ; preds = %75
%98 = load i32, i32* %10
%99 = call i32 @close(i32 %98)
%100 = icmp eq i32 %99, -1
br i1 %100, label %101, label %103
101: ; preds = %97
%102 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %103
103: ; preds = %101, %97
store i32 -2, i32* %5
br label %104
104: ; preds = %103, %94, %86, %73, %66, %59, %37, %28
%105 = load i32, i32* %5
ret i32 %105
}

LLVM IR (-O2):
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i32, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str = [12 x i8] c"getaddrinfo\00"
@.str.1 = [18 x i8] c"MM socket, create\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [11 x i8] c"setsockopt\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [19 x i8] c"MM socket, connect\00"
@.str.4 = [17 x i8] c"MM socket, write\00"
@.str.5 = [16 x i8] c"MM socket, read\00"
@.str.6 = [12 x i8] c"getsockname\00"
@.str.7 = [6 x i8] c"close\00"
define i32 @registerToMM(i8* %0, i8* %1, i8 signext %2, %struct.sockaddr_storage* %3) {
%5 = alloca %struct.addrinfo*
%6 = alloca %struct.addrinfo
%7 = alloca [2 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = bitcast %struct.addrinfo** %5 to i8*
%11 = bitcast %struct.addrinfo* %6 to i8*
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%13 = bitcast i32* %8 to i8*
store i32 4, i32* %8
%14 = bitcast i32* %9 to i8*
store i32 1, i32* %9
store i8 83, i8* %12
%15 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 1
store i8 %2, i8* %15
%16 = call i32 @memset(%struct.addrinfo* %6, i32 0, i32 16)
%17 = load i32, i32* @AF_UNSPEC
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i64 0, i32 2
store i32 %17, i32* %18
%19 = load i32, i32* @SOCK_STREAM
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i64 0, i32 3
store i32 %19, i32* %20
%21 = call i64 @getaddrinfo(i8* %0, i8* %1, %struct.addrinfo* %6, %struct.addrinfo** %5)
%22 = icmp eq i64 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %4
%24 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %85
25: ; preds = %4
%26 = load %struct.addrinfo*, %struct.addrinfo** %5
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %26, i64 0, i32 2
%28 = load i32, i32* %27
%29 = load i32, i32* @SOCK_STREAM
%30 = call i32 @socket(i32 %28, i32 %29, i32 0)
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %25
%33 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %85
34: ; preds = %25
%35 = load i32, i32* @SOL_SOCKET
%36 = load i32, i32* @SO_REUSEADDR
%37 = call i32 @setsockopt(i32 %30, i32 %35, i32 %36, i32* %9, i32 4)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %43
39: ; preds = %34
%40 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %34
%44 = load %struct.addrinfo*, %struct.addrinfo** %5
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i64 0, i32 1
%46 = load i32, i32* %45
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i64 0, i32 0
%48 = load i32, i32* %47
%49 = call i32 @connect(i32 %30, i32 %46, i32 %48)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %53
51: ; preds = %43
%52 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %85
53: ; preds = %43
%54 = call i32 @write(i32 %30, i8* %12, i32 2)
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %85
58: ; preds = %53
%59 = call i32 @read(i32 %30, i8* %12, i32 1)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %85
63: ; preds = %58
%64 = load i8, i8* %12
%65 = icmp eq i8 %64, 79
br i1 %65, label %66, label %80
66: ; preds = %63
%67 = bitcast %struct.sockaddr_storage* %3 to %struct.sockaddr*
%68 = call i32 @getsockname(i32 %30, %struct.sockaddr* %67, i32* %8)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %72
70: ; preds = %66
%71 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %85
72: ; preds = %66
%73 = call i32 @close(i32 %30)
%74 = icmp eq i32 %73, -1
br i1 %74, label %75, label %77
75: ; preds = %72
%76 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %77
77: ; preds = %75, %72
%78 = load %struct.addrinfo*, %struct.addrinfo** %5
%79 = call i32 @freeaddrinfo(%struct.addrinfo* %78)
br label %85
80: ; preds = %63
%81 = call i32 @close(i32 %30)
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %85
83: ; preds = %80
%84 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %85
85: ; preds = %80, %83, %77, %70, %61, %56, %51, %32, %23
%86 = phi i32 [ -1, %23 ], [ -1, %32 ], [ -1, %51 ], [ -1, %56 ], [ -1, %61 ], [ -1, %70 ], [ 0, %77 ], [ -2, %83 ], [ -2, %80 ]
ret i32 %86
}