#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 */
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
char *generate_header(char *url, char *host) {
  char *header = "GET %s "
                 "HTTP/1.1\r\n"
                 "Host: %s\r\n"
                 "Cache-Control: no-cache\r\n"
                 "Accept: text/html,application/xhtml+xml,"
                 "application/xml;q=0.9,image/webp,*/*;q=0.8\r\n"
                 "Pragma: no-cache\r\n"
                 "Accept-Encoding: gzip,deflate,sdch\r\n"
                 "Accept-Language: en-US,en;q=0.8,ru;q=0.6,el;q=0.4\r\n\r\n";
  char *filled_header = malloc(2048);
  memset(filled_header, 0, 2048);
  snprintf(filled_header, 2048, header, url, host);
  return filled_header;
}


x86 assembly (clang, -O0):
<generate_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x800,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1040 <memset@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    $0x800,%esi
call   1030 <snprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_header>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x800,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1040 <memset@plt>
lea    0xea2(%rip),%rdx
mov    %rbx,%rdi
mov    $0x800,%esi
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [244 x i8] c"GET %s HTTP/1.1\0D\0AHost: %s\0D\0ACache-Control: no-cache\0D\0AAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\0D\0APragma: no-cache\0D\0AAccept-Encoding: gzip,deflate,sdch\0D\0AAccept-Language: en-US,en;q=0.8,ru;q=0.6,el;q=0.4\0D\0A\0D\0A\00"
define i8* @generate_header(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8* getelementptr inbounds ([244 x i8], [244 x i8]* @.str, i64 0, i64 0), i8** %5
%7 = call i8* @malloc(i32 2048)
store i8* %7, i8** %6
%8 = load i8*, i8** %6
%9 = call i32 @memset(i8* %8, i32 0, i32 2048)
%10 = load i8*, i8** %6
%11 = load i8*, i8** %5
%12 = load i8*, i8** %3
%13 = load i8*, i8** %4
%14 = call i32 @snprintf(i8* %10, i32 2048, i8* %11, i8* %12, i8* %13)
%15 = load i8*, i8** %6
ret i8* %15
}

LLVM IR (-O2):
@.str = [244 x i8] c"GET %s HTTP/1.1\0D\0AHost: %s\0D\0ACache-Control: no-cache\0D\0AAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\0D\0APragma: no-cache\0D\0AAccept-Encoding: gzip,deflate,sdch\0D\0AAccept-Language: en-US,en;q=0.8,ru;q=0.6,el;q=0.4\0D\0A\0D\0A\00"
define i8* @generate_header(i8* %0, i8* %1) {
%3 = tail call dereferenceable_or_null(2048) i8* @malloc(i32 2048)
%4 = tail call i32 @memset(i8* %3, i32 0, i32 2048)
%5 = tail call i32 @snprintf(i8* %3, i32 2048, i8* getelementptr inbounds ([244 x i8], [244 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
ret i8* %3
}