#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 */

/* Variables and functions */
int /*<<< orphan*/ Gethostname(char *, int);
int /*<<< orphan*/ Rio_writen(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ strlen(char *);
void clientSend(int fd, char *filename) {
  char buf[8192];
  char hostname[8192];
  Gethostname(hostname, 8192);
  sprintf(buf, "GET %s HTTP/1.1\n", filename);
  sprintf(buf, "%shost: %s\n\r\n", buf, hostname);
  Rio_writen(fd, buf, strlen(buf));
}


x86 assembly (clang, -O0):
<clientSend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4020,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x4010(%rbp),%rdi
mov    $0x2000,%esi
call   1040 <Gethostname@plt>
lea    -0x2010(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x2010(%rbp),%rdi
lea    -0x2010(%rbp),%rdx
lea    -0x4010(%rbp),%rcx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x401c(%rbp)
lea    -0x2010(%rbp),%rax
mov    %rax,-0x4018(%rbp)
lea    -0x2010(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x401c(%rbp),%edi
mov    -0x4018(%rbp),%rsi
mov    %eax,%edx
call   1050 <Rio_writen@plt>
add    $0x4020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clientSend>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x4008,%rsp
mov    %rsi,%rbx
mov    %edi,%r15d
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x2000,%esi
call   1040 <Gethostname@plt>
lea    0xe96(%rip),%rsi
lea    0x2000(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    0xe8b(%rip),%rsi
mov    %rbp,%rdi
mov    %rbp,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <Rio_writen@plt>
add    $0x4008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"GET %s HTTP/1.1\0A\00"
@.str.1 = [14 x i8] c"%shost: %s\0A\0D\0A\00"
define void @clientSend(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [8192 x i8]
%6 = alloca [8192 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%8 = call i32 @Gethostname(i8* %7, i32 8192)
%9 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%15 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* %14)
%16 = load i32, i32* %3
%17 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%18 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = call i32 @Rio_writen(i32 %16, i8* %17, i32 %19)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"GET %s HTTP/1.1\0A\00"
@.str.1 = [14 x i8] c"%shost: %s\0A\0D\0A\00"
define void @clientSend(i32 %0, i8* %1) {
%3 = alloca [8192 x i8]
%4 = alloca [8192 x i8]
%5 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [8192 x i8], [8192 x i8]* %4, i64 0, i64 0
%7 = call i32 @Gethostname(i8* %6, i32 8192)
%8 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %1)
%9 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %6)
%10 = call i32 @strlen(i8* %5)
%11 = call i32 @Rio_writen(i32 %0, i8* %5, i32 %10)
ret void
}