#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 */
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_NOCLOSE;
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new_fp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ BIO_puts(int /*<<< orphan*/ *, char *);
int BIO_read(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ BIO_write(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ stdout;
void send_http_get_and_print(BIO *sbio) {
  int len;
  char tmpbuf[1024];
  BIO *out = BIO_new_fp(stdout, BIO_NOCLOSE);
  BIO_puts(sbio, "GET / HTTP/1.0\n\n");
  for (;;) {
    len = BIO_read(sbio, tmpbuf, 1024);
    if (len <= 0)
      break;
    BIO_write(out, tmpbuf, len);
  }
  BIO_free(out);
}


x86 assembly (clang, -O0):
<send_http_get_and_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
call   1030 <BIO_new_fp@plt>
mov    %rax,-0x418(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1060 <BIO_puts@plt>
mov    -0x8(%rbp),%rdi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1040 <BIO_read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     11b4 <send_http_get_and_print+0x64>
jmp    11cf <send_http_get_and_print+0x7f>
mov    -0x418(%rbp),%rdi
lea    -0x410(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1070 <BIO_write@plt>
jmp    118d <send_http_get_and_print+0x3d>
mov    -0x418(%rbp),%rdi
call   1050 <BIO_free@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_http_get_and_print>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%r14
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
call   1030 <BIO_new_fp@plt>
mov    %rax,%r15
lea    0xe80(%rip),%rsi
mov    %r14,%rdi
call   1060 <BIO_puts@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
mov    $0x400,%edx
call   1040 <BIO_read@plt>
test   %eax,%eax
jle    11c1 <send_http_get_and_print+0x71>
mov    %rsp,%rbx
nop
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1070 <BIO_write@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1040 <BIO_read@plt>
test   %eax,%eax
jg     11a0 <send_http_get_and_print+0x50>
mov    %r15,%rdi
call   1050 <BIO_free@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdout = global i32 0
@BIO_NOCLOSE = global i32 0
@.str = [17 x i8] c"GET / HTTP/1.0\0A\0A\00"
define void @send_http_get_and_print(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [1024 x i8]
%5 = alloca i32*
store i32* %0, i32** %2
%6 = load i32, i32* @stdout
%7 = load i32, i32* @BIO_NOCLOSE
%8 = call i32* @BIO_new_fp(i32 %6, i32 %7)
store i32* %8, i32** %5
%9 = load i32*, i32** %2
%10 = call i32 @BIO_puts(i32* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %18, %1
%12 = load i32*, i32** %2
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%14 = call i32 @BIO_read(i32* %12, i8* %13, i32 1024)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp sle i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %11
br label %23
18: ; preds = %11
%19 = load i32*, i32** %5
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%21 = load i32, i32* %3
%22 = call i32 @BIO_write(i32* %19, i8* %20, i32 %21)
br label %11
23: ; preds = %17
%24 = load i32*, i32** %5
%25 = call i32 @BIO_free(i32* %24)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@BIO_NOCLOSE = global i32 0
@.str = [17 x i8] c"GET / HTTP/1.0\0A\0A\00"
define void @send_http_get_and_print(i32* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @stdout
%5 = load i32, i32* @BIO_NOCLOSE
%6 = tail call i32* @BIO_new_fp(i32 %4, i32 %5)
%7 = tail call i32 @BIO_puts(i32* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @BIO_read(i32* %0, i8* %3, i32 1024)
%9 = icmp slt i32 %8, 1
br i1 %9, label %15, label %10
10: ; preds = %1, %10
%11 = phi i32 [ %13, %10 ], [ %8, %1 ]
%12 = call i32 @BIO_write(i32* %6, i8* %3, i32 %11)
%13 = call i32 @BIO_read(i32* %0, i8* %3, i32 1024)
%14 = icmp slt i32 %13, 1
br i1 %14, label %15, label %10
15: ; preds = %10, %1
%16 = call i32 @BIO_free(i32* %6)
ret void
}