#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 scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ fwrite(char *, int, scalar_t__, int /*<<< orphan*/);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
void get_home_page(int socket_fd) {
  char buffer[10000];
  ssize_t number_characters_read;
  sprintf(buffer, "GET /\n\n");
  write(socket_fd, buffer, strlen(buffer));
  while (1) {
    number_characters_read = read(socket_fd, buffer, 10000);
    if (number_characters_read == 0)
      return;
    fwrite(buffer, sizeof(char), number_characters_read, stdout);
  }
}


x86 assembly (clang, -O0):
<get_home_page>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2740,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x2720(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x2734(%rbp)
lea    -0x2720(%rbp),%rax
mov    %rax,-0x2730(%rbp)
lea    -0x2720(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2734(%rbp),%edi
mov    -0x2730(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
lea    -0x2720(%rbp),%rsi
mov    $0x2710,%edx
call   1050 <read@plt>
mov    %rax,-0x2728(%rbp)
cmpq   $0x0,-0x2728(%rbp)
jne    11da <get_home_page+0x8a>
add    $0x2740,%rsp
pop    %rbp
ret
lea    -0x2720(%rbp),%rdi
mov    -0x2728(%rbp),%rdx
mov    0x2df1(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1070 <fwrite@plt>
jmp    11a8 <get_home_page+0x58>

x86 assembly (clang, -O2):
<get_home_page>:
push   %rbp
push   %r14
push   %rbx
sub    $0x2710,%rsp
mov    %edi,%ebp
movabs $0xa0a2f20544547,%rax
mov    %rax,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x2710,%edx
call   1050 <read@plt>
test   %rax,%rax
je     11b7 <get_home_page+0x77>
mov    0x2e53(%rip),%r14
mov    %rsp,%rbx
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
call   1060 <fwrite@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x2710,%edx
call   1050 <read@plt>
test   %rax,%rax
jne    1190 <get_home_page+0x50>
add    $0x2710,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"GET /\0A\0A\00"
@stdout = global i32 0
define void @get_home_page(i32 %0) {
%2 = alloca i32
%3 = alloca [10000 x i8]
%4 = alloca i64
store i32 %0, i32* %2
%5 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = call i32 @write(i32 %7, i8* %8, i32 %10)
br label %12
12: ; preds = %1, %19
%13 = load i32, i32* %2
%14 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%15 = call i64 @read(i32 %13, i8* %14, i32 10000)
store i64 %15, i64* %4
%16 = load i64, i64* %4
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %12
ret void
19: ; preds = %12
%20 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%21 = load i64, i64* %4
%22 = load i32, i32* @stdout
%23 = call i32 @fwrite(i8* %20, i32 1, i64 %21, i32 %22)
br label %12
}

LLVM IR (-O2):
@stdout = global i32 0
define void @get_home_page(i32 %0) {
%2 = alloca [10000 x i8]
%3 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 0
%4 = bitcast [10000 x i8]* %2 to i64*
store i64 2825947289240903, i64* %4
%5 = call i32 @strlen(i8* %3)
%6 = call i32 @write(i32 %0, i8* %3, i32 %5)
%7 = call i64 @read(i32 %0, i8* %3, i32 10000)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %10, %1
ret void
10: ; preds = %1, %10
%11 = phi i64 [ %14, %10 ], [ %7, %1 ]
%12 = load i32, i32* @stdout
%13 = call i32 @fwrite(i8* %3, i32 1, i64 %11, i32 %12)
%14 = call i64 @read(i32 %0, i8* %3, i32 10000)
%15 = icmp eq i64 %14, 0
br i1 %15, label %9, label %10
}