#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 */
struct Request {
  int dummy;
};

/* Variables and functions */
struct Request *parseRequest(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
struct Request *buildRequest(char *path, char *headers) {
  char txt[512];
  if (headers != NULL) {
    sprintf(txt,
            "GET %s HTTP/1.1"
            "\r\n"
            "%s"
            "\r\n"
            "\r\n",
            path, headers);
  } else {
    sprintf(txt,
            "GET %s HTTP/1.1"
            "\r\n"
            "\r\n",
            path);
  }
  return parseRequest(txt);
}


x86 assembly (clang, -O0):
<buildRequest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1160 <buildRequest+0x40>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xeac(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1179 <buildRequest+0x59>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xea6(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1030 <parseRequest@plt>
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buildRequest>:
sub    $0x208,%rsp
mov    %rdi,%rdx
test   %rsi,%rsi
je     1145 <buildRequest+0x25>
mov    %rsi,%rcx
lea    0xec7(%rip),%rsi
mov    %rsp,%rdi
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    1156 <buildRequest+0x36>
lea    0xecc(%rip),%rsi
mov    %rsp,%rdi
xor    %eax,%eax
call   1040 <sprintf@plt>
mov    %rsp,%rdi
call   1030 <parseRequest@plt>
add    $0x208,%rsp
ret

LLVM IR (-O0):
%struct.Request = type { i32 }
@.str = [24 x i8] c"GET %s HTTP/1.1\0D\0A%s\0D\0A\0D\0A\00"
@.str.1 = [20 x i8] c"GET %s HTTP/1.1\0D\0A\0D\0A\00"
define %struct.Request* @buildRequest(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [512 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%10 = load i8*, i8** %3
%11 = load i8*, i8** %4
%12 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
br label %17
13: ; preds = %2
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%15 = load i8*, i8** %3
%16 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %13, %8
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%19 = call %struct.Request* @parseRequest(i8* %18)
ret %struct.Request* %19
}

LLVM IR (-O2):
%struct.Request = type { i32 }
@.str = [24 x i8] c"GET %s HTTP/1.1\0D\0A%s\0D\0A\0D\0A\00"
@.str.1 = [20 x i8] c"GET %s HTTP/1.1\0D\0A\0D\0A\00"
define %struct.Request* @buildRequest(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = icmp eq i8* %1, null
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
br label %10
8: ; preds = %2
%9 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %10
10: ; preds = %8, %6
%11 = call %struct.Request* @parseRequest(i8* %4)
ret %struct.Request* %11
}