#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 scalar_t__ u_int;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ get_buf;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ _ip;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *get_ip(char *, char *, int);
int /*<<< orphan*/ htons(scalar_t__);
int inet_pton(int /*<<< orphan*/, char *, void *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, scalar_t__, int /*<<< orphan*/);
int snprintf(char *, scalar_t__, char *, char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char *);
char *strstr(char *, char *);
char *http_get(char *host, u_int port, char *page, char *rsp, u_int rsp_len) {
  struct sockaddr_in remote;
  int sock, tmpres;
  u_int out_len = 0;
  char *ip, _ip[64];
  char get_buf[256];
  char buf[1024];
  int htmlstart = 0, debug = 0;
  char *htmlcontent;
  if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
    return (NULL);
  }
  snprintf(get_buf, sizeof(get_buf), "GET /%s HTTP/1.0\r\nHost: %s\r\n\r\n",
           (page[0] == '/') ? &page[1] : page, host);
  if (debug)
    fprintf(stderr, "Query is:\n---\n%s---\n", get_buf);
  if ((ip = get_ip(host, _ip, sizeof(_ip))) == NULL)
    return (NULL);
  remote.sin_family = AF_INET;
  tmpres = inet_pton(AF_INET, ip, (void *)(&(remote.sin_addr.s_addr)));
  if (tmpres < 0) {
    return (NULL);
  } else if (tmpres == 0) {
    return (NULL);
  }
  remote.sin_port = htons(port);
  if (connect(sock, (struct sockaddr *)&remote, sizeof(struct sockaddr)) < 0) {
    return (NULL);
  }
  u_int sent = 0;
  while (sent < strlen(get_buf)) {
    tmpres = send(sock, get_buf + sent, strlen(get_buf) - sent, 0);
    if (tmpres == -1) {
      return (NULL);
    }
    sent += tmpres;
  }
  memset(buf, 0, sizeof(buf));
  while ((tmpres = recv(sock, buf, sizeof(buf) - 1, 0)) > 0) {
    buf[tmpres] = '\0';
    if (debug)
      fprintf(stderr, "Received %d bytes\n", tmpres);
    if (htmlstart == 0) {
      htmlcontent = strstr(buf, "\r\n\r\n");
      if (htmlcontent != NULL) {
        htmlstart = 1;
        htmlcontent += 4;
      }
    } else
      htmlcontent = buf;
    if (htmlstart) {
      if (rsp_len > out_len) {
        int n = snprintf(&rsp[out_len], rsp_len - out_len, "%s", htmlcontent);
        if (n > 0)
          out_len += n;
      }
    }
  }
  close(sock);
  if (debug)
    fprintf(stderr, "%s\n", rsp);
  return (rsp);
}


x86 assembly (clang, -O0):
<http_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5f0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movq   $0x0,-0x50(%rbp)
movl   $0x0,-0x5a4(%rbp)
movl   $0x0,-0x5a8(%rbp)
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
mov    0x2dad(%rip),%rax
mov    (%rax),%esi
mov    0x2dbc(%rip),%rax
mov    (%rax),%edx
call   10f0 <socket@plt>
mov    %eax,-0x44(%rbp)
cmp    $0x0,%eax
jge    1244 <http_get+0x74>
movq   $0x0,-0x8(%rbp)
jmp    15b7 <http_get+0x3e7>
lea    -0x1a0(%rbp),%rax
mov    %rax,-0x5c8(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1276 <http_get+0xa6>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x5d0(%rbp)
jmp    1281 <http_get+0xb1>
mov    -0x20(%rbp),%rax
mov    %rax,-0x5d0(%rbp)
mov    -0x5c8(%rbp),%rdi
mov    -0x5d0(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    $0x100,%esi
lea    0xd61(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
cmpl   $0x0,-0x5a8(%rbp)
je     12d1 <http_get+0x101>
mov    0x2d16(%rip),%rax
mov    (%rax),%edi
lea    -0x1a0(%rbp),%rdx
lea    0xd55(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x40,%edx
call   10c0 <get_ip@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    1301 <http_get+0x131>
movq   $0x0,-0x8(%rbp)
jmp    15b7 <http_get+0x3e7>
mov    0x2ce0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2cd4(%rip),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%rsi
lea    -0x40(%rbp),%rdx
add    $0x4,%rdx
call   10b0 <inet_pton@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
jge    1341 <http_get+0x171>
movq   $0x0,-0x8(%rbp)
jmp    15b7 <http_get+0x3e7>
cmpl   $0x0,-0x48(%rbp)
jne    1358 <http_get+0x188>
movq   $0x0,-0x8(%rbp)
jmp    15b7 <http_get+0x3e7>
jmp    135d <http_get+0x18d>
mov    -0x18(%rbp),%rdi
call   1050 <htons@plt>
mov    %eax,-0x40(%rbp)
mov    -0x44(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x4,%edx
call   10d0 <connect@plt>
cmp    $0x0,%rax
jge    1391 <http_get+0x1c1>
movq   $0x0,-0x8(%rbp)
jmp    15b7 <http_get+0x3e7>
movq   $0x0,-0x5b8(%rbp)
mov    -0x5b8(%rbp),%rax
mov    %rax,-0x5d8(%rbp)
lea    -0x1a0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x5d8(%rbp),%rax
cmp    %rcx,%rax
jge    1442 <http_get+0x272>
mov    -0x44(%rbp),%eax
mov    %eax,-0x5e4(%rbp)
lea    -0x1a0(%rbp),%rax
add    -0x5b8(%rbp),%rax
mov    %rax,-0x5e0(%rbp)
lea    -0x1a0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x5e4(%rbp),%edi
mov    -0x5e0(%rbp),%rsi
mov    %rax,%rdx
sub    -0x5b8(%rbp),%rdx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0xffffffff,-0x48(%rbp)
jne    142b <http_get+0x25b>
movq   $0x0,-0x8(%rbp)
jmp    15b7 <http_get+0x3e7>
movslq -0x48(%rbp),%rax
add    -0x5b8(%rbp),%rax
mov    %rax,-0x5b8(%rbp)
jmp    139c <http_get+0x1cc>
lea    -0x5a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    -0x44(%rbp),%edi
lea    -0x5a0(%rbp),%rsi
mov    $0x3ff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x48(%rbp)
cmp    $0x0,%eax
jle    157f <http_get+0x3af>
movslq -0x48(%rbp),%rax
movb   $0x0,-0x5a0(%rbp,%rax,1)
cmpl   $0x0,-0x5a8(%rbp)
je     14aa <http_get+0x2da>
mov    0x2b39(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%edx
lea    0xb91(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
cmpl   $0x0,-0x5a4(%rbp)
jne    1500 <http_get+0x330>
lea    -0x5a0(%rbp),%rdi
lea    0xb55(%rip),%rsi
call   10e0 <strstr@plt>
mov    %rax,-0x5b0(%rbp)
cmpq   $0x0,-0x5b0(%rbp)
je     14fb <http_get+0x32b>
movl   $0x1,-0x5a4(%rbp)
mov    -0x5b0(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x5b0(%rbp)
jmp    150e <http_get+0x33e>
lea    -0x5a0(%rbp),%rax
mov    %rax,-0x5b0(%rbp)
cmpl   $0x0,-0x5a4(%rbp)
je     157a <http_get+0x3aa>
mov    -0x30(%rbp),%rax
cmp    -0x50(%rbp),%rax
jle    1575 <http_get+0x3a5>
mov    -0x28(%rbp),%rdi
add    -0x50(%rbp),%rdi
mov    -0x30(%rbp),%rsi
sub    -0x50(%rbp),%rsi
mov    -0x5b0(%rbp),%rcx
lea    0xb00(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
mov    %eax,-0x5bc(%rbp)
cmpl   $0x0,-0x5bc(%rbp)
jle    1570 <http_get+0x3a0>
movslq -0x5bc(%rbp),%rax
add    -0x50(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    1575 <http_get+0x3a5>
jmp    157a <http_get+0x3aa>
jmp    1455 <http_get+0x285>
mov    -0x44(%rbp),%edi
call   1090 <close@plt>
cmpl   $0x0,-0x5a8(%rbp)
je     15af <http_get+0x3df>
mov    0x2a35(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xaa2(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x5f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_get>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x568,%rsp
mov    %r8,%r15
mov    %rcx,0x18(%rsp)
mov    %rdx,%rbp
mov    %rsi,%r12
mov    %rdi,%rbx
mov    0x2dff(%rip),%r14
mov    (%r14),%edi
mov    0x2ddd(%rip),%rax
mov    (%rax),%esi
mov    0x2de4(%rip),%rax
mov    (%rax),%edx
call   10e0 <socket@plt>
test   %eax,%eax
js     1327 <http_get+0x167>
mov    %eax,%r13d
xor    %ecx,%ecx
cmpb   $0x2f,0x0(%rbp)
sete   %cl
add    %rbp,%rcx
lea    0xddf(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0x100,%esi
mov    %rbx,%r8
xor    %eax,%eax
call   1070 <snprintf@plt>
lea    0x120(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x40,%edx
call   10b0 <get_ip@plt>
test   %rax,%rax
je     1327 <http_get+0x167>
mov    (%r14),%edi
mov    %edi,0x10(%rsp)
lea    0xc(%rsp),%rdx
mov    %rax,%rsi
call   10a0 <inet_pton@plt>
test   %eax,%eax
jle    1327 <http_get+0x167>
mov    %r12,%rdi
call   1050 <htons@plt>
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %r13d,%edi
mov    $0x4,%edx
call   10c0 <connect@plt>
test   %rax,%rax
js     1327 <http_get+0x167>
lea    0x20(%rsp),%rdi
call   1040 <strlen@plt>
test   %rax,%rax
mov    0x18(%rsp),%r14
jle    12ef <http_get+0x12f>
lea    0x20(%rsp),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%rsp,%rbp,1),%rsi
add    $0x20,%rsi
sub    %rbp,%rax
mov    %r13d,%edi
mov    %rax,%rdx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    $0xffffffff,%eax
je     1327 <http_get+0x167>
cltq
add    %rax,%rbp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    %rbp,%rax
jg     12c0 <http_get+0x100>
lea    0x160(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x3ff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    13c3 <http_get+0x203>
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    1366 <http_get+0x1a6>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x568,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x3ff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    13c3 <http_get+0x203>
mov    %eax,%eax
movb   $0x0,0x160(%rsp,%rax,1)
mov    %rbx,%rcx
test   %ebp,%ebp
jne    1392 <http_get+0x1d2>
mov    %rbx,%rdi
lea    0xc99(%rip),%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
je     133f <http_get+0x17f>
mov    %rax,%rcx
add    $0x4,%rcx
mov    $0x1,%ebp
cmp    %r15,%r12
jge    1350 <http_get+0x190>
lea    (%r14,%r12,1),%rdi
mov    %r15,%rsi
sub    %r12,%rsi
lea    0xc72(%rip),%rdx
xor    %eax,%eax
call   1070 <snprintf@plt>
test   %eax,%eax
mov    $0x0,%ecx
cmovs  %ecx,%eax
add    %rax,%r12
jmp    1350 <http_get+0x190>
mov    %r13d,%edi
call   1090 <close@plt>
jmp    132a <http_get+0x16a>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str = [31 x i8] c"GET /%s HTTP/1.0\0D\0AHost: %s\0D\0A\0D\0A\00"
@stderr = global i32 0
@.str.1 = [21 x i8] c"Query is:\0A---\0A%s---\0A\00"
@.str.2 = [19 x i8] c"Received %d bytes\0A\00"
@.str.3 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i8* @http_get(i8* %0, i64 %1, i8* %2, i8* %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca %struct.sockaddr_in
%13 = alloca i32
%14 = alloca i32
%15 = alloca i64
%16 = alloca i8*
%17 = alloca [64 x i8]
%18 = alloca [256 x i8]
%19 = alloca [1024 x i8]
%20 = alloca i32
%21 = alloca i32
%22 = alloca i8*
%23 = alloca i64
%24 = alloca i32
store i8* %0, i8** %7
store i64 %1, i64* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i64 %4, i64* %11
store i64 0, i64* %15
store i32 0, i32* %20
store i32 0, i32* %21
%25 = load i32, i32* @AF_INET
%26 = load i32, i32* @SOCK_STREAM
%27 = load i32, i32* @IPPROTO_TCP
%28 = call i32 @socket(i32 %25, i32 %26, i32 %27)
store i32 %28, i32* %13
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %5
store i8* null, i8** %6
br label %178
31: ; preds = %5
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%33 = load i8*, i8** %9
%34 = getelementptr inbounds i8, i8* %33, i64 0
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 47
br i1 %37, label %38, label %41
38: ; preds = %31
%39 = load i8*, i8** %9
%40 = getelementptr inbounds i8, i8* %39, i64 1
br label %43
41: ; preds = %31
%42 = load i8*, i8** %9
br label %43
43: ; preds = %41, %38
%44 = phi i8* [ %40, %38 ], [ %42, %41 ]
%45 = load i8*, i8** %7
%46 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %32, i64 256, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %44, i8* %45)
%47 = load i32, i32* %21
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %43
%50 = load i32, i32* @stderr
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %51)
br label %53
53: ; preds = %49, %43
%54 = load i8*, i8** %7
%55 = getelementptr inbounds [64 x i8], [64 x i8]* %17, i64 0, i64 0
%56 = call i8* @get_ip(i8* %54, i8* %55, i32 64)
store i8* %56, i8** %16
%57 = icmp eq i8* %56, null
br i1 %57, label %58, label %59
58: ; preds = %53
store i8* null, i8** %6
br label %178
59: ; preds = %53
%60 = load i32, i32* @AF_INET
%61 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 2
store i32 %60, i32* %61
%62 = load i32, i32* @AF_INET
%63 = load i8*, i8** %16
%64 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 1
%65 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %64, i32 0, i32 0
%66 = bitcast i32* %65 to i8*
%67 = call i32 @inet_pton(i32 %62, i8* %63, i8* %66)
store i32 %67, i32* %14
%68 = load i32, i32* %14
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %59
store i8* null, i8** %6
br label %178
71: ; preds = %59
%72 = load i32, i32* %14
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %75
74: ; preds = %71
store i8* null, i8** %6
br label %178
75: ; preds = %71
br label %76
76: ; preds = %75
%77 = load i64, i64* %8
%78 = call i32 @htons(i64 %77)
%79 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
store i32 %78, i32* %79
%80 = load i32, i32* %13
%81 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%82 = call i64 @connect(i32 %80, %struct.sockaddr* %81, i32 4)
%83 = icmp slt i64 %82, 0
br i1 %83, label %84, label %85
84: ; preds = %76
store i8* null, i8** %6
br label %178
85: ; preds = %76
store i64 0, i64* %23
br label %86
86: ; preds = %104, %85
%87 = load i64, i64* %23
%88 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%89 = call i64 @strlen(i8* %88)
%90 = icmp slt i64 %87, %89
br i1 %90, label %91, label %109
91: ; preds = %86
%92 = load i32, i32* %13
%93 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%94 = load i64, i64* %23
%95 = getelementptr inbounds i8, i8* %93, i64 %94
%96 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%97 = call i64 @strlen(i8* %96)
%98 = load i64, i64* %23
%99 = sub nsw i64 %97, %98
%100 = call i32 @send(i32 %92, i8* %95, i64 %99, i32 0)
store i32 %100, i32* %14
%101 = load i32, i32* %14
%102 = icmp eq i32 %101, -1
br i1 %102, label %103, label %104
103: ; preds = %91
store i8* null, i8** %6
br label %178
104: ; preds = %91
%105 = load i32, i32* %14
%106 = sext i32 %105 to i64
%107 = load i64, i64* %23
%108 = add nsw i64 %107, %106
store i64 %108, i64* %23
br label %86
109: ; preds = %86
%110 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 0
%111 = call i32 @memset(i8* %110, i32 0, i32 1024)
br label %112
112: ; preds = %166, %109
%113 = load i32, i32* %13
%114 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 0
%115 = call i32 @recv(i32 %113, i8* %114, i32 1023, i32 0)
store i32 %115, i32* %14
%116 = icmp sgt i32 %115, 0
br i1 %116, label %117, label %167
117: ; preds = %112
%118 = load i32, i32* %14
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 %119
store i8 0, i8* %120
%121 = load i32, i32* %21
%122 = icmp ne i32 %121, 0
br i1 %122, label %123, label %127
123: ; preds = %117
%124 = load i32, i32* @stderr
%125 = load i32, i32* %14
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %125)
br label %127
127: ; preds = %123, %117
%128 = load i32, i32* %20
%129 = icmp eq i32 %128, 0
br i1 %129, label %130, label %139
130: ; preds = %127
%131 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 0
%132 = call i8* @strstr(i8* %131, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i8* %132, i8** %22
%133 = load i8*, i8** %22
%134 = icmp ne i8* %133, null
br i1 %134, label %135, label %138
135: ; preds = %130
store i32 1, i32* %20
%136 = load i8*, i8** %22
%137 = getelementptr inbounds i8, i8* %136, i64 4
store i8* %137, i8** %22
br label %138
138: ; preds = %135, %130
br label %141
139: ; preds = %127
%140 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 0
store i8* %140, i8** %22
br label %141
141: ; preds = %139, %138
%142 = load i32, i32* %20
%143 = icmp ne i32 %142, 0
br i1 %143, label %144, label %166
144: ; preds = %141
%145 = load i64, i64* %11
%146 = load i64, i64* %15
%147 = icmp sgt i64 %145, %146
br i1 %147, label %148, label %165
148: ; preds = %144
%149 = load i8*, i8** %10
%150 = load i64, i64* %15
%151 = getelementptr inbounds i8, i8* %149, i64 %150
%152 = load i64, i64* %11
%153 = load i64, i64* %15
%154 = sub nsw i64 %152, %153
%155 = load i8*, i8** %22
%156 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %151, i64 %154, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %155)
store i32 %156, i32* %24
%157 = load i32, i32* %24
%158 = icmp sgt i32 %157, 0
br i1 %158, label %159, label %164
159: ; preds = %148
%160 = load i32, i32* %24
%161 = sext i32 %160 to i64
%162 = load i64, i64* %15
%163 = add nsw i64 %162, %161
store i64 %163, i64* %15
br label %164
164: ; preds = %159, %148
br label %165
165: ; preds = %164, %144
br label %166
166: ; preds = %165, %141
br label %112
167: ; preds = %112
%168 = load i32, i32* %13
%169 = call i32 @close(i32 %168)
%170 = load i32, i32* %21
%171 = icmp ne i32 %170, 0
br i1 %171, label %172, label %176
172: ; preds = %167
%173 = load i32, i32* @stderr
%174 = load i8*, i8** %10
%175 = call i32 (i32, i8*, ...) @fprintf(i32 %173, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %174)
br label %176
176: ; preds = %172, %167
%177 = load i8*, i8** %10
store i8* %177, i8** %6
br label %178
178: ; preds = %176, %103, %84, %74, %70, %58, %30
%179 = load i8*, i8** %6
ret i8* %179
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str = [31 x i8] c"GET /%s HTTP/1.0\0D\0AHost: %s\0D\0A\0D\0A\00"
@stderr = global i32 0
@.str.3 = [5 x i8] c"\0D\0A\0D\0A\00"
@.str.4 = [3 x i8] c"%s\00"
define i8* @http_get(i8* %0, i64 %1, i8* %2, i8* %3, i64 %4) {
%6 = alloca %struct.sockaddr_in
%7 = alloca [64 x i8]
%8 = alloca [256 x i8]
%9 = alloca [1024 x i8]
%10 = bitcast %struct.sockaddr_in* %6 to i8*
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%14 = load i32, i32* @AF_INET
%15 = load i32, i32* @SOCK_STREAM
%16 = load i32, i32* @IPPROTO_TCP
%17 = tail call i32 @socket(i32 %14, i32 %15, i32 %16)
%18 = icmp slt i32 %17, 0
br i1 %18, label %89, label %19
19: ; preds = %5
%20 = load i8, i8* %2
%21 = icmp eq i8 %20, 47
%22 = zext i1 %21 to i64
%23 = getelementptr i8, i8* %2, i64 %22
%24 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %12, i64 256, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %23, i8* %0)
%25 = call i8* @get_ip(i8* %0, i8* %11, i32 64)
%26 = icmp eq i8* %25, null
br i1 %26, label %89, label %27
27: ; preds = %19
%28 = load i32, i32* @AF_INET
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2
store i32 %28, i32* %29
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1, i32 0
%31 = bitcast i32* %30 to i8*
%32 = call i32 @inet_pton(i32 %28, i8* %25, i8* %31)
%33 = icmp slt i32 %32, 1
br i1 %33, label %89, label %34
34: ; preds = %27
%35 = call i32 @htons(i64 %1)
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
store i32 %35, i32* %36
%37 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%38 = call i64 @connect(i32 %17, %struct.sockaddr* %37, i32 4)
%39 = icmp slt i64 %38, 0
br i1 %39, label %89, label %40
40: ; preds = %34
%41 = call i64 @strlen(i8* %12)
%42 = icmp sgt i64 %41, 0
br i1 %42, label %46, label %55
43: ; preds = %46
%44 = call i64 @strlen(i8* %12)
%45 = icmp sgt i64 %44, %54
br i1 %45, label %46, label %55
46: ; preds = %40, %43
%47 = phi i64 [ %44, %43 ], [ %41, %40 ]
%48 = phi i64 [ %54, %43 ], [ 0, %40 ]
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %48
%50 = sub nsw i64 %47, %48
%51 = call i32 @send(i32 %17, i8* %49, i64 %50, i32 0)
%52 = icmp eq i32 %51, -1
%53 = sext i32 %51 to i64
%54 = add nsw i64 %48, %53
br i1 %52, label %89, label %43
55: ; preds = %43, %40
%56 = call i32 @memset(i8* %13, i32 0, i32 1024)
%57 = call i32 @recv(i32 %17, i8* %13, i32 1023, i32 0)
%58 = icmp sgt i32 %57, 0
br i1 %58, label %59, label %87
59: ; preds = %55, %82
%60 = phi i32 [ %85, %82 ], [ %57, %55 ]
%61 = phi i32 [ %83, %82 ], [ 0, %55 ]
%62 = phi i64 [ %84, %82 ], [ 0, %55 ]
%63 = zext i32 %60 to i64
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 %63
store i8 0, i8* %64
%65 = icmp eq i32 %61, 0
br i1 %65, label %66, label %71
66: ; preds = %59
%67 = call i8* @strstr(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%68 = icmp eq i8* %67, null
br i1 %68, label %82, label %69
69: ; preds = %66
%70 = getelementptr inbounds i8, i8* %67, i64 4
br label %71
71: ; preds = %59, %69
%72 = phi i8* [ %70, %69 ], [ %13, %59 ]
%73 = icmp slt i64 %62, %4
br i1 %73, label %74, label %82
74: ; preds = %71
%75 = getelementptr inbounds i8, i8* %3, i64 %62
%76 = sub nsw i64 %4, %62
%77 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %75, i64 %76, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %72)
%78 = icmp sgt i32 %77, 0
%79 = select i1 %78, i32 %77, i32 0
%80 = zext i32 %79 to i64
%81 = add nsw i64 %62, %80
br label %82
82: ; preds = %66, %74, %71
%83 = phi i32 [ 1, %74 ], [ 1, %71 ], [ 0, %66 ]
%84 = phi i64 [ %81, %74 ], [ %62, %71 ], [ %62, %66 ]
%85 = call i32 @recv(i32 %17, i8* %13, i32 1023, i32 0)
%86 = icmp sgt i32 %85, 0
br i1 %86, label %59, label %87
87: ; preds = %82, %55
%88 = call i32 @close(i32 %17)
br label %89
89: ; preds = %46, %87, %34, %27, %19, %5
%90 = phi i8* [ null, %5 ], [ null, %19 ], [ null, %27 ], [ null, %34 ], [ %3, %87 ], [ null, %46 ]
ret i8* %90
}