#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*/ rio_writen(int, char *, scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, ...);
scalar_t__ strlen(char *);
void do_error(int fd, char *cause, char *errnum, char *shortmsg,
              char *longmsg) {
  char header[8192], body[8192];
  sprintf(body, "<html><title>Zaver Error</title>");
  sprintf(body,
          "%s<body bgcolor="
          "ffffff"
          ">\n",
          body);
  sprintf(body, "%s%s: %s\n", body, errnum, shortmsg);
  sprintf(body, "%s<p>%s: %s\n</p>", body, longmsg, cause);
  sprintf(body, "%s<hr><em>Zaver web server</em>\n</body></html>", body);
  sprintf(header, "HTTP/1.1 %s %s\r\n", errnum, shortmsg);
  sprintf(header, "%sServer: Zaver\r\n", header);
  sprintf(header, "%sContent-type: text/html\r\n", header);
  sprintf(header, "%sConnection: close\r\n", header);
  sprintf(header, "%sContent-length: %d\r\n\r\n", header, (int)strlen(body));
  rio_writen(fd, header, strlen(header));
  rio_writen(fd, body, strlen(body));
  return;
}


x86 assembly (clang, -O0):
<do_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4060,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0x4030(%rbp),%rdi
lea    0xea4(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x4030(%rbp),%rdi
lea    -0x4030(%rbp),%rdx
lea    0xea9(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x4030(%rbp),%rdi
lea    -0x4030(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe9e(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x4030(%rbp),%rdi
lea    -0x4030(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xe84(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x4030(%rbp),%rdi
lea    -0x4030(%rbp),%rdx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x2030(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x2030(%rbp),%rdi
lea    -0x2030(%rbp),%rdx
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x2030(%rbp),%rdi
lea    -0x2030(%rbp),%rdx
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x2030(%rbp),%rdi
lea    -0x2030(%rbp),%rdx
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x2030(%rbp),%rax
mov    %rax,-0x4060(%rbp)
lea    -0x2030(%rbp),%rax
mov    %rax,-0x4058(%rbp)
lea    -0x4030(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x4060(%rbp),%rdi
mov    -0x4058(%rbp),%rdx
mov    %eax,%ecx
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x404c(%rbp)
lea    -0x2030(%rbp),%rax
mov    %rax,-0x4048(%rbp)
lea    -0x2030(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x404c(%rbp),%edi
mov    -0x4048(%rbp),%rsi
mov    %rax,%rdx
call   1040 <rio_writen@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x403c(%rbp)
lea    -0x4030(%rbp),%rax
mov    %rax,-0x4038(%rbp)
lea    -0x4030(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x403c(%rbp),%edi
mov    -0x4038(%rbp),%rsi
mov    %rax,%rdx
call   1040 <rio_writen@plt>
add    $0x4060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_error>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4008,%rsp
mov    %r8,%r13
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbp
mov    %edi,%r14d
movups 0xeb9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movups 0xe9d(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x20(%rsp)
lea    0xeae(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1050 <sprintf@plt>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %rbp,%r8
xor    %eax,%eax
call   1050 <sprintf@plt>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
lea    0xeb2(%rip),%rsi
lea    0x2000(%rsp),%rbp
mov    %rbp,%rdi
mov    %r12,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1050 <sprintf@plt>
lea    0xea4(%rip),%rsi
mov    %rbp,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
lea    0xea2(%rip),%rsi
mov    %rbp,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
lea    0xeaa(%rip),%rsi
mov    %rbp,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xea4(%rip),%rsi
mov    %rbp,%rdi
mov    %rbp,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1040 <rio_writen@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <rio_writen@plt>
add    $0x4008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"<html><title>Zaver Error</title>\00"
@.str.1 = [25 x i8] c"%s<body bgcolor=ffffff>\0A\00"
@.str.2 = [10 x i8] c"%s%s: %s\0A\00"
@.str.3 = [17 x i8] c"%s<p>%s: %s\0A</p>\00"
@.str.4 = [47 x i8] c"%s<hr><em>Zaver web server</em>\0A</body></html>\00"
@.str.5 = [17 x i8] c"HTTP/1.1 %s %s\0D\0A\00"
@.str.6 = [18 x i8] c"%sServer: Zaver\0D\0A\00"
@.str.7 = [28 x i8] c"%sContent-type: text/html\0D\0A\00"
@.str.8 = [22 x i8] c"%sConnection: close\0D\0A\00"
@.str.9 = [25 x i8] c"%sContent-length: %d\0D\0A\0D\0A\00"
define void @do_error(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [8192 x i8]
%12 = alloca [8192 x i8]
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%13 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%16 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%19 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%20 = load i8*, i8** %8
%21 = load i8*, i8** %9
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %19, i8* %20, i8* %21)
%23 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%24 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%25 = load i8*, i8** %10
%26 = load i8*, i8** %7
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %24, i8* %25, i8* %26)
%28 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%29 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%30 = call i32 (i8*, i8*, ...) @sprintf(i8* %28, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* %29)
%31 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%32 = load i8*, i8** %8
%33 = load i8*, i8** %9
%34 = call i32 (i8*, i8*, ...) @sprintf(i8* %31, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %32, i8* %33)
%35 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%36 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%37 = call i32 (i8*, i8*, ...) @sprintf(i8* %35, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %36)
%38 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%39 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %38, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i8* %39)
%41 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%42 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%43 = call i32 (i8*, i8*, ...) @sprintf(i8* %41, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %42)
%44 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%45 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%46 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%47 = call i64 @strlen(i8* %46)
%48 = trunc i64 %47 to i32
%49 = call i32 (i8*, i8*, ...) @sprintf(i8* %44, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i8* %45, i32 %48)
%50 = load i32, i32* %6
%51 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%52 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%53 = call i64 @strlen(i8* %52)
%54 = call i32 @rio_writen(i32 %50, i8* %51, i64 %53)
%55 = load i32, i32* %6
%56 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%57 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%58 = call i64 @strlen(i8* %57)
%59 = call i32 @rio_writen(i32 %55, i8* %56, i64 %58)
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"<html><title>Zaver Error</title>\00"
@.str.1 = [25 x i8] c"%s<body bgcolor=ffffff>\0A\00"
@.str.2 = [10 x i8] c"%s%s: %s\0A\00"
@.str.3 = [17 x i8] c"%s<p>%s: %s\0A</p>\00"
@.str.4 = [47 x i8] c"%s<hr><em>Zaver web server</em>\0A</body></html>\00"
@.str.5 = [17 x i8] c"HTTP/1.1 %s %s\0D\0A\00"
@.str.6 = [18 x i8] c"%sServer: Zaver\0D\0A\00"
@.str.7 = [28 x i8] c"%sContent-type: text/html\0D\0A\00"
@.str.8 = [22 x i8] c"%sConnection: close\0D\0A\00"
@.str.9 = [25 x i8] c"%sContent-length: %d\0D\0A\0D\0A\00"
define void @do_error(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca [8192 x i8]
%7 = alloca [8192 x i8]
%8 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [8192 x i8], [8192 x i8]* %7, i64 0, i64 0
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* %2, i8* %3)
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %9, i8* %4, i8* %1)
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %2, i8* %3)
%15 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %8)
%16 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i8* %8)
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %8)
%18 = call i64 @strlen(i8* %9)
%19 = trunc i64 %18 to i32
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i8* %8, i32 %19)
%21 = call i64 @strlen(i8* %8)
%22 = call i32 @rio_writen(i32 %0, i8* %8, i64 %21)
%23 = call i64 @strlen(i8* %9)
%24 = call i32 @rio_writen(i32 %0, i8* %9, i64 %23)
ret void
}