#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 {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ server;
typedef int /*<<< orphan*/ client;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_KEEPALIVE;
int /*<<< orphan*/ SO_REUSEADDR;
int /*<<< orphan*/ TCP_KEEPCNT;
int /*<<< orphan*/ TCP_KEEPIDLE;
int /*<<< orphan*/ TCP_KEEPINTVL;
int /*<<< orphan*/ TCP_NODELAY;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int listen(int, int);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              void *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc < 3) {
    fprintf(stderr, "Usage: %s [port] [enable_keepalive_flag]\n", argv[0]);
    fflush(stderr);
    exit(1);
  };
  int port = atoi(argv[1]);
  int enable_keepalive = atoi(argv[2]);
  int server_fd, client_fd, err;
  struct sockaddr_in server, client;
  char buf[1024];
  server_fd = socket(AF_INET, SOCK_STREAM, 0);
  if (server_fd < 0) {
    fprintf(stderr, "Could not create socket\n");
    fflush(stderr);
    exit(1);
  };
  server.sin_family = AF_INET;
  server.sin_port = htons(port);
  server.sin_addr.s_addr = htonl(INADDR_ANY);
  int opt_val = 1;
  setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &opt_val, sizeof opt_val);
  err = bind(server_fd, (struct sockaddr *)&server, sizeof(server));
  if (err < 0) {
    fprintf(stderr, "Could not bind socket\n");
    fflush(stderr);
    exit(1);
  };
  err = listen(server_fd, 128);
  if (err < 0) {
    fprintf(stderr, "Could not listen on socket\n");
    fflush(stderr);
    exit(1);
  };
  printf("Server is listening on %d\n", port);
  while (1) {
    int nodelay = 1;
    socklen_t client_len = sizeof(client);
    client_fd = accept(server_fd, (struct sockaddr *)&client, &client_len);
    if (client_fd < 0) {
      fprintf(stderr, "Could not establish new connection\n");
      fflush(stderr);
      exit(1);
    };
    setsockopt(client_fd, IPPROTO_TCP, TCP_NODELAY, (void *)&nodelay,
               sizeof(int));
    if (enable_keepalive) {
      int optval = 1;
      setsockopt(client_fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&optval,
                 sizeof(int));
      int idle = 600;
      setsockopt(client_fd, IPPROTO_TCP, TCP_KEEPIDLE, (void *)&idle,
                 sizeof(int));
      int interval = 30;
      setsockopt(client_fd, IPPROTO_TCP, TCP_KEEPINTVL, (void *)&interval,
                 sizeof(int));
      int count = 5;
      setsockopt(client_fd, IPPROTO_TCP, TCP_KEEPCNT, (void *)&count,
                 sizeof(int));
    }
    printf("Get Client Connected!!!\n");
    while (1) {
      int read = recv(client_fd, buf, 1024, 0);
      if (!read)
        break;
      if (read < 0) {
        fprintf(stderr, "Client read failed\n");
        fflush(stderr);
        exit(1);
      };
      err = send(client_fd, buf, read, 0);
      if (err < 0) {
        fprintf(stderr, "Client write failed\n");
        fflush(stderr);
        exit(1);
      };
      buf[read] = 0;
      printf("GET: %s", buf);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1239 <main+0x59>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xde6(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
mov    0x2d37(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    12ae <main+0xce>
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
lea    0xd9b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2d23(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x30(%rbp)
movl   $0x1,-0x444(%rbp)
mov    -0x1c(%rbp),%edi
mov    0x2cfe(%rip),%rax
mov    (%rax),%esi
mov    0x2c9d(%rip),%rax
mov    (%rax),%edx
lea    -0x444(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
mov    -0x1c(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1354 <main+0x174>
mov    0x2c7c(%rip),%rax
mov    (%rax),%edi
lea    0xd0e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c65(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    $0x80,%esi
call   10b0 <listen@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    139d <main+0x1bd>
mov    0x2c33(%rip),%rax
mov    (%rax),%edi
lea    0xcdc(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c1c(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x14(%rbp),%esi
lea    0xccf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x448(%rbp)
movl   $0xc,-0x44c(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x44c(%rbp),%rdx
call   10d0 <accept@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1411 <main+0x231>
mov    0x2bbf(%rip),%rax
mov    (%rax),%edi
lea    0xc9f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2ba8(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x20(%rbp),%edi
mov    0x2bad(%rip),%rax
mov    (%rax),%esi
mov    0x2bbc(%rip),%rax
mov    (%rax),%edx
lea    -0x448(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmpl   $0x0,-0x18(%rbp)
je     1506 <main+0x326>
movl   $0x1,-0x450(%rbp)
mov    -0x20(%rbp),%edi
mov    0x2b92(%rip),%rax
mov    (%rax),%esi
mov    0x2b21(%rip),%rax
mov    (%rax),%edx
lea    -0x450(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
movl   $0x258,-0x454(%rbp)
mov    -0x20(%rbp),%edi
mov    0x2b41(%rip),%rax
mov    (%rax),%esi
mov    0x2b08(%rip),%rax
mov    (%rax),%edx
lea    -0x454(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
movl   $0x1e,-0x458(%rbp)
mov    -0x20(%rbp),%edi
mov    0x2b10(%rip),%rax
mov    (%rax),%esi
mov    0x2aff(%rip),%rax
mov    (%rax),%edx
lea    -0x458(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
movl   $0x5,-0x45c(%rbp)
mov    -0x20(%rbp),%edi
mov    0x2adf(%rip),%rax
mov    (%rax),%esi
mov    0x2ac6(%rip),%rax
mov    (%rax),%edx
lea    -0x45c(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
lea    0xba8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%edi
lea    -0x440(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x460(%rbp)
cmpl   $0x0,-0x460(%rbp)
jne    1542 <main+0x362>
jmp    15fa <main+0x41a>
cmpl   $0x0,-0x460(%rbp)
jge    157e <main+0x39e>
mov    0x2a52(%rip),%rax
mov    (%rax),%edi
lea    0xb6f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2a3b(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x20(%rbp),%edi
lea    -0x440(%rbp),%rsi
mov    -0x460(%rbp),%edx
xor    %ecx,%ecx
call   1060 <send@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    15d1 <main+0x3f1>
mov    0x29ff(%rip),%rax
mov    (%rax),%edi
lea    0xb30(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x29e8(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
movslq -0x460(%rbp),%rax
movb   $0x0,-0x440(%rbp,%rax,1)
lea    -0x440(%rbp),%rsi
lea    0xb09(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1514 <main+0x334>
jmp    13ae <main+0x1ce>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x448,%rsp
mov    %rsi,%rbp
cmp    $0x2,%edi
jg     1229 <main+0x39>
mov    0x2d98(%rip),%rbx
mov    (%rbx),%edi
mov    0x0(%rbp),%rdx
lea    0xde3(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1513 <main+0x323>
mov    0x8(%rbp),%rdi
call   10f0 <atoi@plt>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
call   10f0 <atoi@plt>
mov    %eax,0x8(%rsp)
mov    0x2d90(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d4e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
test   %eax,%eax
jns    1274 <main+0x84>
mov    0x2d42(%rip),%rbx
mov    (%rbx),%edi
lea    0xdbb(%rip),%rsi
jmp    150c <main+0x31c>
mov    %eax,%r13d
mov    0x0(%rbp),%eax
mov    %eax,0x28(%rsp)
mov    %ebx,%edi
call   1060 <htons@plt>
mov    %eax,0x24(%rsp)
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
call   1090 <htonl@plt>
mov    %eax,0x20(%rsp)
movl   $0x1,0x1c(%rsp)
mov    0x2d3e(%rip),%rax
mov    (%rax),%esi
mov    0x2cdd(%rip),%rax
mov    (%rax),%edx
lea    0x1c(%rsp),%rcx
mov    %r13d,%edi
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
lea    0x20(%rsp),%rsi
mov    %r13d,%edi
mov    $0xc,%edx
call   10d0 <bind@plt>
test   %eax,%eax
jns    12f3 <main+0x103>
mov    0x2cc3(%rip),%rbx
mov    (%rbx),%edi
lea    0xd55(%rip),%rsi
jmp    150c <main+0x31c>
mov    %r13d,%edi
mov    $0x80,%esi
call   10c0 <listen@plt>
test   %eax,%eax
jns    1319 <main+0x129>
mov    0x2c9d(%rip),%rbx
mov    (%rbx),%edi
lea    0xd46(%rip),%rsi
jmp    150c <main+0x31c>
lea    0xd56(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1080 <printf@plt>
movl   $0x1,0x4(%rsp)
movl   $0xc,(%rsp)
lea    0x30(%rsp),%rsi
mov    %rsp,%rdx
mov    %r13d,%edi
call   10e0 <accept@plt>
test   %eax,%eax
jns    1361 <main+0x171>
mov    0x2c55(%rip),%rbx
mov    (%rbx),%edi
lea    0xd35(%rip),%rsi
jmp    150c <main+0x31c>
mov    %eax,%ebx
mov    0x2c5e(%rip),%r12
lea    0x40(%rsp),%rbp
lea    0xd68(%rip),%r14
jmp    13a5 <main+0x1b5>
nopl   0x0(%rax,%rax,1)
movl   $0x1,0x4(%rsp)
movl   $0xc,(%rsp)
mov    %r13d,%edi
lea    0x30(%rsp),%rsi
mov    %rsp,%rdx
call   10e0 <accept@plt>
mov    %eax,%ebx
test   %eax,%eax
js     134c <main+0x15c>
mov    (%r12),%esi
mov    0x2c30(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
lea    0x4(%rsp),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
cmpl   $0x0,0x8(%rsp)
je     1470 <main+0x280>
movl   $0x1,0x18(%rsp)
mov    0x2c0a(%rip),%rax
mov    (%rax),%esi
mov    0x2b99(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
lea    0x18(%rsp),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
movl   $0x258,0x14(%rsp)
mov    (%r12),%esi
mov    0x2b8a(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
lea    0x14(%rsp),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
movl   $0x1e,0x10(%rsp)
mov    (%r12),%esi
mov    0x2b8b(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
lea    0x10(%rsp),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
movl   $0x5,0xc(%rsp)
mov    (%r12),%esi
mov    0x2b5c(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
lea    0xc(%rsp),%rcx
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
lea    0xc6f(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
je     1380 <main+0x190>
mov    %eax,%r15d
nopl   0x0(%rax,%rax,1)
test   %r15d,%r15d
js     14ea <main+0x2fa>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r15d,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
test   %eax,%eax
js     14fc <main+0x30c>
mov    %r15d,%eax
movb   $0x0,0x40(%rsp,%rax,1)
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%r15d
test   %eax,%eax
jne    14a0 <main+0x2b0>
jmp    1380 <main+0x190>
mov    0x2ab7(%rip),%rbx
mov    (%rbx),%edi
lea    0xbbb(%rip),%rsi
jmp    150c <main+0x31c>
mov    0x2aa5(%rip),%rbx
mov    (%rbx),%edi
lea    0xbbd(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
call   10b0 <fflush@plt>
mov    $0x1,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [42 x i8] c"Usage: %s [port] [enable_keepalive_flag]\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [25 x i8] c"Could not create socket\0A\00"
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [23 x i8] c"Could not bind socket\0A\00"
@.str.3 = [28 x i8] c"Could not listen on socket\0A\00"
@.str.4 = [27 x i8] c"Server is listening on %d\0A\00"
@.str.5 = [36 x i8] c"Could not establish new connection\0A\00"
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
@SO_KEEPALIVE = global i32 0
@TCP_KEEPIDLE = global i32 0
@TCP_KEEPINTVL = global i32 0
@TCP_KEEPCNT = global i32 0
@.str.6 = [25 x i8] c"Get Client Connected!!!\0A\00"
@.str.7 = [20 x i8] c"Client read failed\0A\00"
@.str.8 = [21 x i8] c"Client write failed\0A\00"
@.str.9 = [8 x i8] c"GET: %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 i32
%10 = alloca i32
%11 = alloca %struct.sockaddr_in
%12 = alloca %struct.sockaddr_in
%13 = alloca [1024 x i8]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 3
br i1 %23, label %24, label %33
24: ; preds = %2
%25 = load i32, i32* @stderr
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @stderr
%31 = call i32 @fflush(i32 %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %2
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %6
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @atoi(i8* %40)
store i32 %41, i32* %7
%42 = load i32, i32* @AF_INET
%43 = load i32, i32* @SOCK_STREAM
%44 = call i32 @socket(i32 %42, i32 %43, i32 0)
store i32 %44, i32* %8
%45 = load i32, i32* %8
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %53
47: ; preds = %33
%48 = load i32, i32* @stderr
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%50 = load i32, i32* @stderr
%51 = call i32 @fflush(i32 %50)
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %33
%54 = load i32, i32* @AF_INET
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %54, i32* %55
%56 = load i32, i32* %6
%57 = call i32 @htons(i32 %56)
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
store i32 %57, i32* %58
%59 = load i32, i32* @INADDR_ANY
%60 = call i32 @htonl(i32 %59)
%61 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%62 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %61, i32 0, i32 0
store i32 %60, i32* %62
store i32 1, i32* %14
%63 = load i32, i32* %8
%64 = load i32, i32* @SOL_SOCKET
%65 = load i32, i32* @SO_REUSEADDR
%66 = bitcast i32* %14 to i8*
%67 = call i32 @setsockopt(i32 %63, i32 %64, i32 %65, i8* %66, i32 4)
%68 = load i32, i32* %8
%69 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%70 = call i32 @bind(i32 %68, %struct.sockaddr* %69, i32 12)
store i32 %70, i32* %10
%71 = load i32, i32* %10
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %79
73: ; preds = %53
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%76 = load i32, i32* @stderr
%77 = call i32 @fflush(i32 %76)
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %53
%80 = load i32, i32* %8
%81 = call i32 @listen(i32 %80, i32 128)
store i32 %81, i32* %10
%82 = load i32, i32* %10
%83 = icmp slt i32 %82, 0
br i1 %83, label %84, label %90
84: ; preds = %79
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%87 = load i32, i32* @stderr
%88 = call i32 @fflush(i32 %87)
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %79
%91 = load i32, i32* %6
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %91)
br label %93
93: ; preds = %90, %171
store i32 1, i32* %15
store i32 12, i32* %16
%94 = load i32, i32* %8
%95 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%96 = call i32 @accept(i32 %94, %struct.sockaddr* %95, i32* %16)
store i32 %96, i32* %9
%97 = load i32, i32* %9
%98 = icmp slt i32 %97, 0
br i1 %98, label %99, label %105
99: ; preds = %93
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%102 = load i32, i32* @stderr
%103 = call i32 @fflush(i32 %102)
%104 = call i32 @exit(i32 1)
unreachable
105: ; preds = %93
%106 = load i32, i32* %9
%107 = load i32, i32* @IPPROTO_TCP
%108 = load i32, i32* @TCP_NODELAY
%109 = bitcast i32* %15 to i8*
%110 = call i32 @setsockopt(i32 %106, i32 %107, i32 %108, i8* %109, i32 4)
%111 = load i32, i32* %7
%112 = icmp ne i32 %111, 0
br i1 %112, label %113, label %134
113: ; preds = %105
store i32 1, i32* %17
%114 = load i32, i32* %9
%115 = load i32, i32* @SOL_SOCKET
%116 = load i32, i32* @SO_KEEPALIVE
%117 = bitcast i32* %17 to i8*
%118 = call i32 @setsockopt(i32 %114, i32 %115, i32 %116, i8* %117, i32 4)
store i32 600, i32* %18
%119 = load i32, i32* %9
%120 = load i32, i32* @IPPROTO_TCP
%121 = load i32, i32* @TCP_KEEPIDLE
%122 = bitcast i32* %18 to i8*
%123 = call i32 @setsockopt(i32 %119, i32 %120, i32 %121, i8* %122, i32 4)
store i32 30, i32* %19
%124 = load i32, i32* %9
%125 = load i32, i32* @IPPROTO_TCP
%126 = load i32, i32* @TCP_KEEPINTVL
%127 = bitcast i32* %19 to i8*
%128 = call i32 @setsockopt(i32 %124, i32 %125, i32 %126, i8* %127, i32 4)
store i32 5, i32* %20
%129 = load i32, i32* %9
%130 = load i32, i32* @IPPROTO_TCP
%131 = load i32, i32* @TCP_KEEPCNT
%132 = bitcast i32* %20 to i8*
%133 = call i32 @setsockopt(i32 %129, i32 %130, i32 %131, i8* %132, i32 4)
br label %134
134: ; preds = %113, %105
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %136
136: ; preds = %134, %165
%137 = load i32, i32* %9
%138 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%139 = call i32 @recv(i32 %137, i8* %138, i32 1024, i32 0)
store i32 %139, i32* %21
%140 = load i32, i32* %21
%141 = icmp ne i32 %140, 0
br i1 %141, label %143, label %142
142: ; preds = %136
br label %171
143: ; preds = %136
%144 = load i32, i32* %21
%145 = icmp slt i32 %144, 0
br i1 %145, label %146, label %152
146: ; preds = %143
%147 = load i32, i32* @stderr
%148 = call i32 (i32, i8*, ...) @fprintf(i32 %147, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%149 = load i32, i32* @stderr
%150 = call i32 @fflush(i32 %149)
%151 = call i32 @exit(i32 1)
unreachable
152: ; preds = %143
%153 = load i32, i32* %9
%154 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%155 = load i32, i32* %21
%156 = call i32 @send(i32 %153, i8* %154, i32 %155, i32 0)
store i32 %156, i32* %10
%157 = load i32, i32* %10
%158 = icmp slt i32 %157, 0
br i1 %158, label %159, label %165
159: ; preds = %152
%160 = load i32, i32* @stderr
%161 = call i32 (i32, i8*, ...) @fprintf(i32 %160, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%162 = load i32, i32* @stderr
%163 = call i32 @fflush(i32 %162)
%164 = call i32 @exit(i32 1)
unreachable
165: ; preds = %152
%166 = load i32, i32* %21
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %167
store i8 0, i8* %168
%169 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* %169)
br label %136
171: ; preds = %142
br label %93
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [42 x i8] c"Usage: %s [port] [enable_keepalive_flag]\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [25 x i8] c"Could not create socket\0A\00"
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [23 x i8] c"Could not bind socket\0A\00"
@.str.3 = [28 x i8] c"Could not listen on socket\0A\00"
@.str.4 = [27 x i8] c"Server is listening on %d\0A\00"
@.str.5 = [36 x i8] c"Could not establish new connection\0A\00"
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
@SO_KEEPALIVE = global i32 0
@TCP_KEEPIDLE = global i32 0
@TCP_KEEPINTVL = global i32 0
@TCP_KEEPCNT = global i32 0
@.str.7 = [20 x i8] c"Client read failed\0A\00"
@.str.8 = [21 x i8] c"Client write failed\0A\00"
@.str.9 = [8 x i8] c"GET: %s\00"
@str = [24 x i8] c"Get Client Connected!!!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca [1024 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = icmp slt i32 %0, 3
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @stderr
%19 = tail call i32 @fflush(i32 %18)
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = tail call i32 @atoi(i8* %23)
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = tail call i32 @atoi(i8* %26)
%28 = bitcast %struct.sockaddr_in* %3 to i8*
%29 = bitcast %struct.sockaddr_in* %4 to i8*
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%31 = load i32, i32* @AF_INET
%32 = load i32, i32* @SOCK_STREAM
%33 = tail call i32 @socket(i32 %31, i32 %32, i32 0)
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %21
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%38 = load i32, i32* @stderr
%39 = tail call i32 @fflush(i32 %38)
%40 = tail call i32 @exit(i32 1)
unreachable
41: ; preds = %21
%42 = load i32, i32* @AF_INET
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %42, i32* %43
%44 = tail call i32 @htons(i32 %24)
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %44, i32* %45
%46 = load i32, i32* @INADDR_ANY
%47 = tail call i32 @htonl(i32 %46)
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %47, i32* %48
%49 = bitcast i32* %6 to i8*
store i32 1, i32* %6
%50 = load i32, i32* @SOL_SOCKET
%51 = load i32, i32* @SO_REUSEADDR
%52 = call i32 @setsockopt(i32 %33, i32 %50, i32 %51, i8* %49, i32 4)
%53 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%54 = call i32 @bind(i32 %33, %struct.sockaddr* %53, i32 12)
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %62
56: ; preds = %41
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%59 = load i32, i32* @stderr
%60 = call i32 @fflush(i32 %59)
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %41
%63 = call i32 @listen(i32 %33, i32 128)
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %71
65: ; preds = %62
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%68 = load i32, i32* @stderr
%69 = call i32 @fflush(i32 %68)
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %62
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%73 = bitcast i32* %7 to i8*
%74 = bitcast i32* %8 to i8*
%75 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
store i32 1, i32* %7
store i32 12, i32* %8
%76 = call i32 @accept(i32 %33, %struct.sockaddr* %75, i32* %8)
%77 = icmp slt i32 %76, 0
br i1 %77, label %84, label %78
78: ; preds = %71
%79 = icmp eq i32 %27, 0
%80 = bitcast i32* %9 to i8*
%81 = bitcast i32* %10 to i8*
%82 = bitcast i32* %11 to i8*
%83 = bitcast i32* %12 to i8*
br label %90
84: ; preds = %136, %71
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0))
%87 = load i32, i32* @stderr
%88 = call i32 @fflush(i32 %87)
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %78, %136
%91 = phi i32 [ %76, %78 ], [ %137, %136 ]
%92 = load i32, i32* @IPPROTO_TCP
%93 = load i32, i32* @TCP_NODELAY
%94 = call i32 @setsockopt(i32 %91, i32 %92, i32 %93, i8* %73, i32 4)
br i1 %79, label %108, label %95
95: ; preds = %90
store i32 1, i32* %9
%96 = load i32, i32* @SOL_SOCKET
%97 = load i32, i32* @SO_KEEPALIVE
%98 = call i32 @setsockopt(i32 %91, i32 %96, i32 %97, i8* %80, i32 4)
store i32 600, i32* %10
%99 = load i32, i32* @IPPROTO_TCP
%100 = load i32, i32* @TCP_KEEPIDLE
%101 = call i32 @setsockopt(i32 %91, i32 %99, i32 %100, i8* %81, i32 4)
store i32 30, i32* %11
%102 = load i32, i32* @IPPROTO_TCP
%103 = load i32, i32* @TCP_KEEPINTVL
%104 = call i32 @setsockopt(i32 %91, i32 %102, i32 %103, i8* %82, i32 4)
store i32 5, i32* %12
%105 = load i32, i32* @IPPROTO_TCP
%106 = load i32, i32* @TCP_KEEPCNT
%107 = call i32 @setsockopt(i32 %91, i32 %105, i32 %106, i8* %83, i32 4)
br label %108
108: ; preds = %95, %90
%109 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%110 = call i32 @recv(i32 %91, i8* %30, i32 1024, i32 0)
%111 = icmp eq i32 %110, 0
br i1 %111, label %136, label %112
112: ; preds = %108, %130
%113 = phi i32 [ %134, %130 ], [ %110, %108 ]
%114 = icmp slt i32 %113, 0
br i1 %114, label %115, label %121
115: ; preds = %112
%116 = load i32, i32* @stderr
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%118 = load i32, i32* @stderr
%119 = call i32 @fflush(i32 %118)
%120 = call i32 @exit(i32 1)
unreachable
121: ; preds = %112
%122 = call i32 @send(i32 %91, i8* %30, i32 %113, i32 0)
%123 = icmp slt i32 %122, 0
br i1 %123, label %124, label %130
124: ; preds = %121
%125 = load i32, i32* @stderr
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%127 = load i32, i32* @stderr
%128 = call i32 @fflush(i32 %127)
%129 = call i32 @exit(i32 1)
unreachable
130: ; preds = %121
%131 = zext i32 %113 to i64
%132 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %131
store i8 0, i8* %132
%133 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* %30)
%134 = call i32 @recv(i32 %91, i8* %30, i32 1024, i32 0)
%135 = icmp eq i32 %134, 0
br i1 %135, label %136, label %112
136: ; preds = %130, %108
store i32 1, i32* %7
store i32 12, i32* %8
%137 = call i32 @accept(i32 %33, %struct.sockaddr* %75, i32* %8)
%138 = icmp slt i32 %137, 0
br i1 %138, label %84, label %90
}