#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 char uint32_t;
typedef char uint16_t;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  void *sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int atoi(char *);
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char htonl(int);
void *htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int, int);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int i, fd, loop;
  struct sockaddr_in sin;
  char send_buf[102406], recv_buf[1024];
  loop = 1024;
  if (argc == 2) {
    loop = atoi(argv[1]);
  }
  memset(&sin, 0x00, sizeof(struct sockaddr_in));
  sin.sin_family = AF_INET;
  sin.sin_port = htons(1304);
  sin.sin_addr.s_addr = inet_addr("127.0.0.1");
  fd = socket(AF_INET, SOCK_STREAM, 0);
  if (fd == -1) {
    fprintf(stderr, "socket() failed: %s\n", strerror(errno));
    return 1;
  }
  if (connect(fd, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) == -1) {
    fprintf(stderr, "connect() failed: %s\n", strerror(errno));
    return 1;
  }
  for (i = 0; i < loop; ++i) {
    uint32_t body_n = htonl((i + 1));
    uint16_t qtype = htons(1);
    memcpy(send_buf, &body_n, 4);
    memcpy(send_buf + 4, &qtype, 2);
    memcpy(send_buf + 6, "0123456789", 10);
    ssize_t n = send(fd, send_buf, 6 + (i + 1), 0);
    if (n == -1) {
      fprintf(stderr, "send() failed: %s\n", strerror(errno));
      return 1;
    }
    fprintf(stderr, "send %ld\n", n);
    n = recv(fd, recv_buf, 1024, 0);
    if (n == -1) {
      fprintf(stderr, "recv() failed: %s\n", strerror(errno));
      return 1;
    }
    recv_buf[n] = '\0';
    fprintf(stderr, "recv %ld, fid %s\n", n, recv_buf + 6);
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x19460,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x400,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    120a <main+0x3a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    $0x518,%edi
call   1040 <htons@plt>
mov    %rax,-0x30(%rbp)
lea    0xdc5(%rip),%rdi
call   1090 <inet_addr@plt>
mov    %eax,-0x38(%rbp)
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
mov    0x2d7d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    12a9 <main+0xd9>
mov    0x2d68(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1944c(%rbp)
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x1944c(%rbp),%edi
mov    %rax,%rdx
lea    0xd74(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ce <main+0x2fe>
mov    -0x18(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x18,%edx
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
jne    1303 <main+0x133>
mov    0x2d0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x19450(%rbp)
mov    0x2cef(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x19450(%rbp),%edi
mov    %rax,%rdx
lea    0xd2f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ce <main+0x2fe>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    14bf <main+0x2ef>
mov    -0x14(%rbp),%edi
add    $0x1,%edi
call   1060 <htonl@plt>
mov    %al,-0x19441(%rbp)
mov    $0x1,%edi
call   1040 <htons@plt>
mov    %al,-0x19442(%rbp)
lea    -0x19040(%rbp),%rdi
lea    -0x19441(%rbp),%rsi
mov    $0x4,%edx
call   10b0 <memcpy@plt>
lea    -0x19040(%rbp),%rdi
add    $0x4,%rdi
lea    -0x19442(%rbp),%rsi
mov    $0x2,%edx
call   10b0 <memcpy@plt>
lea    -0x19040(%rbp),%rdi
add    $0x6,%rdi
lea    0xcb8(%rip),%rsi
mov    $0xa,%edx
call   10b0 <memcpy@plt>
mov    -0x18(%rbp),%edi
lea    -0x19040(%rbp),%rsi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
add    $0x6,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %eax,-0x19448(%rbp)
cmpl   $0xffffffff,-0x19448(%rbp)
jne    13f4 <main+0x224>
mov    0x2c1d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x19454(%rbp)
mov    0x2bfe(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x19454(%rbp),%edi
mov    %rax,%rdx
lea    0xc5f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ce <main+0x2fe>
mov    0x2bdd(%rip),%rax
mov    (%rax),%edi
mov    -0x19448(%rbp),%edx
lea    0xc49(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%edi
lea    -0x19440(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x19448(%rbp)
cmpl   $0xffffffff,-0x19448(%rbp)
jne    147a <main+0x2aa>
mov    0x2b97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x19458(%rbp)
mov    0x2b78(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x19458(%rbp),%edi
mov    %rax,%rdx
lea    0xbf6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ce <main+0x2fe>
movslq -0x19448(%rbp),%rax
movb   $0x0,-0x19440(%rbp,%rax,1)
mov    0x2b48(%rip),%rax
mov    (%rax),%edi
mov    -0x19448(%rbp),%edx
lea    -0x19440(%rbp),%rcx
add    $0x6,%rcx
lea    0xbc6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    130a <main+0x13a>
mov    -0x18(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x19460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x19428,%rsp
mov    $0x400,%r13d
cmp    $0x2,%edi
jne    11f8 <main+0x28>
mov    0x8(%rsi),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r13d
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    0x2dd8(%rip),%rbx
mov    (%rbx),%eax
mov    %eax,0x18(%rsp)
mov    $0x518,%edi
call   1040 <htons@plt>
mov    %rax,0x10(%rsp)
lea    0xdd4(%rip),%rdi
call   1090 <inet_addr@plt>
mov    %eax,0x8(%rsp)
mov    (%rbx),%edi
mov    0x2d92(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
cmp    $0xffffffff,%eax
je     137a <main+0x1aa>
mov    %eax,%ebp
lea    0x8(%rsp),%rsi
mov    %eax,%edi
mov    $0x18,%edx
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
je     139a <main+0x1ca>
test   %r13d,%r13d
jle    136c <main+0x19c>
neg    %r13d
mov    $0x7,%ebx
lea    0x420(%rsp),%r12
mov    0x2d4c(%rip),%r14
nopl   0x0(%rax)
lea    -0x6(%rbx),%edi
call   1060 <htonl@plt>
mov    %al,0x7(%rsp)
mov    $0x1,%edi
call   1040 <htons@plt>
mov    %al,0x6(%rsp)
mov    %r12,%rdi
lea    0x7(%rsp),%rsi
mov    $0x4,%edx
call   10b0 <memcpy@plt>
lea    0x424(%rsp),%rdi
lea    0x6(%rsp),%rsi
mov    $0x2,%edx
call   10b0 <memcpy@plt>
lea    0x426(%rsp),%rdi
lea    0xd53(%rip),%rsi
mov    $0xa,%edx
call   10b0 <memcpy@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    %ebx,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    (%r14),%r15d
cmp    $0xffffffff,%eax
je     13ba <main+0x1ea>
mov    %r15d,%edi
lea    0xd43(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %ebp,%edi
lea    0x20(%rsp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     13d4 <main+0x204>
movslq %eax,%rcx
movb   $0x0,0x20(%rsp,%rcx,1)
mov    (%r14),%edi
lea    0xd29(%rip),%rsi
mov    %eax,%edx
lea    0x26(%rsp),%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
lea    (%rbx,%r13,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x7,%eax
jne    1290 <main+0xc0>
mov    %ebp,%edi
call   1080 <close@plt>
xor    %eax,%eax
jmp    13fd <main+0x22d>
mov    0x2c57(%rip),%rax
mov    (%rax),%ebx
mov    0x2c3e(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xc72(%rip),%rsi
jmp    13ec <main+0x21c>
mov    0x2c37(%rip),%rax
mov    (%rax),%ebx
mov    0x2c1e(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xc67(%rip),%rsi
jmp    13ec <main+0x21c>
mov    0x2c07(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xc71(%rip),%rsi
mov    %r15d,%edi
jmp    13ee <main+0x21e>
mov    (%r14),%ebx
mov    0x2bea(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xc71(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%eax
add    $0x19428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@.str = [10 x i8] c"127.0.0.1\00"
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str.1 = [21 x i8] c"socket() failed: %s\0A\00"
@errno = global i32 0
@.str.2 = [22 x i8] c"connect() failed: %s\0A\00"
@.str.3 = [11 x i8] c"0123456789\00"
@.str.4 = [19 x i8] c"send() failed: %s\0A\00"
@.str.5 = [10 x i8] c"send %ld\0A\00"
@.str.6 = [19 x i8] c"recv() failed: %s\0A\00"
@.str.7 = [18 x i8] c"recv %ld, fid %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
%10 = alloca [102406 x i8]
%11 = alloca [1024 x i8]
%12 = alloca i8
%13 = alloca i8
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1024, i32* %8
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %22
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %8
br label %22
22: ; preds = %17, %2
%23 = call i32 @memset(%struct.sockaddr_in* %9, i32 0, i32 24)
%24 = load i32, i32* @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %24, i32* %25
%26 = call i8* @htons(i32 1304)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
store i8* %26, i8** %27
%28 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%30 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %29, i32 0, i32 0
store i32 %28, i32* %30
%31 = load i32, i32* @AF_INET
%32 = load i32, i32* @SOCK_STREAM
%33 = call i32 @socket(i32 %31, i32 %32, i32 0)
store i32 %33, i32* %7
%34 = load i32, i32* %7
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %41
36: ; preds = %22
%37 = load i32, i32* @stderr
%38 = load i32, i32* @errno
%39 = call i8* @strerror(i32 %38)
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %39)
store i32 1, i32* %3
br label %112
41: ; preds = %22
%42 = load i32, i32* %7
%43 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%44 = call i32 @connect(i32 %42, %struct.sockaddr* %43, i32 24)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %51
46: ; preds = %41
%47 = load i32, i32* @stderr
%48 = load i32, i32* @errno
%49 = call i8* @strerror(i32 %48)
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %49)
store i32 1, i32* %3
br label %112
51: ; preds = %41
store i32 0, i32* %6
br label %52
52: ; preds = %106, %51
%53 = load i32, i32* %6
%54 = load i32, i32* %8
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %109
56: ; preds = %52
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
%59 = call signext i8 @htonl(i32 %58)
store i8 %59, i8* %12
%60 = call i8* @htons(i32 1)
%61 = ptrtoint i8* %60 to i8
store i8 %61, i8* %13
%62 = getelementptr inbounds [102406 x i8], [102406 x i8]* %10, i64 0, i64 0
%63 = call i32 @memcpy(i8* %62, i8* %12, i32 4)
%64 = getelementptr inbounds [102406 x i8], [102406 x i8]* %10, i64 0, i64 0
%65 = getelementptr inbounds i8, i8* %64, i64 4
%66 = call i32 @memcpy(i8* %65, i8* %13, i32 2)
%67 = getelementptr inbounds [102406 x i8], [102406 x i8]* %10, i64 0, i64 0
%68 = getelementptr inbounds i8, i8* %67, i64 6
%69 = call i32 @memcpy(i8* %68, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 10)
%70 = load i32, i32* %7
%71 = getelementptr inbounds [102406 x i8], [102406 x i8]* %10, i64 0, i64 0
%72 = load i32, i32* %6
%73 = add nsw i32 %72, 1
%74 = add nsw i32 6, %73
%75 = call i32 @send(i32 %70, i8* %71, i32 %74, i32 0)
store i32 %75, i32* %14
%76 = load i32, i32* %14
%77 = icmp eq i32 %76, -1
br i1 %77, label %78, label %83
78: ; preds = %56
%79 = load i32, i32* @stderr
%80 = load i32, i32* @errno
%81 = call i8* @strerror(i32 %80)
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %81)
store i32 1, i32* %3
br label %112
83: ; preds = %56
%84 = load i32, i32* @stderr
%85 = load i32, i32* %14
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %85)
%87 = load i32, i32* %7
%88 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%89 = call i32 @recv(i32 %87, i8* %88, i32 1024, i32 0)
store i32 %89, i32* %14
%90 = load i32, i32* %14
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %97
92: ; preds = %83
%93 = load i32, i32* @stderr
%94 = load i32, i32* @errno
%95 = call i8* @strerror(i32 %94)
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %95)
store i32 1, i32* %3
br label %112
97: ; preds = %83
%98 = load i32, i32* %14
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %99
store i8 0, i8* %100
%101 = load i32, i32* @stderr
%102 = load i32, i32* %14
%103 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%104 = getelementptr inbounds i8, i8* %103, i64 6
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %102, i8* %104)
br label %106
106: ; preds = %97
%107 = load i32, i32* %6
%108 = add nsw i32 %107, 1
store i32 %108, i32* %6
br label %52
109: ; preds = %52
%110 = load i32, i32* %7
%111 = call i32 @close(i32 %110)
store i32 0, i32* %3
br label %112
112: ; preds = %109, %92, %78, %46, %36
%113 = load i32, i32* %3
ret i32 %113
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@.str = [10 x i8] c"127.0.0.1\00"
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str.1 = [21 x i8] c"socket() failed: %s\0A\00"
@errno = global i32 0
@.str.2 = [22 x i8] c"connect() failed: %s\0A\00"
@.str.3 = [11 x i8] c"0123456789\00"
@.str.4 = [19 x i8] c"send() failed: %s\0A\00"
@.str.5 = [10 x i8] c"send %ld\0A\00"
@.str.6 = [19 x i8] c"recv() failed: %s\0A\00"
@.str.7 = [18 x i8] c"recv %ld, fid %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [102406 x i8]
%5 = alloca [1024 x i8]
%6 = alloca i8
%7 = alloca i8
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = getelementptr inbounds [102406 x i8], [102406 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%11 = icmp eq i32 %0, 2
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
br label %16
16: ; preds = %12, %2
%17 = phi i32 [ %15, %12 ], [ 1024, %2 ]
%18 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 24)
%19 = load i32, i32* @AF_INET
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %19, i32* %20
%21 = call i8* @htons(i32 1304)
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i8* %21, i8** %22
%23 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %23, i32* %24
%25 = load i32, i32* @AF_INET
%26 = load i32, i32* @SOCK_STREAM
%27 = call i32 @socket(i32 %25, i32 %26, i32 0)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %34
29: ; preds = %16
%30 = load i32, i32* @stderr
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %32)
br label %85
34: ; preds = %16
%35 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%36 = call i32 @connect(i32 %27, %struct.sockaddr* %35, i32 24)
%37 = icmp eq i32 %36, -1
br i1 %37, label %44, label %38
38: ; preds = %34
%39 = icmp sgt i32 %17, 0
br i1 %39, label %40, label %83
40: ; preds = %38
%41 = getelementptr inbounds [102406 x i8], [102406 x i8]* %4, i64 0, i64 4
%42 = getelementptr inbounds [102406 x i8], [102406 x i8]* %4, i64 0, i64 6
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 6
br label %49
44: ; preds = %34
%45 = load i32, i32* @stderr
%46 = load i32, i32* @errno
%47 = call i8* @strerror(i32 %46)
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %47)
br label %85
49: ; preds = %40, %77
%50 = phi i32 [ 0, %40 ], [ %51, %77 ]
%51 = add nuw nsw i32 %50, 1
%52 = call signext i8 @htonl(i32 %51)
store i8 %52, i8* %6
%53 = call i8* @htons(i32 1)
%54 = ptrtoint i8* %53 to i64
%55 = trunc i64 %54 to i8
store i8 %55, i8* %7
%56 = call i32 @memcpy(i8* %9, i8* %6, i32 4)
%57 = call i32 @memcpy(i8* %41, i8* %7, i32 2)
%58 = call i32 @memcpy(i8* %42, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 10)
%59 = add nuw nsw i32 %50, 7
%60 = call i32 @send(i32 %27, i8* %9, i32 %59, i32 0)
%61 = icmp eq i32 %60, -1
%62 = load i32, i32* @stderr
br i1 %61, label %63, label %67
63: ; preds = %49
%64 = load i32, i32* @errno
%65 = call i8* @strerror(i32 %64)
%66 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %65)
br label %76
67: ; preds = %49
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %60)
%69 = call i32 @recv(i32 %27, i8* %10, i32 1024, i32 0)
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %77
71: ; preds = %67
%72 = load i32, i32* @stderr
%73 = load i32, i32* @errno
%74 = call i8* @strerror(i32 %73)
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %74)
br label %76
76: ; preds = %63, %71
br label %85
77: ; preds = %67
%78 = sext i32 %69 to i64
%79 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %78
store i8 0, i8* %79
%80 = load i32, i32* @stderr
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %69, i8* %43)
%82 = icmp eq i32 %51, %17
br i1 %82, label %83, label %49
83: ; preds = %77, %38
%84 = call i32 @close(i32 %27)
br label %85
85: ; preds = %76, %83, %44, %29
%86 = phi i32 [ 1, %29 ], [ 1, %44 ], [ 0, %83 ], [ 1, %76 ]
ret i32 %86
}