#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 hostent {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int BUFSIZ;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getip(char *);
int /*<<< orphan*/ htons(int);
scalar_t__ inet_pton(int /*<<< orphan*/, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stdout;
int strlen(char *);
int main(int argc, char *argv[]) {
  int n;
  int s;
  int c;
  int sent;
  char line[512];
  char buf[BUFSIZ + 1];
  struct hostent *host;
  struct sockaddr_in addr;
  char *ip;
  if ((s = socket(PF_INET, SOCK_STREAM, 0)) == -1) {
    perror("Socket");
    exit(1);
  }
  addr.sin_family = AF_INET;
  addr.sin_port = htons(80);
  ip = getip(argv[1]);
  if (ip == 0) {
    printf("Invalid host\n");
    exit(1);
  }
  if (inet_pton(AF_INET, ip, &addr.sin_addr.s_addr) <= 0) {
    perror("inet_pton");
    exit(1);
  }
  if (connect(s, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) {
    perror("Connect");
    exit(1);
  }
  printf("Connected to host\n");
  memset(line, 0, 512);
  sprintf(line, "GET %s HTTP/1.1\r\nConnection: close\r\n\r\n", argv[2]);
  printf("Sending request... \n===\n%s===\n", line);
  sent = 0;
  while (sent < strlen(line)) {
    n = send(s, line + sent, strlen(line) - sent, 0);
    if (n < 0) {
      perror("Can't send query");
      exit(1);
    }
    sent = sent + n;
  }
  n = 0;
  printf("receiving...\n");
  memset(buf, 0, BUFSIZ + 1);
  while ((n = recv(s, buf, BUFSIZ, 0)) > 0) {
    if (strlen(buf) == 0) {
      break;
    }
    fprintf(stdout, buf);
    memset(buf, 0, BUFSIZ + 1);
  }
  close(s);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x228(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x258(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x230(%rbp)
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
mov    0x2d87(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    127c <main+0x8c>
lea    0xd93(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x240(%rbp)
mov    $0x50,%edi
call   1050 <htons@plt>
mov    %eax,-0x244(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <getip@plt>
mov    %rax,-0x250(%rbp)
cmpq   $0x0,-0x250(%rbp)
jne    12d5 <main+0xe5>
lea    0xd43(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
mov    -0x250(%rbp),%rsi
lea    -0x248(%rbp),%rdx
call   10c0 <inet_pton@plt>
cmp    $0x0,%rax
jg     1311 <main+0x121>
lea    0xd13(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x18(%rbp),%edi
lea    -0x248(%rbp),%rsi
mov    $0xc,%edx
call   1100 <connect@plt>
cmp    $0x0,%rax
jge    1345 <main+0x155>
lea    0xce9(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xcdb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1090 <memset@plt>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xcbe(%rip),%rsi
call   10e0 <sprintf@plt>
lea    -0x220(%rbp),%rsi
lea    0xcd2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x25c(%rbp)
lea    -0x220(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x25c(%rbp),%eax
cmp    %ecx,%eax
jge    1436 <main+0x246>
mov    -0x18(%rbp),%eax
mov    %eax,-0x26c(%rbp)
lea    -0x220(%rbp),%rax
movslq -0x20(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x268(%rbp)
lea    -0x220(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x26c(%rbp),%edi
mov    -0x268(%rbp),%rsi
mov    %eax,%edx
sub    -0x20(%rbp),%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1428 <main+0x238>
lea    0xc67(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x20(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    139d <main+0x1ad>
movl   $0x0,-0x14(%rbp)
lea    0xc4d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x258(%rbp),%rdi
mov    0x2b77(%rip),%rax
mov    (%rax),%edx
add    $0x1,%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    -0x258(%rbp),%rsi
mov    -0x18(%rbp),%edi
mov    0x2b5a(%rip),%rax
mov    (%rax),%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    14d9 <main+0x2e9>
mov    -0x258(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jne    14a5 <main+0x2b5>
jmp    14d9 <main+0x2e9>
mov    -0x258(%rbp),%rsi
mov    0x2b0d(%rip),%rax
mov    (%rax),%edi
call   10b0 <fprintf@plt>
mov    -0x258(%rbp),%rdi
mov    0x2b08(%rip),%rax
mov    (%rax),%edx
add    $0x1,%edx
xor    %esi,%esi
call   1090 <memset@plt>
jmp    1465 <main+0x275>
mov    -0x18(%rbp),%edi
call   10a0 <close@plt>
mov    -0x228(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rsi,%r15
mov    %rsp,%r14
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
mov    0x2d91(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     140c <main+0x20c>
mov    0x2d85(%rip),%rbx
mov    (%rbx),%eax
mov    %eax,-0x30(%rbp)
mov    $0x50,%edi
call   1060 <htons@plt>
mov    %eax,-0x34(%rbp)
mov    0x8(%r15),%rdi
call   1090 <getip@plt>
test   %rax,%rax
je     1415 <main+0x215>
mov    (%rbx),%edi
lea    -0x38(%rbp),%rdx
mov    %rax,%rsi
call   10d0 <inet_pton@plt>
test   %rax,%rax
jle    142b <main+0x22b>
mov    %r14,-0x40(%rbp)
lea    -0x38(%rbp),%rsi
mov    -0x2c(%rbp),%edi
mov    $0xc,%edx
call   1110 <connect@plt>
test   %rax,%rax
js     1434 <main+0x234>
lea    0xdad(%rip),%rdi
call   1040 <puts@plt>
lea    -0x240(%rbp),%rbx
xor    %r13d,%r13d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   10a0 <memset@plt>
mov    0x10(%r15),%rdx
lea    0xd2d(%rip),%rsi
mov    %rbx,%rdi
call   10f0 <sprintf@plt>
lea    0xd45(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1360 <main+0x160>
lea    -0x240(%rbp),%r15
nopl   0x0(%rax,%rax,1)
movslq %r13d,%r14
lea    (%r14,%rbp,1),%rbx
add    $0xfffffffffffffdc0,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
sub    %r14d,%eax
mov    -0x2c(%rbp),%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
test   %eax,%eax
js     13f6 <main+0x1f6>
add    %eax,%r13d
mov    %r15,%rdi
call   1050 <strlen@plt>
cmp    %eax,%r13d
jl     1320 <main+0x120>
lea    0xd1b(%rip),%rdi
call   1040 <puts@plt>
mov    0x2c5d(%rip),%rbx
mov    (%rbx),%edx
add    $0x1,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10a0 <memset@plt>
mov    (%rbx),%edx
mov    -0x2c(%rbp),%edi
mov    %r12,%rsi
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    13d9 <main+0x1d9>
mov    0x2c24(%rip),%r14
nopl   0x0(%rax)
mov    %r12,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
je     13d9 <main+0x1d9>
mov    (%r14),%edi
mov    %r12,%rsi
call   10c0 <fprintf@plt>
mov    (%rbx),%edx
add    $0x1,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10a0 <memset@plt>
mov    (%rbx),%edx
mov    -0x2c(%rbp),%edi
mov    %r12,%rsi
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jg     13a0 <main+0x1a0>
mov    -0x2c(%rbp),%edi
call   10b0 <close@plt>
mov    -0x40(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc62(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0xbed(%rip),%rdi
jmp    13fd <main+0x1fd>
lea    0xc73(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0xbd5(%rip),%rdi
jmp    13fd <main+0x1fd>
lea    0xbd6(%rip),%rdi
jmp    13fd <main+0x1fd>

LLVM IR (-O0):
%struct.hostent = type { i32 }
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@BUFSIZ = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"Socket\00"
@AF_INET = global i32 0
@.str.1 = [14 x i8] c"Invalid host\0A\00"
@.str.2 = [10 x i8] c"inet_pton\00"
@.str.3 = [8 x i8] c"Connect\00"
@.str.4 = [19 x i8] c"Connected to host\0A\00"
@.str.5 = [39 x i8] c"GET %s HTTP/1.1\0D\0AConnection: close\0D\0A\0D\0A\00"
@.str.6 = [31 x i8] c"Sending request... \0A===\0A%s===\0A\00"
@.str.7 = [17 x i8] c"Can't send query\00"
@.str.8 = [14 x i8] c"receiving...\0A\00"
@stdout = 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 i32
%9 = alloca i32
%10 = alloca [512 x i8]
%11 = alloca i8*
%12 = alloca i64
%13 = alloca %struct.hostent*
%14 = alloca %struct.sockaddr_in
%15 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* @BUFSIZ
%17 = add nsw i32 %16, 1
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %11
%20 = alloca i8, i64 %18
store i64 %18, i64* %12
%21 = load i32, i32* @PF_INET
%22 = load i32, i32* @SOCK_STREAM
%23 = call i32 @socket(i32 %21, i32 %22, i32 0)
store i32 %23, i32* %7
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %2
%26 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %2
%29 = load i32, i32* @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 2
store i32 %29, i32* %30
%31 = call i32 @htons(i32 80)
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 1
store i32 %31, i32* %32
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i8* @getip(i8* %35)
store i8* %36, i8** %15
%37 = load i8*, i8** %15
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %42
39: ; preds = %28
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %28
%43 = load i32, i32* @AF_INET
%44 = load i8*, i8** %15
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 0
%46 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %45, i32 0, i32 0
%47 = call i64 @inet_pton(i32 %43, i8* %44, i32* %46)
%48 = icmp sle i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %42
%50 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %42
%53 = load i32, i32* %7
%54 = bitcast %struct.sockaddr_in* %14 to %struct.sockaddr*
%55 = call i64 @connect(i32 %53, %struct.sockaddr* %54, i32 12)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %52
%58 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%59 = call i32 @exit(i32 1)
unreachable
60: ; preds = %52
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%62 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%63 = call i32 @memset(i8* %62, i32 0, i32 512)
%64 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 2
%67 = load i8*, i8** %66
%68 = call i32 @sprintf(i8* %64, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* %67)
%69 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %69)
store i32 0, i32* %9
br label %71
71: ; preds = %92, %60
%72 = load i32, i32* %9
%73 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%74 = call i32 @strlen(i8* %73)
%75 = icmp slt i32 %72, %74
br i1 %75, label %76, label %96
76: ; preds = %71
%77 = load i32, i32* %7
%78 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%79 = load i32, i32* %9
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %78, i64 %80
%82 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%83 = call i32 @strlen(i8* %82)
%84 = load i32, i32* %9
%85 = sub nsw i32 %83, %84
%86 = call i32 @send(i32 %77, i8* %81, i32 %85, i32 0)
store i32 %86, i32* %6
%87 = load i32, i32* %6
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %76
%90 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%91 = call i32 @exit(i32 1)
unreachable
92: ; preds = %76
%93 = load i32, i32* %9
%94 = load i32, i32* %6
%95 = add nsw i32 %93, %94
store i32 %95, i32* %9
br label %71
96: ; preds = %71
store i32 0, i32* %6
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%98 = load i32, i32* @BUFSIZ
%99 = add nsw i32 %98, 1
%100 = call i32 @memset(i8* %20, i32 0, i32 %99)
br label %101
101: ; preds = %110, %96
%102 = load i32, i32* %7
%103 = load i32, i32* @BUFSIZ
%104 = call i32 @recv(i32 %102, i8* %20, i32 %103, i32 0)
store i32 %104, i32* %6
%105 = icmp sgt i32 %104, 0
br i1 %105, label %106, label %116
106: ; preds = %101
%107 = call i32 @strlen(i8* %20)
%108 = icmp eq i32 %107, 0
br i1 %108, label %109, label %110
109: ; preds = %106
br label %116
110: ; preds = %106
%111 = load i32, i32* @stdout
%112 = call i32 @fprintf(i32 %111, i8* %20)
%113 = load i32, i32* @BUFSIZ
%114 = add nsw i32 %113, 1
%115 = call i32 @memset(i8* %20, i32 0, i32 %114)
br label %101
116: ; preds = %109, %101
%117 = load i32, i32* %7
%118 = call i32 @close(i32 %117)
%119 = load i8*, i8** %11
%120 = load i32, i32* %3
ret i32 %120
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32 }
%struct.sockaddr = type { i32 }
@BUFSIZ = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"Socket\00"
@AF_INET = global i32 0
@.str.2 = [10 x i8] c"inet_pton\00"
@.str.3 = [8 x i8] c"Connect\00"
@.str.5 = [39 x i8] c"GET %s HTTP/1.1\0D\0AConnection: close\0D\0A\0D\0A\00"
@.str.6 = [31 x i8] c"Sending request... \0A===\0A%s===\0A\00"
@.str.7 = [17 x i8] c"Can't send query\00"
@stdout = global i32 0
@str = [18 x i8] c"Connected to host\00"
@str.9 = [13 x i8] c"receiving...\00"
@str.10 = [13 x i8] c"Invalid host\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca %struct.sockaddr_in
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = load i32, i32* @BUFSIZ
%7 = add nsw i32 %6, 1
%8 = zext i32 %7 to i64
%9 = tail call i8* @llvm.stacksave()
%10 = alloca i8, i64 %8
%11 = bitcast %struct.sockaddr_in* %4 to i8*
%12 = load i32, i32* @PF_INET
%13 = load i32, i32* @SOCK_STREAM
%14 = tail call i32 @socket(i32 %12, i32 %13, i32 0)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i32, i32* @AF_INET
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %20, i32* %21
%22 = tail call i32 @htons(i32 80)
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %22, i32* %23
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = tail call i8* @getip(i8* %25)
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %31
28: ; preds = %19
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.10, i64 0, i64 0))
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %19
%32 = load i32, i32* @AF_INET
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
%34 = call i64 @inet_pton(i32 %32, i8* %26, i32* %33)
%35 = icmp slt i64 %34, 1
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %31
%40 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%41 = call i64 @connect(i32 %14, %struct.sockaddr* %40, i32 12)
%42 = icmp slt i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %39
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%48 = call i32 @memset(i8* %5, i32 0, i32 512)
%49 = getelementptr inbounds i8*, i8** %1, i64 2
%50 = load i8*, i8** %49
%51 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0), i8* %50)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%53 = call i32 @strlen(i8* %5)
%54 = icmp sgt i32 %53, 0
br i1 %54, label %58, label %70
55: ; preds = %58
%56 = call i32 @strlen(i8* %5)
%57 = icmp slt i32 %66, %56
br i1 %57, label %58, label %70
58: ; preds = %46, %55
%59 = phi i32 [ %66, %55 ], [ 0, %46 ]
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %60
%62 = call i32 @strlen(i8* %5)
%63 = sub nsw i32 %62, %59
%64 = call i32 @send(i32 %14, i8* %61, i32 %63, i32 0)
%65 = icmp slt i32 %64, 0
%66 = add nsw i32 %64, %59
br i1 %65, label %67, label %55
67: ; preds = %58
%68 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %55, %46
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.9, i64 0, i64 0))
%72 = load i32, i32* @BUFSIZ
%73 = add nsw i32 %72, 1
%74 = call i32 @memset(i8* %10, i32 0, i32 %73)
%75 = load i32, i32* @BUFSIZ
%76 = call i32 @recv(i32 %14, i8* %10, i32 %75, i32 0)
%77 = icmp sgt i32 %76, 0
br i1 %77, label %78, label %90
78: ; preds = %70, %81
%79 = call i32 @strlen(i8* %10)
%80 = icmp eq i32 %79, 0
br i1 %80, label %90, label %81
81: ; preds = %78
%82 = load i32, i32* @stdout
%83 = call i32 @fprintf(i32 %82, i8* %10)
%84 = load i32, i32* @BUFSIZ
%85 = add nsw i32 %84, 1
%86 = call i32 @memset(i8* %10, i32 0, i32 %85)
%87 = load i32, i32* @BUFSIZ
%88 = call i32 @recv(i32 %14, i8* %10, i32 %87, i32 0)
%89 = icmp sgt i32 %88, 0
br i1 %89, label %78, label %90
90: ; preds = %81, %78, %70
%91 = call i32 @close(i32 %14)
ret i32 0
}