#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*/ strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int serverSendHTML(int cfd, char *html) {
  char *ok = "HTTP/1.0 200\r\nContent-type:text/html\r\n\r\n";
  char resp[1024];
  strncpy(resp, ok, 1024);
  strncat(resp, html, 1024);
  write(cfd, resp, strlen(resp));
  return 0;
}


x86 assembly (clang, -O0):
<serverSendHTML>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x400,%edx
call   1030 <strncpy@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x400,%edx
call   1060 <strncat@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x42c(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x428(%rbp)
lea    -0x420(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x42c(%rbp),%edi
mov    -0x428(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serverSendHTML>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
lea    0xea8(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x400,%edx
call   1030 <strncpy@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1060 <strncat@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"HTTP/1.0 200\0D\0AContent-type:text/html\0D\0A\0D\0A\00"
define i32 @serverSendHTML(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [1024 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
store i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8** %5
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%8 = load i8*, i8** %5
%9 = call i32 @strncpy(i8* %7, i8* %8, i32 1024)
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = call i32 @strncat(i8* %10, i8* %11, i32 1024)
%13 = load i32, i32* %3
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = call i32 @write(i32 %13, i8* %14, i32 %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"HTTP/1.0 200\0D\0AContent-type:text/html\0D\0A\0D\0A\00"
define i32 @serverSendHTML(i32 %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32 @strncpy(i8* %4, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 1024)
%6 = call i32 @strncat(i8* %4, i8* %1, i32 1024)
%7 = call i32 @strlen(i8* %4)
%8 = call i32 @write(i32 %0, i8* %4, i32 %7)
ret i32 0
}