#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*/ err_abort(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int const, char const *,
                           char const *);
int strlen(char *);
int write(int, char *, int);
void send_error(int sockfd, const char *version, const int code,
                const char *text) {
  char response[255];
  sprintf(response, "HTTP/1.1 %d %s\r\n\r\n%s\r\n\r\n", code, text, text);
  int n = strlen(response);
  printf("sending: %s\n", response);
  if (write(sockfd, response, n) != n) {
    err_abort("Fehler beim Schreiben des Sockets!");
  }
}


x86 assembly (clang, -O0):
<send_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe7e(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x124(%rbp)
lea    -0x120(%rbp),%rsi
lea    0xe72(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    -0x124(%rbp),%edx
call   1030 <write@plt>
cmp    -0x124(%rbp),%eax
je     11d9 <send_error+0x89>
lea    0xe52(%rip),%rdi
call   1060 <err_abort@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_error>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %edi,%r14d
lea    0xe9b(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %rcx,%r8
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0xe95(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <write@plt>
cmp    %ebp,%eax
je     11a9 <send_error+0x59>
lea    0xe82(%rip),%rdi
call   1060 <err_abort@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"HTTP/1.1 %d %s\0D\0A\0D\0A%s\0D\0A\0D\0A\00"
@.str.1 = [13 x i8] c"sending: %s\0A\00"
@.str.2 = [35 x i8] c"Fehler beim Schreiben des Sockets!\00"
define void @send_error(i32 %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [255 x i8]
%10 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%12 = load i32, i32* %7
%13 = load i8*, i8** %8
%14 = load i8*, i8** %8
%15 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %13, i8* %14)
%16 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %10
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %5
%21 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%22 = load i32, i32* %10
%23 = call i32 @write(i32 %20, i8* %21, i32 %22)
%24 = load i32, i32* %10
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %4
%27 = call i32 @err_abort(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %4
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"HTTP/1.1 %d %s\0D\0A\0D\0A%s\0D\0A\0D\0A\00"
@.str.1 = [13 x i8] c"sending: %s\0A\00"
@.str.2 = [35 x i8] c"Fehler beim Schreiben des Sockets!\00"
define void @send_error(i32 %0, i8* nocapture readnone %1, i32 %2, i8* %3) {
%5 = alloca [255 x i8]
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %2, i8* %3, i8* %3)
%8 = call i32 @strlen(i8* %6)
%9 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%10 = call i32 @write(i32 %0, i8* %6, i32 %8)
%11 = icmp eq i32 %10, %8
br i1 %11, label %14, label %12
12: ; preds = %4
%13 = call i32 @err_abort(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %4
ret void
}