#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef void *uint32_t;
struct TYPE_2__ {
  void *s_addr;
};
struct sockaddr_in {
  void *sin_port;
  TYPE_1__ sin_addr;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ sendaddr;

/* Variables and functions */
void *AF_INET;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr const *, int);
void *htons(int);
int /*<<< orphan*/ memcpy(unsigned char *, void **, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int recv(int, unsigned char *, int, int /*<<< orphan*/);
int recvfromTimeOut(int, int, int /*<<< orphan*/);
scalar_t__ send(int, unsigned char *, int, int /*<<< orphan*/);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
int openDevice(uint32_t addr, uint32_t connectCode) {
  int sock;
  struct sockaddr_in sendaddr;
  unsigned char msg[64];
  int bytesReceived;
  if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    perror("openDevice: Error creating socket.");
    return -1;
  }
  memset(&sendaddr, 0, sizeof(sendaddr));
  sendaddr.sin_family = AF_INET;
  sendaddr.sin_addr.s_addr = addr;
  sendaddr.sin_port = htons(54211);
  if (connect(sock, (const struct sockaddr *)&sendaddr, sizeof(sendaddr)) < 0) {
    perror("openDevice: error in connect.");
    close(sock);
    return -1;
  }
  msg[0] = 'C';
  memcpy(&msg[1], &connectCode, 4);
  if (send(sock, msg, 5, 0) < 0) {
    perror("openDevice: Error in send.");
    close(sock);
    return -1;
  }
  switch (recvfromTimeOut(sock, 1, 0)) {
  case 0:
  case -1:
    close(sock);
    return -1;
    break;
  default:
    bytesReceived = recv(sock, msg, 64, 0);
    if ((bytesReceived == 2) && (msg[0] = 'C') && (msg[1] == 0)) {
      break;
    } else {
      close(sock);
      return -1;
    }
    break;
  }
  close(sock);
  if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
    perror("openDevice: error creating TCP socket.");
    return -1;
  }
  memset(&sendaddr, 0, sizeof(sendaddr));
  sendaddr.sin_family = AF_INET;
  sendaddr.sin_addr.s_addr = addr;
  sendaddr.sin_port = htons(54211);
  if ((connect(sock, (const struct sockaddr *)&sendaddr, sizeof(sendaddr))) <
      0) {
    perror("openDevice: can not connect to device.");
    close(sock);
    return -1;
  }
  return sock;
}


x86 assembly (clang, -O0):
<openDevice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2e2e(%rip),%rax
mov    (%rax),%rdi
mov    0x2e14(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    11f1 <openDevice+0x51>
lea    0xe20(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    140c <openDevice+0x26c>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0xd3c3,%edi
call   1050 <htons@plt>
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x18,%edx
call   10b0 <connect@plt>
cmp    $0x0,%rax
jge    1260 <openDevice+0xc0>
lea    0xddc(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    140c <openDevice+0x26c>
movb   $0x43,-0x80(%rbp)
lea    -0x80(%rbp),%rdi
add    $0x1,%rdi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1090 <memcpy@plt>
mov    -0x1c(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x5,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0x0,%rax
jge    12b7 <openDevice+0x117>
lea    0xda3(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    140c <openDevice+0x26c>
mov    -0x1c(%rbp),%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <recvfromTimeOut@plt>
add    $0x1,%eax
sub    $0x1,%eax
ja     12eb <openDevice+0x14b>
jmp    12d7 <openDevice+0x137>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    140c <openDevice+0x26c>
mov    -0x1c(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x40,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x2,-0x84(%rbp)
jne    1336 <openDevice+0x196>
movb   $0x43,-0x80(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    1324 <openDevice+0x184>
jmp    1336 <openDevice+0x196>
movzbl -0x7f(%rbp),%eax
cmp    $0x0,%eax
jne    1336 <openDevice+0x196>
jmp    134a <openDevice+0x1aa>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    140c <openDevice+0x26c>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
mov    0x2c8f(%rip),%rax
mov    (%rax),%rdi
mov    0x2c65(%rip),%rax
mov    (%rax),%esi
mov    0x2c74(%rip),%rax
mov    (%rax),%edx
call   10c0 <socket@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1397 <openDevice+0x1f7>
lea    0xcd6(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    140c <openDevice+0x26c>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    0x2c3a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0xd3c3,%edi
call   1050 <htons@plt>
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x18,%edx
call   10b0 <connect@plt>
cmp    $0x0,%rax
jge    1406 <openDevice+0x266>
lea    0xc96(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    140c <openDevice+0x26c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<openDevice>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rdi,%r14
mov    %rsi,0x18(%rsp)
mov    0x2e2f(%rip),%r15
mov    (%r15),%rdi
mov    0x2e15(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
test   %eax,%eax
js     1318 <openDevice+0x178>
mov    %eax,%ebp
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    (%r15),%rax
mov    %rax,0x10(%rsp)
mov    %r14,0x8(%rsp)
mov    $0xd3c3,%edi
call   1050 <htons@plt>
mov    %rax,(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x18,%edx
call   10b0 <connect@plt>
test   %rax,%rax
js     1329 <openDevice+0x189>
movb   $0x43,0x20(%rsp)
lea    0x21(%rsp),%rdi
lea    0x18(%rsp),%rsi
mov    $0x4,%edx
call   1090 <memcpy@plt>
lea    0x20(%rsp),%rsi
mov    %ebp,%edi
mov    $0x5,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
test   %rax,%rax
js     1332 <openDevice+0x192>
mov    %ebp,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <recvfromTimeOut@plt>
add    $0x1,%eax
cmp    $0x1,%eax
ja     127f <openDevice+0xdf>
mov    %ebp,%edi
call   1080 <close@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x20(%rsp),%rsi
mov    %ebp,%edi
mov    $0x40,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0x2,%eax
jne    1266 <openDevice+0xc6>
movb   $0x43,0x20(%rsp)
cmpb   $0x0,0x21(%rsp)
jne    1266 <openDevice+0xc6>
mov    %ebp,%edi
call   1080 <close@plt>
mov    (%r15),%rdi
mov    0x2d14(%rip),%rax
mov    (%rax),%esi
mov    0x2d23(%rip),%rax
mov    (%rax),%edx
call   10c0 <socket@plt>
test   %eax,%eax
js     1343 <openDevice+0x1a3>
mov    %eax,%ebp
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    (%r15),%rax
mov    %rax,0x10(%rsp)
mov    %r14,0x8(%rsp)
mov    $0xd3c3,%edi
call   1050 <htons@plt>
mov    %rax,(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x18,%edx
call   10b0 <connect@plt>
test   %rax,%rax
jns    1272 <openDevice+0xd2>
lea    0xd6d(%rip),%rdi
jmp    1339 <openDevice+0x199>
lea    0xce1(%rip),%rdi
call   10a0 <perror@plt>
jmp    126d <openDevice+0xcd>
lea    0xcf3(%rip),%rdi
jmp    1339 <openDevice+0x199>
lea    0xd08(%rip),%rdi
call   10a0 <perror@plt>
jmp    1266 <openDevice+0xc6>
lea    0xd12(%rip),%rdi
call   10a0 <perror@plt>
jmp    126d <openDevice+0xcd>

LLVM IR (-O0):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@.str = [35 x i8] c"openDevice: Error creating socket.\00"
@.str.1 = [30 x i8] c"openDevice: error in connect.\00"
@.str.2 = [27 x i8] c"openDevice: Error in send.\00"
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.3 = [39 x i8] c"openDevice: error creating TCP socket.\00"
@.str.4 = [39 x i8] c"openDevice: can not connect to device.\00"
define i32 @openDevice(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
%8 = alloca [64 x i8]
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i8*, i8** @AF_INET
%11 = load i32, i32* @SOCK_DGRAM
%12 = call i32 @socket(i8* %10, i32 %11, i32 0)
store i32 %12, i32* %6
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %97
16: ; preds = %2
%17 = call i32 @memset(%struct.sockaddr_in* %7, i32 0, i32 24)
%18 = load i8*, i8** @AF_INET
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i8* %18, i8** %19
%20 = load i8*, i8** %4
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%22 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %21, i32 0, i32 0
store i8* %20, i8** %22
%23 = call i8* @htons(i32 54211)
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i8* %23, i8** %24
%25 = load i32, i32* %6
%26 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%27 = call i64 @connect(i32 %25, %struct.sockaddr* %26, i32 24)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %16
%30 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* %6
%32 = call i32 @close(i32 %31)
store i32 -1, i32* %3
br label %97
33: ; preds = %16
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
store i8 67, i8* %34
%35 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 1
%36 = call i32 @memcpy(i8* %35, i8** %5, i32 4)
%37 = load i32, i32* %6
%38 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%39 = call i64 @send(i32 %37, i8* %38, i32 5, i32 0)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %33
%42 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%43 = load i32, i32* %6
%44 = call i32 @close(i32 %43)
store i32 -1, i32* %3
br label %97
45: ; preds = %33
%46 = load i32, i32* %6
%47 = call i32 @recvfromTimeOut(i32 %46, i32 1, i32 0)
switch i32 %47, label %51 [
i32 0, label %48
i32 -1, label %48
]
48: ; preds = %45, %45
%49 = load i32, i32* %6
%50 = call i32 @close(i32 %49)
store i32 -1, i32* %3
br label %97
51: ; preds = %45
%52 = load i32, i32* %6
%53 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%54 = call i32 @recv(i32 %52, i8* %53, i32 64, i32 0)
store i32 %54, i32* %9
%55 = load i32, i32* %9
%56 = icmp eq i32 %55, 2
br i1 %56, label %57, label %65
57: ; preds = %51
%58 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
store i8 67, i8* %58
br i1 true, label %59, label %65
59: ; preds = %57
%60 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 1
%61 = load i8, i8* %60
%62 = zext i8 %61 to i32
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %59
br label %68
65: ; preds = %59, %57, %51
%66 = load i32, i32* %6
%67 = call i32 @close(i32 %66)
store i32 -1, i32* %3
br label %97
68: ; preds = %64
%69 = load i32, i32* %6
%70 = call i32 @close(i32 %69)
%71 = load i8*, i8** @AF_INET
%72 = load i32, i32* @SOCK_STREAM
%73 = load i32, i32* @IPPROTO_TCP
%74 = call i32 @socket(i8* %71, i32 %72, i32 %73)
store i32 %74, i32* %6
%75 = icmp slt i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %68
%77 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %97
78: ; preds = %68
%79 = call i32 @memset(%struct.sockaddr_in* %7, i32 0, i32 24)
%80 = load i8*, i8** @AF_INET
%81 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i8* %80, i8** %81
%82 = load i8*, i8** %4
%83 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%84 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %83, i32 0, i32 0
store i8* %82, i8** %84
%85 = call i8* @htons(i32 54211)
%86 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i8* %85, i8** %86
%87 = load i32, i32* %6
%88 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%89 = call i64 @connect(i32 %87, %struct.sockaddr* %88, i32 24)
%90 = icmp slt i64 %89, 0
br i1 %90, label %91, label %95
91: ; preds = %78
%92 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
%93 = load i32, i32* %6
%94 = call i32 @close(i32 %93)
store i32 -1, i32* %3
br label %97
95: ; preds = %78
%96 = load i32, i32* %6
store i32 %96, i32* %3
br label %97
97: ; preds = %95, %91, %76, %65, %48, %41, %29, %14
%98 = load i32, i32* %3
ret i32 %98
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i8*, %struct.TYPE_2__, i8* }
%struct.TYPE_2__ = type { i8* }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@.str = [35 x i8] c"openDevice: Error creating socket.\00"
@.str.1 = [30 x i8] c"openDevice: error in connect.\00"
@.str.2 = [27 x i8] c"openDevice: Error in send.\00"
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.3 = [39 x i8] c"openDevice: error creating TCP socket.\00"
@.str.4 = [39 x i8] c"openDevice: can not connect to device.\00"
define i32 @openDevice(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca %struct.sockaddr_in
%5 = alloca [64 x i8]
store i8* %1, i8** %3
%6 = bitcast %struct.sockaddr_in* %4 to i8*
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%8 = load i8*, i8** @AF_INET
%9 = load i32, i32* @SOCK_DGRAM
%10 = tail call i32 @socket(i8* %8, i32 %9, i32 0)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = tail call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %65
14: ; preds = %2
%15 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 24)
%16 = load i8*, i8** @AF_INET
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i8* %16, i8** %17
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i8* %0, i8** %18
%19 = call i8* @htons(i32 54211)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i8* %19, i8** %20
%21 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%22 = call i64 @connect(i32 %10, %struct.sockaddr* %21, i32 24)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %14
%25 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @close(i32 %10)
br label %65
27: ; preds = %14
store i8 67, i8* %7
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 1
%29 = call i32 @memcpy(i8* %28, i8** %3, i32 4)
%30 = call i64 @send(i32 %10, i8* %7, i32 5, i32 0)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%34 = call i32 @close(i32 %10)
br label %65
35: ; preds = %27
%36 = call i32 @recvfromTimeOut(i32 %10, i32 1, i32 0)
switch i32 %36, label %39 [
i32 0, label %37
i32 -1, label %37
]
37: ; preds = %35, %35
%38 = call i32 @close(i32 %10)
br label %65
39: ; preds = %35
%40 = call i32 @recv(i32 %10, i8* %7, i32 64, i32 0)
%41 = icmp eq i32 %40, 2
br i1 %41, label %42, label %45
42: ; preds = %39
store i8 67, i8* %7
%43 = load i8, i8* %28
%44 = icmp eq i8 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %42, %39
%46 = call i32 @close(i32 %10)
br label %65
47: ; preds = %42
%48 = call i32 @close(i32 %10)
%49 = load i8*, i8** @AF_INET
%50 = load i32, i32* @SOCK_STREAM
%51 = load i32, i32* @IPPROTO_TCP
%52 = call i32 @socket(i8* %49, i32 %50, i32 %51)
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %47
%55 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
br label %65
56: ; preds = %47
%57 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 24)
%58 = load i8*, i8** @AF_INET
store i8* %58, i8** %17
store i8* %0, i8** %18
%59 = call i8* @htons(i32 54211)
store i8* %59, i8** %20
%60 = call i64 @connect(i32 %52, %struct.sockaddr* %21, i32 24)
%61 = icmp slt i64 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %56
%63 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
%64 = call i32 @close(i32 %52)
br label %65
65: ; preds = %56, %62, %54, %45, %37, %32, %24, %12
%66 = phi i32 [ -1, %12 ], [ -1, %24 ], [ -1, %32 ], [ -1, %54 ], [ -1, %62 ], [ -1, %45 ], [ -1, %37 ], [ %52, %56 ]
ret i32 %66
}