#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 *dupfmt(char *, char *, char *, char *, char *, char *, char *, char *,
             char *);
char *http_error(char *code, char *errmsg, char *extraheader, char *errtext,
                 ...) {
  return dupfmt("HTTP/1.1 %s %s\r\n"
                "Date: %D\r\n"
                "Server: "
                "agedu"
                "\r\n"
                "Connection: close\r\n"
                "%s"
                "Content-Type: text/html; charset=US-ASCII\r\n"
                "\r\n"
                "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n"
                "<HTML><HEAD>\r\n"
                "<TITLE>%s %s</TITLE>\r\n"
                "</HEAD><BODY>\r\n"
                "<H1>%s %s</H1>\r\n"
                "<P>%s</P>\r\n"
                "</BODY></HTML>\r\n",
                code, errmsg, extraheader ? extraheader : "", code, errmsg,
                code, errmsg, errtext);
}


x86 assembly (clang, -O0):
<http_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1150 <http_error+0x40>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1160 <http_error+0x50>
lea    0xfa6(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    1160 <http_error+0x50>
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rcx
mov    -0x8(%rbp),%r8
mov    -0x10(%rbp),%r9
mov    -0x20(%rbp),%rdi
mov    %rsp,%rax
mov    %rdi,0x10(%rax)
mov    %r9,0x8(%rax)
mov    %r8,(%rax)
lea    0xe73(%rip),%rdi
call   1030 <dupfmt@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_error>:
push   %rax
mov    %rcx,%rax
mov    %rsi,%r9
mov    %rdi,%rsi
test   %rdx,%rdx
lea    0xfd9(%rip),%rcx
cmovne %rdx,%rcx
sub    $0x8,%rsp
lea    0xecd(%rip),%rdi
mov    %r9,%rdx
mov    %rsi,%r8
push   %rax
push   %r9
push   %rsi
call   1030 <dupfmt@plt>
add    $0x20,%rsp
pop    %rcx
ret

LLVM IR (-O0):
@.str = [254 x i8] c"HTTP/1.1 %s %s\0D\0ADate: %D\0D\0AServer: agedu\0D\0AConnection: close\0D\0A%sContent-Type: text/html; charset=US-ASCII\0D\0A\0D\0A<!DOCTYPE HTML PUBLIC \22-//IETF//DTD HTML 2.0//EN\22>\0D\0A<HTML><HEAD>\0D\0A<TITLE>%s %s</TITLE>\0D\0A</HEAD><BODY>\0D\0A<H1>%s %s</H1>\0D\0A<P>%s</P>\0D\0A</BODY></HTML>\0D\0A\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @http_error(i8* %0, i8* %1, i8* %2, i8* %3, ...) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%9 = load i8*, i8** %5
%10 = load i8*, i8** %6
%11 = load i8*, i8** %7
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = load i8*, i8** %7
br label %16
15: ; preds = %4
br label %16
16: ; preds = %15, %13
%17 = phi i8* [ %14, %13 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %15 ]
%18 = load i8*, i8** %5
%19 = load i8*, i8** %6
%20 = load i8*, i8** %5
%21 = load i8*, i8** %6
%22 = load i8*, i8** %8
%23 = call i8* @dupfmt(i8* getelementptr inbounds ([254 x i8], [254 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10, i8* %17, i8* %18, i8* %19, i8* %20, i8* %21, i8* %22)
ret i8* %23
}

LLVM IR (-O2):
@.str = [254 x i8] c"HTTP/1.1 %s %s\0D\0ADate: %D\0D\0AServer: agedu\0D\0AConnection: close\0D\0A%sContent-Type: text/html; charset=US-ASCII\0D\0A\0D\0A<!DOCTYPE HTML PUBLIC \22-//IETF//DTD HTML 2.0//EN\22>\0D\0A<HTML><HEAD>\0D\0A<TITLE>%s %s</TITLE>\0D\0A</HEAD><BODY>\0D\0A<H1>%s %s</H1>\0D\0A<P>%s</P>\0D\0A</BODY></HTML>\0D\0A\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @http_error(i8* %0, i8* %1, i8* %2, i8* %3, ...) {
%5 = icmp eq i8* %2, null
%6 = select i1 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %2
%7 = tail call i8* @dupfmt(i8* getelementptr inbounds ([254 x i8], [254 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i8* %6, i8* %0, i8* %1, i8* %0, i8* %1, i8* %3)
ret i8* %7
}