#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 sprintf(char *, char const *, char *);
int strlen(char const *);
char *error_resp(char *path, int *len) {
  const char eresponse[] =
      "<html><head><title>X-P</title></head><body><font "
      "face=\"sans-serif\"><center><h1>X-P</h1><p>Could not find content at "
      "<b>%s</b>.</p></font></center></body>";
  char *resp;
  int sz = strlen(eresponse) + strlen(path);
  resp = malloc(sz);
  if (!resp)
    return NULL;
  *len = sprintf(resp, eresponse, path);
  return resp;
}


x86 assembly (clang, -O0):
<error_resp>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0xc0(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x9a,%edx
call   1040 <memcpy@plt>
lea    -0xc0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xd0(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xd0(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xcc(%rbp)
mov    -0xcc(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0xc8(%rbp)
cmpq   $0x0,-0xc8(%rbp)
jne    11c3 <error_resp+0x83>
movq   $0x0,-0x8(%rbp)
jmp    11ed <error_resp+0xad>
mov    -0xc8(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1060 <sprintf@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xc8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<error_resp>:
push   %r15
push   %r14
push   %rbx
sub    $0xa0,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xea7(%rip),%rsi
mov    %rsp,%rbx
mov    $0x9a,%edx
mov    %rbx,%rdi
call   1040 <memcpy@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1030 <strlen@plt>
add    %eax,%ebx
mov    %ebx,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     119d <error_resp+0x5d>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1060 <sprintf@plt>
mov    %eax,(%r14)
mov    %rbx,%rax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.error_resp.eresponse = [154 x i8] c"<html><head><title>X-P</title></head><body><font face=\22sans-serif\22><center><h1>X-P</h1><p>Could not find content at <b>%s</b>.</p></font></center></body>\00"
define i8* @error_resp(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [154 x i8]
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
%9 = bitcast [154 x i8]* %6 to i8*
%10 = getelementptr inbounds [154 x i8], [154 x i8]* %6, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
%14 = add nsw i32 %11, %13
store i32 %14, i32* %8
%15 = load i32, i32* %8
%16 = call i8* @malloc(i32 %15)
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = icmp ne i8* %17, null
br i1 %18, label %20, label %19
19: ; preds = %2
store i8* null, i8** %3
br label %27
20: ; preds = %2
%21 = load i8*, i8** %7
%22 = getelementptr inbounds [154 x i8], [154 x i8]* %6, i64 0, i64 0
%23 = load i8*, i8** %4
%24 = call i32 @sprintf(i8* %21, i8* %22, i8* %23)
%25 = load i32*, i32** %5
store i32 %24, i32* %25
%26 = load i8*, i8** %7
store i8* %26, i8** %3
br label %27
27: ; preds = %20, %19
%28 = load i8*, i8** %3
ret i8* %28
}

LLVM IR (-O2):
@__const.error_resp.eresponse = [154 x i8] c"<html><head><title>X-P</title></head><body><font face=\22sans-serif\22><center><h1>X-P</h1><p>Could not find content at <b>%s</b>.</p></font></center></body>\00"
define noalias i8* @error_resp(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca [154 x i8]
%4 = getelementptr inbounds [154 x i8], [154 x i8]* %3, i64 0, i64 0
%5 = call i32 @strlen(i8* %4)
%6 = call i32 @strlen(i8* %0)
%7 = add nsw i32 %6, %5
%8 = call i8* @malloc(i32 %7)
%9 = icmp eq i8* %8, null
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = call i32 @sprintf(i8* %8, i8* %4, i8* %0)
store i32 %11, i32* %1
br label %12
12: ; preds = %2, %10
ret i8* %8
}