#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 */
scalar_t__ log10(unsigned short);
char *reason(unsigned short);
int /*<<< orphan*/ respond(unsigned short, char *, char *, int);
int sprintf(char *, char *, unsigned short, char const *, unsigned short,
            char const *);
int strlen(char const *);
void error(unsigned short code) {
  const char *phrase = reason(code);
  if (phrase == NULL) {
    return;
  }
  char *template = "<html><head><title>%i %s</title></head><body><h1>%i "
                   "%s</h1></body></html>";
  char body[(strlen(template) - 2 - ((int)log10(code) + 1) - 2 +
             strlen(phrase)) *
                2 +
            1];
  int length = sprintf(body, template, code, phrase, code, phrase);
  if (length < 0) {
    body[0] = '\0';
    length = 0;
  }
  char *headers = "Content-Type: text/html\r\n";
  respond(code, headers, body, length);
}


x86 assembly (clang, -O0):
<error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%edi
call   1050 <reason@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117c <error+0x2c>
jmp    1242 <error+0xf2>
lea    0xe7d(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x48(%rbp)
movzwl -0x2(%rbp),%edi
call   1060 <log10@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x44(%rbp),%ecx
add    %eax,%ecx
mov    %ecx,%eax
lea    -0x9(%rax,%rax,1),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x40(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x2(%rbp),%dx
mov    -0x10(%rbp),%rcx
mov    -0x2(%rbp),%ax
mov    -0x10(%rbp),%r9
movzwl %dx,%edx
movzwl %ax,%r8d
call   1070 <sprintf@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1219 <error+0xc9>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x2c(%rbp)
mov    -0x40(%rbp),%rdx
lea    0xe26(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x2(%rbp),%ax
mov    -0x38(%rbp),%rsi
mov    -0x2c(%rbp),%ecx
movzwl %ax,%edi
call   1030 <respond@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<error>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
call   1050 <reason@plt>
test   %rax,%rax
je     11f3 <error+0xa3>
mov    %rax,%r12
lea    0xe88(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%r13d
movzwl %bx,%r14d
mov    %r14d,%edi
call   1060 <log10@plt>
mov    %rax,%rbx
not    %ebx
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %rsp,%r15
add    %r13d,%ebx
add    %eax,%ebx
lea    (%rbx,%rbx,1),%eax
add    $0xfffffff9,%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
lea    0xe3e(%rip),%rsi
mov    %r14d,%edx
mov    %r12,%rcx
mov    %r14d,%r8d
mov    %r12,%r9
call   1070 <sprintf@plt>
test   %eax,%eax
jns    11dc <error+0x8c>
movb   $0x0,(%rbx)
xor    %eax,%eax
lea    0xe67(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1030 <respond@plt>
mov    %r15,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [74 x i8] c"<html><head><title>%i %s</title></head><body><h1>%i %s</h1></body></html>\00"
@.str.1 = [26 x i8] c"Content-Type: text/html\0D\0A\00"
define void @error(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
store i16 %0, i16* %2
%9 = load i16, i16* %2
%10 = call i8* @reason(i16 zeroext %9)
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %1
br label %48
14: ; preds = %1
store i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0), i8** %4
%15 = load i8*, i8** %4
%16 = call i32 @strlen(i8* %15)
%17 = sub nsw i32 %16, 2
%18 = load i16, i16* %2
%19 = call i64 @log10(i16 zeroext %18)
%20 = trunc i64 %19 to i32
%21 = add nsw i32 %20, 1
%22 = sub nsw i32 %17, %21
%23 = sub nsw i32 %22, 2
%24 = load i8*, i8** %3
%25 = call i32 @strlen(i8* %24)
%26 = add nsw i32 %23, %25
%27 = mul nsw i32 %26, 2
%28 = add nsw i32 %27, 1
%29 = zext i32 %28 to i64
%30 = call i8* @llvm.stacksave()
store i8* %30, i8** %5
%31 = alloca i8, i64 %29
store i64 %29, i64* %6
%32 = load i8*, i8** %4
%33 = load i16, i16* %2
%34 = load i8*, i8** %3
%35 = load i16, i16* %2
%36 = load i8*, i8** %3
%37 = call i32 @sprintf(i8* %31, i8* %32, i16 zeroext %33, i8* %34, i16 zeroext %35, i8* %36)
store i32 %37, i32* %7
%38 = load i32, i32* %7
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %14
%41 = getelementptr inbounds i8, i8* %31, i64 0
store i8 0, i8* %41
store i32 0, i32* %7
br label %42
42: ; preds = %40, %14
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8** %8
%43 = load i16, i16* %2
%44 = load i8*, i8** %8
%45 = load i32, i32* %7
%46 = call i32 @respond(i16 zeroext %43, i8* %44, i8* %31, i32 %45)
%47 = load i8*, i8** %5
br label %48
48: ; preds = %42, %13
ret void
}

LLVM IR (-O2):
@.str = [74 x i8] c"<html><head><title>%i %s</title></head><body><h1>%i %s</h1></body></html>\00"
@.str.1 = [26 x i8] c"Content-Type: text/html\0D\0A\00"
define void @error(i16 zeroext %0) {
%2 = tail call i8* @reason(i16 zeroext %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %24, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%6 = tail call i64 @log10(i16 zeroext %0)
%7 = trunc i64 %6 to i32
%8 = xor i32 %7, -1
%9 = tail call i32 @strlen(i8* %2)
%10 = add i32 %5, -4
%11 = add i32 %10, %8
%12 = add i32 %11, %9
%13 = shl nsw i32 %12, 1
%14 = or i32 %13, 1
%15 = zext i32 %14 to i64
%16 = tail call i8* @llvm.stacksave()
%17 = alloca i8, i64 %15
%18 = call i32 @sprintf(i8* %17, i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0), i16 zeroext %0, i8* %2, i16 zeroext %0, i8* %2)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %4
store i8 0, i8* %17
br label %21
21: ; preds = %20, %4
%22 = phi i32 [ 0, %20 ], [ %18, %4 ]
%23 = call i32 @respond(i16 zeroext %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %17, i32 %22)
br label %24
24: ; preds = %1, %21
ret void
}