#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 */
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ body;

/* Variables and functions */
int /*<<< orphan*/ Rio_writen(int, char *, scalar_t__);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
scalar_t__ strlen(char *);
void clienterror(int fd, char *cause, char *errnum, char *shortmsg,
                 char *longmsg) {
  char buf[8192], body[8192];
  snprintf(body, sizeof(body), "<html><title>Tiny Error</title>");
  snprintf(body, sizeof(body),
           "%s<body bgcolor="
           "ffffff"
           ">\r\n",
           body);
  snprintf(body, sizeof(body), "%s%s: %s\r\n", body, errnum, shortmsg);
  snprintf(body, sizeof(body), "%s<p>%s: %s\r\n", body, longmsg, cause);
  snprintf(body, sizeof(body), "%s<hr><em>The Tiny Web server</em>\r\n", body);
  snprintf(buf, sizeof(buf), "HTTP/1.0 %s %s\r\n", errnum, shortmsg);
  Rio_writen(fd, buf, strlen(buf));
  snprintf(buf, sizeof(buf), "Content-type: text/html\r\n");
  Rio_writen(fd, buf, strlen(buf));
  snprintf(buf, sizeof(buf), "Content-length: %d\r\n\r\n", (int)strlen(body));
  Rio_writen(fd, buf, strlen(buf));
  Rio_writen(fd, body, strlen(body));
}


x86 assembly (clang, -O0):
<clienterror>:
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    -0x4030(%rbp),%rdi
mov    $0x2000,%esi
lea    0xe9f(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x4030(%rbp),%rdi
lea    -0x4030(%rbp),%rcx
mov    $0x2000,%esi
lea    0xe9e(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x4030(%rbp),%rdi
lea    -0x4030(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r9
mov    $0x2000,%esi
lea    0xe8f(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x4030(%rbp),%rdi
lea    -0x4030(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x10(%rbp),%r9
mov    $0x2000,%esi
lea    0xe71(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x4030(%rbp),%rdi
lea    -0x4030(%rbp),%rcx
mov    $0x2000,%esi
lea    0xe5e(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x2030(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    $0x2000,%esi
lea    0xe61(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@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),%rdi
mov    $0x2000,%esi
lea    0xe20(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@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),%rax
mov    %rax,-0x4058(%rbp)
lea    -0x4030(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x4058(%rbp),%rdi
mov    %eax,%ecx
mov    $0x2000,%esi
lea    0xdcc(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@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>
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>
add    $0x4080,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clienterror>:
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    0xea9(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x2000,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0xeb0(%rip),%rdx
mov    %rbx,%rdi
mov    $0x2000,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0xeb1(%rip),%rdx
mov    %rbx,%rdi
mov    $0x2000,%esi
mov    %rbx,%rcx
mov    %r12,%r8
mov    %r15,%r9
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0xe9d(%rip),%rdx
mov    %rbx,%rdi
mov    $0x2000,%esi
mov    %rbx,%rcx
mov    %r13,%r8
mov    %rbp,%r9
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0xe8c(%rip),%rdx
mov    %rbx,%rdi
mov    $0x2000,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0xe98(%rip),%rdx
lea    0x2000(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x2000,%esi
mov    %r12,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1050 <Rio_writen@plt>
lea    0xe6f(%rip),%rdx
mov    %rbp,%rdi
mov    $0x2000,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1050 <Rio_writen@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xe55(%rip),%rdx
mov    %rbp,%rdi
mov    $0x2000,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1050 <Rio_writen@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1050 <Rio_writen@plt>
add    $0x4008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"<html><title>Tiny Error</title>\00"
@.str.1 = [26 x i8] c"%s<body bgcolor=ffffff>\0D\0A\00"
@.str.2 = [11 x i8] c"%s%s: %s\0D\0A\00"
@.str.3 = [14 x i8] c"%s<p>%s: %s\0D\0A\00"
@.str.4 = [37 x i8] c"%s<hr><em>The Tiny Web server</em>\0D\0A\00"
@.str.5 = [17 x i8] c"HTTP/1.0 %s %s\0D\0A\00"
@.str.6 = [26 x i8] c"Content-type: text/html\0D\0A\00"
@.str.7 = [23 x i8] c"Content-length: %d\0D\0A\0D\0A\00"
define void @clienterror(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*, i32, i8*, ...) @snprintf(i8* %13, i32 8192, i8* getelementptr inbounds ([32 x i8], [32 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*, i32, i8*, ...) @snprintf(i8* %15, i32 8192, i8* getelementptr inbounds ([26 x i8], [26 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*, i32, i8*, ...) @snprintf(i8* %18, i32 8192, i8* getelementptr inbounds ([11 x i8], [11 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*, i32, i8*, ...) @snprintf(i8* %23, i32 8192, i8* getelementptr inbounds ([14 x i8], [14 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*, i32, i8*, ...) @snprintf(i8* %28, i32 8192, i8* getelementptr inbounds ([37 x i8], [37 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*, i32, i8*, ...) @snprintf(i8* %31, i32 8192, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %32, i8* %33)
%35 = load i32, i32* %6
%36 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%37 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%38 = call i64 @strlen(i8* %37)
%39 = call i32 @Rio_writen(i32 %35, i8* %36, i64 %38)
%40 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%41 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %40, i32 8192, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%42 = load i32, i32* %6
%43 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%44 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%45 = call i64 @strlen(i8* %44)
%46 = call i32 @Rio_writen(i32 %42, i8* %43, i64 %45)
%47 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%48 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%49 = call i64 @strlen(i8* %48)
%50 = trunc i64 %49 to i32
%51 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %47, i32 8192, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %6
%53 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%54 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%55 = call i64 @strlen(i8* %54)
%56 = call i32 @Rio_writen(i32 %52, i8* %53, i64 %55)
%57 = load i32, i32* %6
%58 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%59 = getelementptr inbounds [8192 x i8], [8192 x i8]* %12, i64 0, i64 0
%60 = call i64 @strlen(i8* %59)
%61 = call i32 @Rio_writen(i32 %57, i8* %58, i64 %60)
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"<html><title>Tiny Error</title>\00"
@.str.1 = [26 x i8] c"%s<body bgcolor=ffffff>\0D\0A\00"
@.str.2 = [11 x i8] c"%s%s: %s\0D\0A\00"
@.str.3 = [14 x i8] c"%s<p>%s: %s\0D\0A\00"
@.str.4 = [37 x i8] c"%s<hr><em>The Tiny Web server</em>\0D\0A\00"
@.str.5 = [17 x i8] c"HTTP/1.0 %s %s\0D\0A\00"
@.str.6 = [26 x i8] c"Content-type: text/html\0D\0A\00"
@.str.7 = [23 x i8] c"Content-length: %d\0D\0A\0D\0A\00"
define void @clienterror(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*, i32, i8*, ...) @snprintf(i8* %9, i32 8192, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 8192, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%12 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 8192, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* %2, i8* %3)
%13 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 8192, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %9, i8* %4, i8* %1)
%14 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 8192, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%15 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %8, i32 8192, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %2, i8* %3)
%16 = call i64 @strlen(i8* %8)
%17 = call i32 @Rio_writen(i32 %0, i8* %8, i64 %16)
%18 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %8, i32 8192, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%19 = call i64 @strlen(i8* %8)
%20 = call i32 @Rio_writen(i32 %0, i8* %8, i64 %19)
%21 = call i64 @strlen(i8* %9)
%22 = trunc i64 %21 to i32
%23 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %8, i32 8192, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %22)
%24 = call i64 @strlen(i8* %8)
%25 = call i32 @Rio_writen(i32 %0, i8* %8, i64 %24)
%26 = call i64 @strlen(i8* %9)
%27 = call i32 @Rio_writen(i32 %0, i8* %9, i64 %26)
ret void
}