#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 */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct in_addr {
  int dummy;
};
struct hostent {
  scalar_t__ *h_addr_list;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ SOCK_STREAM;
int close(int);
int connect(int, struct sockaddr *, size_t);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(int /*<<< orphan*/);
int /*<<< orphan*/ inet_ntoa(struct in_addr);
int ntohl(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, void *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  struct hostent *server_resolve;
  struct in_addr *server_address;
  struct sockaddr_in server;
  size_t address_length;
  int server_socket, result, bytes_read = 0, connection_counter = 0;
  if (argc < 2) {
    printf("Usage: %s hostname\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  server_resolve = gethostbyname(argv[1]);
  if (server_resolve == NULL) {
    fprintf(stderr, "Address not found for %s\n", argv[1]);
    exit(EXIT_FAILURE);
  }
  server_address = (struct in_addr *)server_resolve->h_addr_list[0];
  server.sin_family = AF_INET;
  server.sin_port = htons(2342);
  server.sin_addr.s_addr = inet_addr(inet_ntoa(*server_address));
  server_socket = socket(AF_INET, SOCK_STREAM, 0);
  if (server_socket == -1) {
    perror("Error creating socket");
    exit(EXIT_FAILURE);
  }
  address_length = sizeof(struct sockaddr_in);
  if (connect(server_socket, (struct sockaddr *)&server, address_length) ==
      -1) {
    perror("Error connecting to server");
    exit(EXIT_FAILURE);
  }
  while (bytes_read < sizeof(int)) {
    result = read(server_socket, (void *)(&connection_counter - bytes_read),
                  sizeof(int) - bytes_read);
    if (result == -1) {
      perror("Read from connection error");
      exit(EXIT_FAILURE);
    } else if (result == 0) {
      fprintf(stderr, "There was nothing to read\n");
      exit(EXIT_FAILURE);
    }
    bytes_read = bytes_read + result;
  }
  printf("I received: %d\n", ntohl(connection_counter));
  if (close(server_socket) == -1) {
    perror("Error closing connection");
    exit(EXIT_FAILURE);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1221 <main+0x51>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <gethostbyname@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    126a <main+0x9a>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdbf(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2d69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    $0x926,%edi
call   1040 <htons@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1030 <inet_ntoa@plt>
mov    %eax,%edi
call   1080 <inet_addr@plt>
mov    %eax,-0x30(%rbp)
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
mov    0x2d1a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    12e6 <main+0x116>
lea    0xd5b(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
movq   $0xc,-0x38(%rbp)
mov    -0x3c(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
jne    1321 <main+0x151>
lea    0xd36(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2cae(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
jmp    1326 <main+0x156>
movslq -0x44(%rbp),%rax
cmp    $0x4,%rax
jae    13c7 <main+0x1f7>
mov    -0x3c(%rbp),%edi
movslq -0x44(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
lea    -0x48(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
movslq -0x44(%rbp),%rcx
mov    $0x4,%eax
sub    %rcx,%rax
mov    %eax,%edx
call   1070 <read@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0xffffffff,-0x40(%rbp)
jne    1385 <main+0x1b5>
lea    0xced(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c4a(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x40(%rbp)
jne    13b4 <main+0x1e4>
mov    0x2c42(%rip),%rax
mov    (%rax),%edi
lea    0xcdb(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2c1b(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
jmp    13b9 <main+0x1e9>
mov    -0x44(%rbp),%eax
add    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    1326 <main+0x156>
mov    -0x48(%rbp),%edi
call   10e0 <ntohl@plt>
mov    %eax,%esi
lea    0xcbd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x3c(%rbp),%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    140a <main+0x23a>
lea    0xcae(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2bc5(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0x2baf(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
movl   $0x0,0x4(%rsp)
cmp    $0x1,%edi
jg     11fc <main+0x2c>
mov    (%rbx),%rsi
lea    0xe10(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1332 <main+0x162>
mov    0x8(%rbx),%rdi
call   1090 <gethostbyname@plt>
test   %rax,%rax
jne    122a <main+0x5a>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xdf6(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1332 <main+0x162>
mov    (%rax),%rax
mov    (%rax),%rbx
mov    0x2db1(%rip),%rbp
mov    0x0(%rbp),%eax
mov    %eax,0x10(%rsp)
mov    $0x926,%edi
call   1040 <htons@plt>
mov    %eax,0xc(%rsp)
mov    (%rbx),%edi
call   1030 <inet_ntoa@plt>
mov    %eax,%edi
call   1080 <inet_addr@plt>
mov    %eax,0x8(%rsp)
mov    0x0(%rbp),%edi
mov    0x2d68(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
cmp    $0xffffffff,%eax
jne    1282 <main+0xb2>
lea    0xdb1(%rip),%rdi
jmp    132d <main+0x15d>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    $0xc,%edx
mov    %eax,%edi
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
jne    12a6 <main+0xd6>
lea    0xda3(%rip),%rdi
jmp    132d <main+0x15d>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
shl    $0x2,%rax
neg    %rax
lea    (%rsp,%rax,1),%rsi
add    $0x4,%rsi
mov    $0x4,%edx
sub    %ebp,%edx
mov    %ebx,%edi
call   1070 <read@plt>
test   %eax,%eax
je     130d <main+0x13d>
cmp    $0xffffffff,%eax
je     1326 <main+0x156>
add    %eax,%ebp
cmp    $0x4,%ebp
jb     12b0 <main+0xe0>
mov    0x4(%rsp),%edi
call   10e0 <ntohl@plt>
lea    0xda6(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    1340 <main+0x170>
lea    0xd9a(%rip),%rdi
jmp    132d <main+0x15d>
mov    0x2cc4(%rip),%rax
mov    (%rax),%edi
lea    0xd5d(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1332 <main+0x162>
lea    0xd32(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0x2c79(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.hostent = type { i64* }
%struct.in_addr = type { i32 }
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [20 x i8] c"Usage: %s hostname\0A\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.1 = [26 x i8] c"Address not found for %s\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [22 x i8] c"Error creating socket\00"
@.str.3 = [27 x i8] c"Error connecting to server\00"
@.str.4 = [27 x i8] c"Read from connection error\00"
@.str.5 = [27 x i8] c"There was nothing to read\0A\00"
@.str.6 = [16 x i8] c"I received: %d\0A\00"
@.str.7 = [25 x i8] c"Error closing connection\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.hostent*
%7 = alloca %struct.in_addr*
%8 = alloca %struct.sockaddr_in
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %12
store i32 0, i32* %13
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %23
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call %struct.hostent* @gethostbyname(i8* %26)
store %struct.hostent* %27, %struct.hostent** %6
%28 = load %struct.hostent*, %struct.hostent** %6
%29 = icmp eq %struct.hostent* %28, null
br i1 %29, label %30, label %38
30: ; preds = %23
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([26 x i8], [26 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 = %23
%39 = load %struct.hostent*, %struct.hostent** %6
%40 = getelementptr inbounds %struct.hostent, %struct.hostent* %39, i32 0, i32 0
%41 = load i64*, i64** %40
%42 = getelementptr inbounds i64, i64* %41, i64 0
%43 = load i64, i64* %42
%44 = inttoptr i64 %43 to %struct.in_addr*
store %struct.in_addr* %44, %struct.in_addr** %7
%45 = load i32, i32* @AF_INET
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %45, i32* %46
%47 = call i32 @htons(i32 2342)
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
store i32 %47, i32* %48
%49 = load %struct.in_addr*, %struct.in_addr** %7
%50 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %49, i32 0, i32 0
%51 = load i32, i32* %50
%52 = call i32 @inet_ntoa(i32 %51)
%53 = call i32 @inet_addr(i32 %52)
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%55 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %54, i32 0, i32 0
store i32 %53, i32* %55
%56 = load i32, i32* @AF_INET
%57 = load i32, i32* @SOCK_STREAM
%58 = call i32 @socket(i32 %56, i32 %57, i32 0)
store i32 %58, i32* %10
%59 = load i32, i32* %10
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %65
61: ; preds = %38
%62 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
%64 = call i32 @exit(i32 %63)
unreachable
65: ; preds = %38
store i64 12, i64* %9
%66 = load i32, i32* %10
%67 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%68 = load i64, i64* %9
%69 = call i32 @connect(i32 %66, %struct.sockaddr* %67, i64 %68)
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %75
71: ; preds = %65
%72 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%73 = load i32, i32* @EXIT_FAILURE
%74 = call i32 @exit(i32 %73)
unreachable
75: ; preds = %65
br label %76
76: ; preds = %107, %75
%77 = load i32, i32* %12
%78 = sext i32 %77 to i64
%79 = icmp ult i64 %78, 4
br i1 %79, label %80, label %111
80: ; preds = %76
%81 = load i32, i32* %10
%82 = load i32, i32* %12
%83 = sext i32 %82 to i64
%84 = sub i64 0, %83
%85 = getelementptr inbounds i32, i32* %13, i64 %84
%86 = bitcast i32* %85 to i8*
%87 = load i32, i32* %12
%88 = sext i32 %87 to i64
%89 = sub i64 4, %88
%90 = trunc i64 %89 to i32
%91 = call i32 @read(i32 %81, i8* %86, i32 %90)
store i32 %91, i32* %11
%92 = load i32, i32* %11
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %98
94: ; preds = %80
%95 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%96 = load i32, i32* @EXIT_FAILURE
%97 = call i32 @exit(i32 %96)
unreachable
98: ; preds = %80
%99 = load i32, i32* %11
%100 = icmp eq i32 %99, 0
br i1 %100, label %101, label %106
101: ; preds = %98
%102 = load i32, i32* @stderr
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%104 = load i32, i32* @EXIT_FAILURE
%105 = call i32 @exit(i32 %104)
unreachable
106: ; preds = %98
br label %107
107: ; preds = %106
%108 = load i32, i32* %12
%109 = load i32, i32* %11
%110 = add nsw i32 %108, %109
store i32 %110, i32* %12
br label %76
111: ; preds = %76
%112 = load i32, i32* %13
%113 = call i32 @ntohl(i32 %112)
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %113)
%115 = load i32, i32* %10
%116 = call i32 @close(i32 %115)
%117 = icmp eq i32 %116, -1
br i1 %117, label %118, label %122
118: ; preds = %111
%119 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%120 = load i32, i32* @EXIT_FAILURE
%121 = call i32 @exit(i32 %120)
unreachable
122: ; preds = %111
%123 = load i32, i32* @EXIT_SUCCESS
%124 = call i32 @exit(i32 %123)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i64* }
%struct.in_addr = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [20 x i8] c"Usage: %s hostname\0A\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.1 = [26 x i8] c"Address not found for %s\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [22 x i8] c"Error creating socket\00"
@.str.3 = [27 x i8] c"Error connecting to server\00"
@.str.4 = [27 x i8] c"Read from connection error\00"
@.str.5 = [27 x i8] c"There was nothing to read\0A\00"
@.str.6 = [16 x i8] c"I received: %d\0A\00"
@.str.7 = [25 x i8] c"Error closing connection\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call %struct.hostent* @gethostbyname(i8* %15)
%17 = icmp eq %struct.hostent* %16, null
br i1 %17, label %18, label %24
18: ; preds = %13
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %14
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %13
%25 = getelementptr inbounds %struct.hostent, %struct.hostent* %16, i64 0, i32 0
%26 = load i64*, i64** %25
%27 = load i64, i64* %26
%28 = inttoptr i64 %27 to %struct.in_addr*
%29 = load i32, i32* @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %29, i32* %30
%31 = tail call i32 @htons(i32 2342)
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %31, i32* %32
%33 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %28, i64 0, i32 0
%34 = load i32, i32* %33
%35 = tail call i32 @inet_ntoa(i32 %34)
%36 = tail call i32 @inet_addr(i32 %35)
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %36, i32* %37
%38 = load i32, i32* @AF_INET
%39 = load i32, i32* @SOCK_STREAM
%40 = tail call i32 @socket(i32 %38, i32 %39, i32 0)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %46
42: ; preds = %24
%43 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%44 = load i32, i32* @EXIT_FAILURE
%45 = tail call i32 @exit(i32 %44)
unreachable
46: ; preds = %24
%47 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%48 = call i32 @connect(i32 %40, %struct.sockaddr* %47, i64 12)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %54
50: ; preds = %46
%51 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %46, %71
%55 = phi i32 [ %72, %71 ], [ 0, %46 ]
%56 = zext i32 %55 to i64
%57 = sub nsw i64 0, %56
%58 = getelementptr inbounds i32, i32* %4, i64 %57
%59 = bitcast i32* %58 to i8*
%60 = sub nuw nsw i32 4, %55
%61 = call i32 @read(i32 %40, i8* %59, i32 %60)
switch i32 %61, label %71 [
i32 -1, label %62
i32 0, label %66
]
62: ; preds = %54
%63 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%64 = load i32, i32* @EXIT_FAILURE
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %54
%67 = load i32, i32* @stderr
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%69 = load i32, i32* @EXIT_FAILURE
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %54
%72 = add nsw i32 %61, %55
%73 = icmp ult i32 %72, 4
br i1 %73, label %54, label %74
74: ; preds = %71
%75 = load i32, i32* %4
%76 = call i32 @ntohl(i32 %75)
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %76)
%78 = call i32 @close(i32 %40)
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %84
80: ; preds = %74
%81 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%82 = load i32, i32* @EXIT_FAILURE
%83 = call i32 @exit(i32 %82)
unreachable
84: ; preds = %74
%85 = load i32, i32* @EXIT_SUCCESS
%86 = call i32 @exit(i32 %85)
unreachable
}