#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 in_addr {
  int dummy;
};
struct sockaddr_in {
  struct in_addr sin_addr;
  int /*<<< orphan*/ sin_port;
  scalar_t__ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  scalar_t__ h_addrtype;
  scalar_t__ h_addr;
};
typedef scalar_t__ ssize_t;
typedef int /*<<< orphan*/ sin;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fwrite(char *, int, scalar_t__, int /*<<< orphan*/);
struct hostent *gethostbyname(char const *);
int /*<<< orphan*/ h_errno;
char *hstrerror(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ recv(int, char *, int, int /*<<< orphan*/);
scalar_t__ send(int, char const *, scalar_t__, int /*<<< orphan*/);
int socket(scalar_t__, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strlen(char const *);
int main(int c, char **v) {
  const char query[] = "GET / HTTP/1.0\r\n"
                       "Host: www.google.com\r\n"
                       "\r\n";
  const char hostname[] = "www.google.com";
  struct sockaddr_in sin;
  struct hostent *h;
  const char *cp;
  int fd;
  ssize_t n_written, remaining;
  char buf[1024];
  h = gethostbyname(hostname);
  if (!h) {
    fprintf(stderr, "Couldn't lookup %s: %s", hostname, hstrerror(h_errno));
    return 1;
  }
  if (h->h_addrtype != AF_INET) {
    fprintf(stderr, "No ipv6 support, sorry.");
    return 1;
  }
  fd = socket(AF_INET, SOCK_STREAM, 0);
  if (fd < 0) {
    perror("socket");
    return 1;
  }
  sin.sin_family = AF_INET;
  sin.sin_port = htons(80);
  sin.sin_addr = *(struct in_addr *)h->h_addr;
  if (connect(fd, (struct sockaddr *)&sin, sizeof(sin))) {
    perror("connect");
    close(fd);
    return 1;
  }
  cp = query;
  remaining = strlen(query);
  while (remaining) {
    n_written = send(fd, cp, remaining, 0);
    if (n_written <= 0) {
      perror("send");
      return 1;
    }
    remaining -= n_written;
    cp += n_written;
  }
  while (1) {
    ssize_t result = recv(fd, buf, sizeof(buf), 0);
    if (result == 0) {
      break;
    } else if (result < 0) {
      perror("recv");
      close(fd);
      return 1;
    }
    fwrite(buf, 1, result, stdout);
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe0c(%rip),%rsi
mov    $0x29,%edx
call   10a0 <memcpy@plt>
mov    0xe24(%rip),%rax
mov    %rax,-0x4f(%rbp)
mov    0xe22(%rip),%eax
mov    %eax,-0x47(%rbp)
mov    0xe1c(%rip),%ax
mov    %ax,-0x43(%rbp)
mov    0xe14(%rip),%al
mov    %al,-0x41(%rbp)
lea    -0x4f(%rbp),%rdi
call   1080 <gethostbyname@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    1290 <main+0xc0>
mov    0x2d8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4a4(%rbp)
lea    -0x4f(%rbp),%rax
mov    %rax,-0x4a0(%rbp)
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
call   10c0 <hstrerror@plt>
mov    -0x4a4(%rbp),%edi
mov    -0x4a0(%rbp),%rdx
mov    %rax,%rcx
lea    0xdbb(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1491 <main+0x2c1>
mov    -0x68(%rbp),%rax
mov    (%rax),%rax
mov    0x2d4a(%rip),%rcx
cmp    (%rcx),%rax
je     12ca <main+0xfa>
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
lea    0xd98(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1491 <main+0x2c1>
mov    0x2d17(%rip),%rax
mov    (%rax),%rdi
mov    0x2ced(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jge    1309 <main+0x139>
lea    0xd6f(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1491 <main+0x2c1>
mov    0x2cd8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
mov    $0x50,%edi
call   1050 <htons@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x68(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    -0x74(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0x10,%edx
call   10d0 <connect@plt>
cmp    $0x0,%rax
je     136c <main+0x19c>
lea    0xd1b(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x74(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    1491 <main+0x2c1>
lea    -0x40(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     13f4 <main+0x224>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rsi
mov    -0x88(%rbp),%rdx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %rax,-0x80(%rbp)
cmpq   $0x0,-0x80(%rbp)
jg     13ce <main+0x1fe>
lea    0xcb9(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1491 <main+0x2c1>
mov    -0x80(%rbp),%rcx
mov    -0x88(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x88(%rbp)
mov    -0x80(%rbp),%rax
add    -0x70(%rbp),%rax
mov    %rax,-0x70(%rbp)
jmp    1384 <main+0x1b4>
jmp    13f9 <main+0x229>
mov    -0x74(%rbp),%edi
lea    -0x490(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %rax,-0x498(%rbp)
cmpq   $0x0,-0x498(%rbp)
jne    1429 <main+0x259>
jmp    1482 <main+0x2b2>
cmpq   $0x0,-0x498(%rbp)
jge    1457 <main+0x287>
lea    0xc3d(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x74(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    1491 <main+0x2c1>
jmp    145c <main+0x28c>
lea    -0x490(%rbp),%rdi
mov    -0x498(%rbp),%rdx
mov    0x2b4f(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   10e0 <fwrite@plt>
jmp    13f9 <main+0x229>
mov    -0x74(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x458,%rsp
movups 0xe45(%rip),%xmm0
movups %xmm0,0x39(%rsp)
movaps 0xe30(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe14(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movabs $0x6d6f632e656c67,%rax
mov    %rax,0x7(%rsp)
movabs $0x676f6f672e777777,%rax
6f 6f 67
mov    %rax,(%rsp)
mov    %rsp,%rdi
call   1080 <gethostbyname@plt>
test   %rax,%rax
je     132c <main+0x16c>
mov    %rax,%rbp
mov    (%rax),%rdi
mov    0x2dbc(%rip),%rbx
cmp    (%rbx),%rdi
jne    135b <main+0x19b>
mov    0x2d8c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
test   %eax,%eax
js     1389 <main+0x1c9>
mov    %eax,%r15d
mov    (%rbx),%rax
mov    %rax,0x18(%rsp)
mov    $0x50,%edi
call   1050 <htons@plt>
mov    %eax,0x14(%rsp)
mov    0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0x10,%edx
call   10c0 <connect@plt>
test   %rax,%rax
jne    1392 <main+0x1d2>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
je     12c1 <main+0x101>
mov    %rax,%rbx
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1060 <send@plt>
test   %rax,%rax
jle    139b <main+0x1db>
add    %rax,%rbp
sub    %rax,%rbx
jne    12a0 <main+0xe0>
lea    0x50(%rsp),%rsi
xor    %r14d,%r14d
mov    %r15d,%edi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
je     1322 <main+0x162>
mov    0x2cdc(%rip),%rbx
lea    0x50(%rsp),%rbp
nopl   0x0(%rax)
test   %rax,%rax
js     13a9 <main+0x1e9>
mov    (%rbx),%ecx
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
call   10d0 <fwrite@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
jne    12f0 <main+0x130>
mov    %r15d,%edi
call   1070 <close@plt>
jmp    1378 <main+0x1b8>
mov    0x2c9d(%rip),%rax
mov    (%rax),%ebx
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
call   10b0 <hstrerror@plt>
lea    0xcee(%rip),%rsi
mov    %rsp,%rdx
mov    %ebx,%edi
mov    %rax,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    1372 <main+0x1b2>
mov    0x2c6e(%rip),%rax
mov    (%rax),%edi
lea    0xce4(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x458,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcd7(%rip),%rdi
jmp    13a2 <main+0x1e2>
lea    0xcd5(%rip),%rdi
jmp    13b0 <main+0x1f0>
lea    0xcd4(%rip),%rdi
call   10a0 <perror@plt>
jmp    1372 <main+0x1b2>
lea    0xccb(%rip),%rdi
call   10a0 <perror@plt>
mov    %r15d,%edi
call   1070 <close@plt>
jmp    1372 <main+0x1b2>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.in_addr, i32, i64 }
%struct.in_addr = type { i32 }
%struct.hostent = type { i64, i64 }
%struct.sockaddr = type { i32 }
@__const.main.query = [41 x i8] c"GET / HTTP/1.0\0D\0AHost: www.google.com\0D\0A\0D\0A\00"
@__const.main.hostname = [15 x i8] c"www.google.com\00"
@stderr = global i32 0
@.str = [23 x i8] c"Couldn't lookup %s: %s\00"
@h_errno = global i32 0
@AF_INET = global i64 0
@.str.1 = [24 x i8] c"No ipv6 support, sorry.\00"
@SOCK_STREAM = global i32 0
@.str.2 = [7 x i8] c"socket\00"
@.str.3 = [8 x i8] c"connect\00"
@.str.4 = [5 x i8] c"send\00"
@.str.5 = [5 x i8] c"recv\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [41 x i8]
%7 = alloca [15 x i8]
%8 = alloca %struct.sockaddr_in
%9 = alloca %struct.hostent*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i64
%13 = alloca i64
%14 = alloca [1024 x i8]
%15 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = bitcast [41 x i8]* %6 to i8*
%17 = bitcast [15 x i8]* %7 to i8*
%18 = getelementptr inbounds [15 x i8], [15 x i8]* %7, i64 0, i64 0
%19 = call %struct.hostent* @gethostbyname(i8* %18)
store %struct.hostent* %19, %struct.hostent** %9
%20 = load %struct.hostent*, %struct.hostent** %9
%21 = icmp ne %struct.hostent* %20, null
br i1 %21, label %28, label %22
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = getelementptr inbounds [15 x i8], [15 x i8]* %7, i64 0, i64 0
%25 = load i32, i32* @h_errno
%26 = call i8* @hstrerror(i32 %25)
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %24, i8* %26)
store i32 1, i32* %3
br label %112
28: ; preds = %2
%29 = load %struct.hostent*, %struct.hostent** %9
%30 = getelementptr inbounds %struct.hostent, %struct.hostent* %29, i32 0, i32 0
%31 = load i64, i64* %30
%32 = load i64, i64* @AF_INET
%33 = icmp ne i64 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %112
37: ; preds = %28
%38 = load i64, i64* @AF_INET
%39 = load i32, i32* @SOCK_STREAM
%40 = call i32 @socket(i64 %38, i32 %39, i32 0)
store i32 %40, i32* %11
%41 = load i32, i32* %11
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %37
%44 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %112
45: ; preds = %37
%46 = load i64, i64* @AF_INET
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i64 %46, i64* %47
%48 = call i32 @htons(i32 80)
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
store i32 %48, i32* %49
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%51 = load %struct.hostent*, %struct.hostent** %9
%52 = getelementptr inbounds %struct.hostent, %struct.hostent* %51, i32 0, i32 1
%53 = load i64, i64* %52
%54 = inttoptr i64 %53 to %struct.in_addr*
%55 = bitcast %struct.in_addr* %50 to i8*
%56 = bitcast %struct.in_addr* %54 to i8*
%57 = load i32, i32* %11
%58 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%59 = call i64 @connect(i32 %57, %struct.sockaddr* %58, i32 16)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %65
61: ; preds = %45
%62 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%63 = load i32, i32* %11
%64 = call i32 @close(i32 %63)
store i32 1, i32* %3
br label %112
65: ; preds = %45
%66 = getelementptr inbounds [41 x i8], [41 x i8]* %6, i64 0, i64 0
store i8* %66, i8** %10
%67 = getelementptr inbounds [41 x i8], [41 x i8]* %6, i64 0, i64 0
%68 = call i64 @strlen(i8* %67)
store i64 %68, i64* %13
br label %69
69: ; preds = %81, %65
%70 = load i64, i64* %13
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %88
72: ; preds = %69
%73 = load i32, i32* %11
%74 = load i8*, i8** %10
%75 = load i64, i64* %13
%76 = call i64 @send(i32 %73, i8* %74, i64 %75, i32 0)
store i64 %76, i64* %12
%77 = load i64, i64* %12
%78 = icmp sle i64 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %72
%80 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %112
81: ; preds = %72
%82 = load i64, i64* %12
%83 = load i64, i64* %13
%84 = sub nsw i64 %83, %82
store i64 %84, i64* %13
%85 = load i64, i64* %12
%86 = load i8*, i8** %10
%87 = getelementptr inbounds i8, i8* %86, i64 %85
store i8* %87, i8** %10
br label %69
88: ; preds = %69
br label %89
89: ; preds = %88, %104
%90 = load i32, i32* %11
%91 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%92 = call i64 @recv(i32 %90, i8* %91, i32 1024, i32 0)
store i64 %92, i64* %15
%93 = load i64, i64* %15
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %96
95: ; preds = %89
br label %109
96: ; preds = %89
%97 = load i64, i64* %15
%98 = icmp slt i64 %97, 0
br i1 %98, label %99, label %103
99: ; preds = %96
%100 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%101 = load i32, i32* %11
%102 = call i32 @close(i32 %101)
store i32 1, i32* %3
br label %112
103: ; preds = %96
br label %104
104: ; preds = %103
%105 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%106 = load i64, i64* %15
%107 = load i32, i32* @stdout
%108 = call i32 @fwrite(i8* %105, i32 1, i64 %106, i32 %107)
br label %89
109: ; preds = %95
%110 = load i32, i32* %11
%111 = call i32 @close(i32 %110)
store i32 0, i32* %3
br label %112
112: ; preds = %109, %99, %79, %61, %43, %34, %22
%113 = load i32, i32* %3
ret i32 %113
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.in_addr, i32, i64 }
%struct.in_addr = type { i32 }
%struct.hostent = type { i64, i64 }
%struct.sockaddr = type { i32 }
@__const.main.query = [41 x i8] c"GET / HTTP/1.0\0D\0AHost: www.google.com\0D\0A\0D\0A\00"
@__const.main.hostname = [15 x i8] c"www.google.com\00"
@stderr = global i32 0
@.str = [23 x i8] c"Couldn't lookup %s: %s\00"
@h_errno = global i32 0
@AF_INET = global i64 0
@.str.1 = [24 x i8] c"No ipv6 support, sorry.\00"
@SOCK_STREAM = global i32 0
@.str.2 = [7 x i8] c"socket\00"
@.str.3 = [8 x i8] c"connect\00"
@.str.4 = [5 x i8] c"send\00"
@.str.5 = [5 x i8] c"recv\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [41 x i8]
%4 = alloca [15 x i8]
%5 = alloca %struct.sockaddr_in
%6 = alloca [1024 x i8]
%7 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%9 = bitcast %struct.sockaddr_in* %5 to i8*
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = call %struct.hostent* @gethostbyname(i8* %8)
%12 = icmp eq %struct.hostent* %11, null
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i32, i32* @h_errno
%16 = call i8* @hstrerror(i32 %15)
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %16)
br label %78
18: ; preds = %2
%19 = getelementptr inbounds %struct.hostent, %struct.hostent* %11, i64 0, i32 0
%20 = load i64, i64* %19
%21 = load i64, i64* @AF_INET
%22 = icmp eq i64 %20, %21
br i1 %22, label %26, label %23
23: ; preds = %18
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %78
26: ; preds = %18
%27 = load i32, i32* @SOCK_STREAM
%28 = call i32 @socket(i64 %20, i32 %27, i32 0)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %78
32: ; preds = %26
%33 = load i64, i64* @AF_INET
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i64 %33, i64* %34
%35 = call i32 @htons(i32 80)
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1
store i32 %35, i32* %36
%37 = getelementptr inbounds %struct.hostent, %struct.hostent* %11, i64 0, i32 1
%38 = load i64, i64* %37
%39 = inttoptr i64 %38 to i32*
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0, i32 0
%41 = load i32, i32* %39
store i32 %41, i32* %40
%42 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%43 = call i64 @connect(i32 %28, %struct.sockaddr* %42, i32 16)
%44 = icmp eq i64 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %32
%46 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%47 = call i32 @close(i32 %28)
br label %78
48: ; preds = %32
%49 = call i64 @strlen(i8* %7)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %61, %48
%52 = call i64 @recv(i32 %28, i8* %10, i32 1024, i32 0)
%53 = icmp eq i64 %52, 0
br i1 %53, label %76, label %65
54: ; preds = %48, %61
%55 = phi i64 [ %62, %61 ], [ %49, %48 ]
%56 = phi i8* [ %63, %61 ], [ %7, %48 ]
%57 = call i64 @send(i32 %28, i8* %56, i64 %55, i32 0)
%58 = icmp slt i64 %57, 1
br i1 %58, label %59, label %61
59: ; preds = %54
%60 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %78
61: ; preds = %54
%62 = sub nsw i64 %55, %57
%63 = getelementptr inbounds i8, i8* %56, i64 %57
%64 = icmp eq i64 %62, 0
br i1 %64, label %51, label %54
65: ; preds = %51, %71
%66 = phi i64 [ %74, %71 ], [ %52, %51 ]
%67 = icmp slt i64 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %65
%69 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%70 = call i32 @close(i32 %28)
br label %78
71: ; preds = %65
%72 = load i32, i32* @stdout
%73 = call i32 @fwrite(i8* %10, i32 1, i64 %66, i32 %72)
%74 = call i64 @recv(i32 %28, i8* %10, i32 1024, i32 0)
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %65
76: ; preds = %71, %51
%77 = call i32 @close(i32 %28)
br label %78
78: ; preds = %68, %76, %59, %45, %30, %23, %13
%79 = phi i32 [ 1, %23 ], [ 1, %30 ], [ 1, %45 ], [ 1, %59 ], [ 0, %76 ], [ 1, %13 ], [ 1, %68 ]
ret i32 %79
}