#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 s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ clientAddress;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int EXIT_FAILURE;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ argString(char *, int, int, char **);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ write(int, char *, int);
int main(int argc, char **argv) {
  int client;
  struct sockaddr_in clientAddress;
  char message[128];
  memset(&clientAddress, 0, sizeof(clientAddress));
  clientAddress.sin_family = AF_INET;
  clientAddress.sin_addr.s_addr =
      (((192) << 0) + ((168) << 8) + ((178) << 16) + ((45) << 24));
  clientAddress.sin_port = htons(9025);
  client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (client < 0)
    return EXIT_FAILURE;
  if (connect(client, (struct sockaddr *)&clientAddress,
              sizeof(clientAddress)) < 0) {
    close(client);
    return EXIT_FAILURE;
  }
  argString(message, 128, argc - 1, argv + 1);
  if (write(client, message, 128) <= 0) {
    close(client);
    return EXIT_FAILURE;
  }
  if (read(client, message, 128) <= 0) {
    close(client);
    return EXIT_FAILURE;
  }
  printf("%s", message);
  close(client);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movl   $0x2db2a8c0,-0x1c(%rbp)
mov    $0x2341,%edi
call   1040 <htons@plt>
mov    %eax,-0x20(%rbp)
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
mov    0x2de7(%rip),%rax
mov    (%rax),%esi
mov    0x2dee(%rip),%rax
mov    (%rax),%edx
call   10b0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1217 <main+0x87>
mov    0x2dbb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f3 <main+0x163>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   10a0 <connect@plt>
cmp    $0x0,%rax
jge    124b <main+0xbb>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f3 <main+0x163>
lea    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
mov    -0x10(%rbp),%rcx
add    $0x8,%rcx
mov    $0x80,%esi
call   1090 <argString@plt>
mov    -0x14(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x80,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jg     12a1 <main+0x111>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    0x2d31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f3 <main+0x163>
mov    -0x14(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x80,%edx
call   1080 <read@plt>
cmp    $0x0,%rax
jg     12d8 <main+0x148>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    0x2cfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f3 <main+0x163>
lea    -0xa0(%rbp),%rsi
lea    0xd1a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2e30(%rip),%rbx
mov    (%rbx),%eax
mov    %eax,0x8(%rsp)
movl   $0x2db2a8c0,0x4(%rsp)
2d
mov    $0x2341,%edi
call   1040 <htons@plt>
mov    %eax,(%rsp)
mov    (%rbx),%edi
mov    0x2df4(%rip),%rax
mov    (%rax),%esi
mov    0x2dfb(%rip),%rax
mov    (%rax),%edx
call   10b0 <socket@plt>
test   %eax,%eax
js     1275 <main+0xe5>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0xc,%edx
call   10a0 <connect@plt>
test   %rax,%rax
js     126e <main+0xde>
add    $0xffffffff,%ebp
add    $0x8,%r14
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0x80,%esi
mov    %ebp,%edx
mov    %r14,%rcx
call   1090 <argString@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x80,%edx
call   1030 <write@plt>
test   %rax,%rax
jle    126e <main+0xde>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0x80,%edx
call   1080 <read@plt>
test   %rax,%rax
jle    126e <main+0xde>
lea    0xda7(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <printf@plt>
mov    %ebx,%edi
call   1070 <close@plt>
xor    %eax,%eax
jmp    127e <main+0xee>
mov    %ebx,%edi
call   1070 <close@plt>
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
add    $0x98,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
%8 = alloca [128 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @memset(%struct.sockaddr_in* %7, i32 0, i32 12)
%10 = load i32, i32* @AF_INET
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i32 %10, i32* %11
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%13 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %12, i32 0, i32 0
store i32 766683328, i32* %13
%14 = call i32 @htons(i32 9025)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i32 %14, i32* %15
%16 = load i32, i32* @AF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = load i32, i32* @IPPROTO_TCP
%19 = call i32 @socket(i32 %16, i32 %17, i32 %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %2
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %3
br label %62
24: ; preds = %2
%25 = load i32, i32* %6
%26 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%27 = call i64 @connect(i32 %25, %struct.sockaddr* %26, i32 12)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %24
%30 = load i32, i32* %6
%31 = call i32 @close(i32 %30)
%32 = load i32, i32* @EXIT_FAILURE
store i32 %32, i32* %3
br label %62
33: ; preds = %24
%34 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%35 = load i32, i32* %4
%36 = sub nsw i32 %35, 1
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = call i32 @argString(i8* %34, i32 128, i32 %36, i8** %38)
%40 = load i32, i32* %6
%41 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%42 = call i64 @write(i32 %40, i8* %41, i32 128)
%43 = icmp sle i64 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %33
%45 = load i32, i32* %6
%46 = call i32 @close(i32 %45)
%47 = load i32, i32* @EXIT_FAILURE
store i32 %47, i32* %3
br label %62
48: ; preds = %33
%49 = load i32, i32* %6
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%51 = call i64 @read(i32 %49, i8* %50, i32 128)
%52 = icmp sle i64 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %48
%54 = load i32, i32* %6
%55 = call i32 @close(i32 %54)
%56 = load i32, i32* @EXIT_FAILURE
store i32 %56, i32* %3
br label %62
57: ; preds = %48
%58 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%59 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %58)
%60 = load i32, i32* %6
%61 = call i32 @close(i32 %60)
br label %62
62: ; preds = %57, %53, %44, %29, %22
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@EXIT_FAILURE = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [128 x i8]
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%8 = load i32, i32* @AF_INET
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %8, i32* %9
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 766683328, i32* %10
%11 = call i32 @htons(i32 9025)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %11, i32* %12
%13 = load i32, i32* @AF_INET
%14 = load i32, i32* @SOCK_STREAM
%15 = load i32, i32* @IPPROTO_TCP
%16 = call i32 @socket(i32 %13, i32 %14, i32 %15)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = load i32, i32* @EXIT_FAILURE
br label %45
20: ; preds = %2
%21 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%22 = call i64 @connect(i32 %16, %struct.sockaddr* %21, i32 12)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = call i32 @close(i32 %16)
%26 = load i32, i32* @EXIT_FAILURE
br label %45
27: ; preds = %20
%28 = add nsw i32 %0, -1
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = call i32 @argString(i8* %6, i32 128, i32 %28, i8** %29)
%31 = call i64 @write(i32 %16, i8* %6, i32 128)
%32 = icmp slt i64 %31, 1
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = call i32 @close(i32 %16)
%35 = load i32, i32* @EXIT_FAILURE
br label %45
36: ; preds = %27
%37 = call i64 @read(i32 %16, i8* %6, i32 128)
%38 = icmp slt i64 %37, 1
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = call i32 @close(i32 %16)
%41 = load i32, i32* @EXIT_FAILURE
br label %45
42: ; preds = %36
%43 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%44 = call i32 @close(i32 %16)
br label %45
45: ; preds = %42, %39, %33, %24, %18
%46 = phi i32 [ %19, %18 ], [ %26, %24 ], [ %35, %33 ], [ %41, %39 ], [ 0, %42 ]
ret i32 %46
}