#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 *);
int /*<<< orphan*/ printf(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*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strlen(char *);
int main(int c, char **v) {
  char query[128] = {0};
  sprintf(query,
          "GET / HTTP/1.0\r\n"
          "Host: %s\r\n"
          "\r\n",
          v[1]);
  const char *hostname = v[1];
  printf("hostname = %s\n", hostname);
  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) {
      printf("recv result = 0\n");
      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    $0x4f0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1080 <memset@plt>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdce(%rip),%rsi
call   10e0 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rsi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x98(%rbp),%rdi
call   10a0 <gethostbyname@plt>
mov    %rax,-0xb0(%rbp)
cmpq   $0x0,-0xb0(%rbp)
jne    12d1 <main+0xe1>
mov    0x2d4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4e4(%rbp)
mov    -0x98(%rbp),%rax
mov    %rax,-0x4e0(%rbp)
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
call   10d0 <hstrerror@plt>
mov    -0x4e4(%rbp),%edi
mov    -0x4e0(%rbp),%rdx
mov    %rax,%rcx
lea    0xd6e(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1528 <main+0x338>
mov    -0xb0(%rbp),%rax
mov    (%rax),%rax
mov    0x2d06(%rip),%rcx
cmp    (%rcx),%rax
je     130e <main+0x11e>
mov    0x2cde(%rip),%rax
mov    (%rax),%edi
lea    0xd48(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1528 <main+0x338>
mov    0x2cd3(%rip),%rax
mov    (%rax),%rdi
mov    0x2ca9(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0xbc(%rbp)
cmpl   $0x0,-0xbc(%rbp)
jge    1353 <main+0x163>
lea    0xd19(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1528 <main+0x338>
mov    0x2c8e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xa0(%rbp)
mov    $0x50,%edi
call   1050 <htons@plt>
mov    %eax,-0xa4(%rbp)
mov    -0xb0(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0xa8(%rbp)
mov    -0xbc(%rbp),%edi
lea    -0xa8(%rbp),%rsi
mov    $0x10,%edx
call   10f0 <connect@plt>
cmp    $0x0,%rax
je     13cb <main+0x1db>
lea    0xcb3(%rip),%rdi
call   10c0 <perror@plt>
mov    -0xbc(%rbp),%edi
call   1090 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    1528 <main+0x338>
lea    -0x90(%rbp),%rax
mov    %rax,-0xb8(%rbp)
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0xd0(%rbp)
cmpq   $0x0,-0xd0(%rbp)
je     1474 <main+0x284>
mov    -0xbc(%rbp),%edi
mov    -0xb8(%rbp),%rsi
mov    -0xd0(%rbp),%rdx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %rax,-0xc8(%rbp)
cmpq   $0x0,-0xc8(%rbp)
jg     1442 <main+0x252>
lea    0xc39(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1528 <main+0x338>
mov    -0xc8(%rbp),%rcx
mov    -0xd0(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0xd0(%rbp)
mov    -0xc8(%rbp),%rax
add    -0xb8(%rbp),%rax
mov    %rax,-0xb8(%rbp)
jmp    13ec <main+0x1fc>
jmp    1479 <main+0x289>
mov    -0xbc(%rbp),%edi
lea    -0x4d0(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %rax,-0x4d8(%rbp)
cmpq   $0x0,-0x4d8(%rbp)
jne    14ba <main+0x2ca>
lea    0xbc1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1516 <main+0x326>
cmpq   $0x0,-0x4d8(%rbp)
jge    14eb <main+0x2fb>
lea    0xbb1(%rip),%rdi
call   10c0 <perror@plt>
mov    -0xbc(%rbp),%edi
call   1090 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    1528 <main+0x338>
jmp    14f0 <main+0x300>
lea    -0x4d0(%rbp),%rdi
mov    -0x4d8(%rbp),%rdx
mov    0x2abb(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1100 <fwrite@plt>
jmp    1479 <main+0x289>
mov    -0xbc(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x498,%rsp
mov    %rsi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
mov    0x8(%rsi),%rdx
lea    0xdc7(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10e0 <sprintf@plt>
mov    0x8(%rbx),%rbx
lea    0xdcf(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbx,%rdi
call   10a0 <gethostbyname@plt>
test   %rax,%rax
je     1388 <main+0x198>
mov    %rax,%rbp
mov    (%rax),%rdi
mov    0x2d72(%rip),%rbx
cmp    (%rbx),%rdi
jne    13b7 <main+0x1c7>
mov    0x2d42(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
test   %eax,%eax
js     13e5 <main+0x1f5>
mov    %eax,%r15d
mov    (%rbx),%rax
mov    %rax,0x8(%rsp)
mov    $0x50,%edi
call   1060 <htons@plt>
mov    %eax,0x4(%rsp)
mov    0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    %rsp,%rsi
mov    %r15d,%edi
mov    $0x10,%edx
call   10f0 <connect@plt>
test   %rax,%rax
jne    13ee <main+0x1fe>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
test   %rax,%rax
je     1311 <main+0x121>
mov    %rax,%rbx
nopw   0x0(%rax,%rax,1)
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1070 <send@plt>
test   %rax,%rax
jle    13f7 <main+0x207>
add    %rax,%rbp
sub    %rax,%rbx
jne    12f0 <main+0x100>
lea    0x90(%rsp),%rsi
xor    %r14d,%r14d
mov    %r15d,%edi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
je     1372 <main+0x182>
mov    0x2c89(%rip),%rbx
lea    0x90(%rsp),%rbp
nop
test   %rax,%rax
js     1405 <main+0x215>
mov    (%rbx),%ecx
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
call   1100 <fwrite@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
jne    1340 <main+0x150>
lea    0xcfb(%rip),%rdi
call   1040 <puts@plt>
mov    %r15d,%edi
call   1090 <close@plt>
jmp    13d4 <main+0x1e4>
mov    0x2c41(%rip),%rax
mov    (%rax),%ebp
mov    0x2c48(%rip),%rax
mov    (%rax),%edi
call   10d0 <hstrerror@plt>
lea    0xc86(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    13ce <main+0x1de>
mov    0x2c12(%rip),%rax
mov    (%rax),%edi
lea    0xc7c(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x498,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc6f(%rip),%rdi
jmp    13fe <main+0x20e>
lea    0xc6d(%rip),%rdi
jmp    140c <main+0x21c>
lea    0xc6c(%rip),%rdi
call   10c0 <perror@plt>
jmp    13ce <main+0x1de>
lea    0xc63(%rip),%rdi
call   10c0 <perror@plt>
mov    %r15d,%edi
call   1090 <close@plt>
jmp    13ce <main+0x1de>

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

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