#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_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ servaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ Connect(int, struct sockaddr *, int);
int /*<<< orphan*/ SOCK_STREAM;
int Socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ err_quit(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_pton(int /*<<< orphan*/, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ str_cli(int, int);
int main(int argc, char **argv) {
  int sockfd, i;
  struct sockaddr_in servaddr;
  if (argc != 2)
    err_quit("usage: client <IPaddress>");
  for (i = 1; i < 4; ++i) {
    sockfd = Socket(AF_INET, SOCK_STREAM, 0);
    memset(&servaddr, 0, sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_port = htons(5555);
    inet_pton(AF_INET, argv[1], &servaddr.sin_addr);
    Connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
    str_cli(sockfd, i);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ac <main+0x2c>
lea    0xe59(%rip),%rdi
call   1060 <err_quit@plt>
movl   $0x1,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    1246 <main+0xc6>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
mov    0x2e0b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <Socket@plt>
mov    %eax,-0x14(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    $0x15b3,%edi
call   1030 <htons@plt>
mov    %eax,-0x24(%rbp)
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x28(%rbp),%rdx
call   1070 <inet_pton@plt>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   1090 <Connect@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <str_cli@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11b3 <main+0x33>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
cmp    $0x2,%edi
je     11a0 <main+0x20>
lea    0xe65(%rip),%rdi
call   1060 <err_quit@plt>
mov    0x2e41(%rip),%r15
mov    (%r15),%edi
mov    0x2e27(%rip),%r12
mov    (%r12),%esi
xor    %edx,%edx
call   1080 <Socket@plt>
mov    %eax,%ebp
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    (%r15),%eax
mov    %eax,0x8(%rsp)
mov    $0x15b3,%edi
call   1030 <htons@plt>
mov    %eax,0x4(%rsp)
mov    (%r15),%edi
mov    0x8(%r14),%rsi
mov    %rbx,%rdx
call   1070 <inet_pton@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1090 <Connect@plt>
mov    %ebp,%edi
mov    $0x1,%esi
call   1050 <str_cli@plt>
mov    (%r15),%edi
mov    (%r12),%esi
xor    %edx,%edx
call   1080 <Socket@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    (%r15),%eax
mov    %eax,0x8(%rsp)
mov    $0x15b3,%edi
call   1030 <htons@plt>
mov    %eax,0x4(%rsp)
mov    (%r15),%edi
mov    0x8(%r14),%rsi
mov    %rbx,%rdx
call   1070 <inet_pton@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1090 <Connect@plt>
mov    %ebp,%edi
mov    $0x2,%esi
call   1050 <str_cli@plt>
mov    (%r15),%edi
mov    (%r12),%esi
xor    %edx,%edx
call   1080 <Socket@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    (%r15),%eax
mov    %eax,0x8(%rsp)
mov    $0x15b3,%edi
call   1030 <htons@plt>
mov    %eax,0x4(%rsp)
mov    (%r15),%edi
mov    0x8(%r14),%rsi
mov    %rbx,%rdx
call   1070 <inet_pton@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1090 <Connect@plt>
mov    %ebp,%edi
mov    $0x3,%esi
call   1050 <str_cli@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [26 x i8] c"usage: client <IPaddress>\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @err_quit(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
store i32 1, i32* %7
br label %14
14: ; preds = %38, %13
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 4
br i1 %16, label %17, label %41
17: ; preds = %14
%18 = load i32, i32* @AF_INET
%19 = load i32, i32* @SOCK_STREAM
%20 = call i32 @Socket(i32 %18, i32 %19, i32 0)
store i32 %20, i32* %6
%21 = call i32 @memset(%struct.sockaddr_in* %8, i32 0, i32 12)
%22 = load i32, i32* @AF_INET
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %22, i32* %23
%24 = call i32 @htons(i32 5555)
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
store i32 %24, i32* %25
%26 = load i32, i32* @AF_INET
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%31 = call i32 @inet_pton(i32 %26, i8* %29, i32* %30)
%32 = load i32, i32* %6
%33 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%34 = call i32 @Connect(i32 %32, %struct.sockaddr* %33, i32 12)
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = call i32 @str_cli(i32 %35, i32 %36)
br label %38
38: ; preds = %17
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %14
41: ; preds = %14
%42 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [26 x i8] c"usage: client <IPaddress>\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = bitcast %struct.sockaddr_in* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @err_quit(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %2
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
%13 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%14 = load i32, i32* @AF_INET
%15 = load i32, i32* @SOCK_STREAM
%16 = call i32 @Socket(i32 %14, i32 %15, i32 0)
%17 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%18 = load i32, i32* @AF_INET
store i32 %18, i32* %9
%19 = call i32 @htons(i32 5555)
store i32 %19, i32* %10
%20 = load i32, i32* @AF_INET
%21 = load i8*, i8** %11
%22 = call i32 @inet_pton(i32 %20, i8* %21, i32* %12)
%23 = call i32 @Connect(i32 %16, %struct.sockaddr* %13, i32 12)
%24 = call i32 @str_cli(i32 %16, i32 1)
%25 = load i32, i32* @AF_INET
%26 = load i32, i32* @SOCK_STREAM
%27 = call i32 @Socket(i32 %25, i32 %26, i32 0)
%28 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%29 = load i32, i32* @AF_INET
store i32 %29, i32* %9
%30 = call i32 @htons(i32 5555)
store i32 %30, i32* %10
%31 = load i32, i32* @AF_INET
%32 = load i8*, i8** %11
%33 = call i32 @inet_pton(i32 %31, i8* %32, i32* %12)
%34 = call i32 @Connect(i32 %27, %struct.sockaddr* %13, i32 12)
%35 = call i32 @str_cli(i32 %27, i32 2)
%36 = load i32, i32* @AF_INET
%37 = load i32, i32* @SOCK_STREAM
%38 = call i32 @Socket(i32 %36, i32 %37, i32 0)
%39 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%40 = load i32, i32* @AF_INET
store i32 %40, i32* %9
%41 = call i32 @htons(i32 5555)
store i32 %41, i32* %10
%42 = load i32, i32* @AF_INET
%43 = load i8*, i8** %11
%44 = call i32 @inet_pton(i32 %42, i8* %43, i32* %12)
%45 = call i32 @Connect(i32 %38, %struct.sockaddr* %13, i32 12)
%46 = call i32 @str_cli(i32 %38, i32 3)
%47 = call i32 @exit(i32 0)
unreachable
}