#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 *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, ...);
char *strlen(char *);
void requestError(int fd, char *cause, char *errnum, char *shortmsg,
                  char *longmsg) {
  char buf[8192], body[8192];
  printf("Request ERROR\n");
  sprintf(body, "<html><title>CS537 Error</title>");
  sprintf(body,
          "%s<body bgcolor="
          "fffff"
          ">\r\n",
          body);
  sprintf(body, "%s%s: %s\r\n", body, errnum, shortmsg);
  sprintf(body, "%s<p>%s: %s\r\n", body, longmsg, cause);
  sprintf(body, "%s<hr>CS537 Web Server\r\n", body);
  sprintf(buf, "HTTP/1.0 %s %s\r\n", errnum, shortmsg);
  Rio_writen(fd, buf, strlen(buf));
  printf("%s", buf);
  sprintf(buf, "Content-Type: text/html\r\n");
  Rio_writen(fd, buf, strlen(buf));
  printf("%s", buf);
  sprintf(buf, "Content-Length: %lu\r\n\r\n", strlen(body));
  Rio_writen(fd, buf, strlen(buf));
  printf("%s", buf);
  Rio_writen(fd, body, strlen(body));
  printf("%s", body);
}


x86 assembly (clang, -O0):
<requestError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4080,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x4030(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x4030(%rbp),%rdi
lea    -0x4030(%rbp),%rdx
lea    0xe9a(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x4030(%rbp),%rdi
lea    -0x4030(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x4030(%rbp),%rdi
lea    -0x4030(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x4030(%rbp),%rdi
lea    -0x4030(%rbp),%rdx
lea    0xe68(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x2030(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x4074(%rbp)
lea    -0x2030(%rbp),%rax
mov    %rax,-0x4070(%rbp)
lea    -0x2030(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x4074(%rbp),%edi
mov    -0x4070(%rbp),%rsi
mov    %rax,%rdx
call   1050 <Rio_writen@plt>
lea    -0x2030(%rbp),%rsi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x2030(%rbp),%rdi
lea    0xe16(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x4064(%rbp)
lea    -0x2030(%rbp),%rax
mov    %rax,-0x4060(%rbp)
lea    -0x2030(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x4064(%rbp),%edi
mov    -0x4060(%rbp),%rsi
mov    %rax,%rdx
call   1050 <Rio_writen@plt>
lea    -0x2030(%rbp),%rsi
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x2030(%rbp),%rax
mov    %rax,-0x4058(%rbp)
lea    -0x4030(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x4058(%rbp),%rdi
mov    %rax,%rdx
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   1060 <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   1050 <Rio_writen@plt>
lea    -0x2030(%rbp),%rsi
lea    0xd47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@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   1050 <Rio_writen@plt>
lea    -0x4030(%rbp),%rsi
lea    0xcfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x4080,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<requestError>:
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
lea    0xf3b(%rip),%rdi
call   1030 <puts@plt>
movups 0xe7d(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xe82(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movb   $0x0,0x20(%rsp)
lea    0xe82(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0xe75(%rip),%rsi
mov    %rbx,%rdi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %rbp,%r8
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0xe69(%rip),%rsi
mov    %rbx,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0xe6e(%rip),%rsi
lea    0x2000(%rsp),%rbp
mov    %rbp,%rdi
mov    %r12,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1060 <Rio_writen@plt>
lea    0xe4a(%rip),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
movups 0xe39(%rip),%xmm0
movaps %xmm0,0x2000(%rsp)
movups 0xe34(%rip),%xmm0
movups %xmm0,0x200a(%rsp)
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1060 <Rio_writen@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xe0a(%rip),%rsi
mov    %rbp,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <sprintf@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1060 <Rio_writen@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1060 <Rio_writen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x4008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Request ERROR\0A\00"
@.str.1 = [33 x i8] c"<html><title>CS537 Error</title>\00"
@.str.2 = [25 x i8] c"%s<body bgcolor=fffff>\0D\0A\00"
@.str.3 = [11 x i8] c"%s%s: %s\0D\0A\00"
@.str.4 = [14 x i8] c"%s<p>%s: %s\0D\0A\00"
@.str.5 = [25 x i8] c"%s<hr>CS537 Web Server\0D\0A\00"
@.str.6 = [17 x i8] c"HTTP/1.0 %s %s\0D\0A\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [26 x i8] c"Content-Type: text/html\0D\0A\00"
@.str.9 = [24 x i8] c"Content-Length: %lu\0D\0A\0D\0A\00"
define void @requestError(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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%15 = call i32 (i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%17 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%18 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%20 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%21 = load i8*, i8** %8
%22 = load i8*, i8** %9
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %20, i8* %21, i8* %22)
%24 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%25 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%26 = load i8*, i8** %10
%27 = load i8*, i8** %7
%28 = call i32 (i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %25, i8* %26, i8* %27)
%29 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%30 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* %29, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%33 = load i8*, i8** %8
%34 = load i8*, i8** %9
%35 = call i32 (i8*, i8*, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %33, i8* %34)
%36 = load i32, i32* %6
%37 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%38 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%39 = call i8* @strlen(i8* %38)
%40 = call i32 @Rio_writen(i32 %36, i8* %37, i8* %39)
%41 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %41)
%43 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%44 = call i32 (i8*, i8*, ...) @sprintf(i8* %43, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%45 = load i32, i32* %6
%46 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%47 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%48 = call i8* @strlen(i8* %47)
%49 = call i32 @Rio_writen(i32 %45, i8* %46, i8* %48)
%50 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %50)
%52 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%53 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%54 = call i8* @strlen(i8* %53)
%55 = call i32 (i8*, i8*, ...) @sprintf(i8* %52, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %54)
%56 = load i32, i32* %6
%57 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%58 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%59 = call i8* @strlen(i8* %58)
%60 = call i32 @Rio_writen(i32 %56, i8* %57, i8* %59)
%61 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %61)
%63 = load i32, i32* %6
%64 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%65 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%66 = call i8* @strlen(i8* %65)
%67 = call i32 @Rio_writen(i32 %63, i8* %64, i8* %66)
%68 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %68)
ret void
}

LLVM IR (-O2):
@.str.1 = [33 x i8] c"<html><title>CS537 Error</title>\00"
@.str.2 = [25 x i8] c"%s<body bgcolor=fffff>\0D\0A\00"
@.str.3 = [11 x i8] c"%s%s: %s\0D\0A\00"
@.str.4 = [14 x i8] c"%s<p>%s: %s\0D\0A\00"
@.str.5 = [25 x i8] c"%s<hr>CS537 Web Server\0D\0A\00"
@.str.6 = [17 x i8] c"HTTP/1.0 %s %s\0D\0A\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [26 x i8] c"Content-Type: text/html\0D\0A\00"
@.str.9 = [24 x i8] c"Content-Length: %lu\0D\0A\0D\0A\00"
@str = [14 x i8] c"Request ERROR\00"
define void @requestError(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 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %9, i8* %2, i8* %3)
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %9, i8* %4, i8* %1)
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %9)
%15 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %2, i8* %3)
%16 = call i8* @strlen(i8* %8)
%17 = call i32 @Rio_writen(i32 %0, i8* %8, i8* %16)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %8)
%19 = call i8* @strlen(i8* %8)
%20 = call i32 @Rio_writen(i32 %0, i8* %8, i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %8)
%22 = call i8* @strlen(i8* %9)
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %22)
%24 = call i8* @strlen(i8* %8)
%25 = call i32 @Rio_writen(i32 %0, i8* %8, i8* %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %8)
%27 = call i8* @strlen(i8* %9)
%28 = call i32 @Rio_writen(i32 %0, i8* %9, i8* %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %9)
ret void
}