#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ server_addr;
typedef int /*<<< orphan*/ buff;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ *fdopen(int, char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int listen(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  int server_socket_fd;
  int sck;
  FILE *fp;
  char buffer[1024];
  char buff[1024];
  struct sockaddr_in server_addr;
  server_addr.sin_family = AF_INET;
  server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  server_addr.sin_port = htons(1373);
  server_socket_fd = socket(AF_INET, SOCK_STREAM, 0);
  if (server_socket_fd == -1)
    perror("socket()");
  if (bind(server_socket_fd, (struct sockaddr *)&server_addr,
           sizeof(server_addr)) == -1)
    perror("bind()");
  if (listen(server_socket_fd, 10) == -1)
    perror("listen()");
  sck = accept(server_socket_fd, NULL, NULL);
  fp = fdopen(sck, "r");
  while (fgets(buff, sizeof(buff), fp)) {
    sprintf(buffer, "<tr><td>%s", buff);
    send(sck, buffer, strlen(buffer), 0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x828(%rbp)
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,-0x82c(%rbp)
mov    $0x55d,%edi
call   1040 <htons@plt>
mov    %eax,-0x830(%rbp)
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
mov    0x2db4(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    123e <main+0x7e>
lea    0xdc7(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x14(%rbp),%edi
lea    -0x830(%rbp),%rsi
mov    $0xc,%edx
call   10a0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1267 <main+0xa7>
lea    0xda7(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x14(%rbp),%edi
mov    $0xa,%esi
call   1080 <listen@plt>
cmp    $0xffffffff,%eax
jne    1289 <main+0xc9>
lea    0xd8c(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   10c0 <accept@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
lea    0xd74(%rip),%rsi
call   1090 <fdopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x820(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x400,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1325 <main+0x165>
lea    -0x420(%rbp),%rdi
lea    -0x820(%rbp),%rdx
lea    0xd39(%rip),%rsi
call   10d0 <sprintf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x83c(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x838(%rbp)
lea    -0x420(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x83c(%rbp),%edi
mov    -0x838(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
jmp    12ae <main+0xee>
mov    -0x4(%rbp),%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x810,%rsp
mov    0x2e12(%rip),%rbx
mov    (%rbx),%eax
mov    %eax,0x8(%rsp)
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1060 <htonl@plt>
mov    %eax,0x4(%rsp)
mov    $0x55d,%edi
call   1040 <htons@plt>
mov    %eax,(%rsp)
mov    (%rbx),%edi
mov    0x2dcc(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     12dc <main+0x11c>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0xc,%edx
call   10a0 <bind@plt>
cmp    $0xffffffff,%eax
je     12ed <main+0x12d>
mov    %ebx,%edi
mov    $0xa,%esi
call   1080 <listen@plt>
cmp    $0xffffffff,%eax
je     12fe <main+0x13e>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <accept@plt>
mov    %eax,%r15d
lea    0xdbf(%rip),%rsi
mov    %eax,%edi
call   1090 <fdopen@plt>
mov    %rax,%r12
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     12ca <main+0x10a>
lea    0xd99(%rip),%r14
lea    0x410(%rsp),%rbp
lea    0x10(%rsp),%rbx
nop
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   10d0 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r12,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
jne    1290 <main+0xd0>
xor    %eax,%eax
add    $0x810,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd1d(%rip),%rdi
call   10b0 <perror@plt>
jmp    1218 <main+0x58>
lea    0xd15(%rip),%rdi
call   10b0 <perror@plt>
jmp    1230 <main+0x70>
lea    0xd0b(%rip),%rdi
call   10b0 <perror@plt>
jmp    1245 <main+0x85>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_STREAM = global i32 0
@.str = [9 x i8] c"socket()\00"
@.str.1 = [7 x i8] c"bind()\00"
@.str.2 = [9 x i8] c"listen()\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [11 x i8] c"<tr><td>%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca [1024 x i8]
%10 = alloca [1024 x i8]
%11 = alloca %struct.sockaddr_in
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* @AF_INET
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %12, i32* %13
%14 = load i32, i32* @INADDR_ANY
%15 = call i32 @htonl(i32 %14)
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
%17 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %16, i32 0, i32 0
store i32 %15, i32* %17
%18 = call i32 @htons(i32 1373)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
store i32 %18, i32* %19
%20 = load i32, i32* @AF_INET
%21 = load i32, i32* @SOCK_STREAM
%22 = call i32 @socket(i32 %20, i32 %21, i32 0)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %27
25: ; preds = %2
%26 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %2
%28 = load i32, i32* %6
%29 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%30 = call i32 @bind(i32 %28, %struct.sockaddr* %29, i32 12)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %32, %27
%35 = load i32, i32* %6
%36 = call i32 @listen(i32 %35, i32 10)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
%41 = load i32, i32* %6
%42 = call i32 @accept(i32 %41, i32* null, i32* null)
store i32 %42, i32* %7
%43 = load i32, i32* %7
%44 = call i32* @fdopen(i32 %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %44, i32** %8
br label %45
45: ; preds = %50, %40
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%47 = load i32*, i32** %8
%48 = call i64 @fgets(i8* %46, i32 1024, i32* %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %59
50: ; preds = %45
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%53 = call i32 @sprintf(i8* %51, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %52)
%54 = load i32, i32* %7
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%57 = call i32 @strlen(i8* %56)
%58 = call i32 @send(i32 %54, i8* %55, i32 %57, i32 0)
br label %45
59: ; preds = %45
%60 = load i32, i32* %3
ret i32 %60
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_STREAM = global i32 0
@.str = [9 x i8] c"socket()\00"
@.str.1 = [7 x i8] c"bind()\00"
@.str.2 = [9 x i8] c"listen()\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [11 x i8] c"<tr><td>%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca %struct.sockaddr_in
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = bitcast %struct.sockaddr_in* %5 to i8*
%9 = load i32, i32* @AF_INET
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i32 %9, i32* %10
%11 = load i32, i32* @INADDR_ANY
%12 = tail call i32 @htonl(i32 %11)
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1, i32 0
store i32 %12, i32* %13
%14 = tail call i32 @htons(i32 1373)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
store i32 %14, i32* %15
%16 = load i32, i32* @AF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = tail call i32 @socket(i32 %16, i32 %17, i32 0)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %2
%23 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%24 = call i32 @bind(i32 %18, %struct.sockaddr* %23, i32 12)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
%29 = call i32 @listen(i32 %18, i32 10)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %31, %28
%34 = call i32 @accept(i32 %18, i32* null, i32* null)
%35 = call i32* @fdopen(i32 %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%36 = call i64 @fgets(i8* %7, i32 1024, i32* %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %44, label %38
38: ; preds = %33, %38
%39 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %7)
%40 = call i32 @strlen(i8* %6)
%41 = call i32 @send(i32 %34, i8* %6, i32 %40, i32 0)
%42 = call i64 @fgets(i8* %7, i32 1024, i32* %35)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %38
44: ; preds = %38, %33
ret i32 0
}