#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 */
typedef int /*<<< orphan*/ u_short;
typedef scalar_t__ time_t;
typedef int /*<<< orphan*/ time_str;
struct tm {
  int dummy;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ recv_buf;
typedef int /*<<< orphan*/ expires_time_str;
typedef int /*<<< orphan*/ client_addr;

/* Variables and functions */
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ close(int);
struct tm *gmtime(scalar_t__ *);
char *inet_ntoa(int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ strlen(char *);
scalar_t__ time(int /*<<< orphan*/ *);
int accept_loop(int soc) {
  struct sockaddr_in client_addr;
  int client_addr_len;
  int acc;
  char *client_ip_addr_str;
  u_short client_port;
  int ret = 0;
  char recv_buf[4096] = {0};
  char send_buf[4096] = {0};
  char response_header[4096] = {0};
  char response_body[4096] = {0};
  time_t t;
  struct tm *tm_ptr;
  char time_str[128];
  int content_length = 0;
  char content_length_str[128];
  time_t expires_t;
  struct tm *expires_tm_ptr;
  char expires_time_str[128];
  while (1) {
    client_addr_len = sizeof(client_addr);
    acc = accept(soc, (struct sockaddr *)&client_addr, &client_addr_len);
    if (acc < 0) {
      perror("accept");
      ret = -1;
      break;
    }
    client_ip_addr_str = inet_ntoa(client_addr.sin_addr);
    client_port = ntohs(client_addr.sin_port);
    printf("accept!(IPAddress = %s, Port = %hu)\n", client_ip_addr_str,
           client_port);
    memset(recv_buf, 0, sizeof(char) * 4096);
    recv(acc, recv_buf, sizeof(recv_buf), 0);
    printf("----- recv begin -----\n");
    printf("%s\n", recv_buf);
    printf("----- recv end -----\n");
    t = time(NULL);
    tm_ptr = gmtime(&t);
    strftime(time_str, sizeof(time_str), "%Y/%m/%d %H:%M:%S %Z", tm_ptr);
    expires_t = t + 5 * 60;
    expires_tm_ptr = gmtime(&expires_t);
    strftime(expires_time_str, sizeof(expires_time_str),
             "%a, %d %b %Y %H:%M:%S %Z", expires_tm_ptr);
    strcpy(response_body, "<html>\r\n");
    strcat(response_body, "  <head>\r\n");
    strcat(response_body, "    <title>HTTP 401 Unauthorized</title>\r\n");
    strcat(response_body, "  </head>\r\n");
    strcat(response_body, "  <body>\r\n");
    strcat(response_body, "    ");
    strcat(response_body, "HTTP 401 Unauthorized");
    strcat(response_body, "\r\n");
    strcat(response_body, "  </body>\r\n");
    strcat(response_body, "</html>\r\n");
    strcpy(response_header, "HTTP/1.1 401 Unauthorized\r\n");
    strcat(response_header, "WWW-Authenticate: Basic\r\n");
    strcpy(send_buf, response_header);
    strcat(send_buf, "\r\n");
    strcat(send_buf, response_body);
    send(acc, send_buf, strlen(send_buf), 0);
    close(acc);
  }
  return ret;
}


x86 assembly (clang, -O0):
<accept_loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x41f0,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x28(%rbp)
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1090 <memset@plt>
lea    -0x2030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1090 <memset@plt>
lea    -0x3030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1090 <memset@plt>
lea    -0x4030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1090 <memset@plt>
movl   $0x0,-0x40c4(%rbp)
movl   $0x8,-0x14(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1297 <accept_loop+0xa7>
lea    0xd7a(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x28(%rbp)
jmp    1508 <accept_loop+0x318>
mov    -0xc(%rbp),%edi
call   1050 <inet_ntoa@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
call   10c0 <ntohs@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1090 <memset@plt>
mov    -0x18(%rbp),%edi
lea    -0x1030(%rbp),%rsi
mov    $0x1000,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x1030(%rbp),%rsi
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd32(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
mov    %rax,-0x4038(%rbp)
lea    -0x4038(%rbp),%rdi
call   10f0 <gmtime@plt>
mov    %rax,-0x4040(%rbp)
lea    -0x40c0(%rbp),%rdi
mov    -0x4040(%rbp),%rcx
mov    $0x80,%esi
lea    0xd04(%rip),%rdx
call   10d0 <strftime@plt>
mov    -0x4038(%rbp),%rax
add    $0x12c,%rax
mov    %rax,-0x4158(%rbp)
lea    -0x4158(%rbp),%rdi
call   10f0 <gmtime@plt>
mov    %rax,-0x4160(%rbp)
lea    -0x41e0(%rbp),%rdi
mov    -0x4160(%rbp),%rcx
mov    $0x80,%esi
lea    0xcd3(%rip),%rdx
call   10d0 <strftime@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcd9(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x4030(%rbp),%rdi
lea    0xccf(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcc7(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcdf(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcd8(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcd0(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcc2(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xc9c(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcb2(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcab(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x3030(%rbp),%rdi
lea    0xca2(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x3030(%rbp),%rdi
lea    0xcab(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x2030(%rbp),%rdi
lea    -0x3030(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x2030(%rbp),%rdi
lea    0xc2a(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x2030(%rbp),%rdi
lea    -0x4030(%rbp),%rsi
call   1110 <strcat@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x41ec(%rbp)
lea    -0x2030(%rbp),%rax
mov    %rax,-0x41e8(%rbp)
lea    -0x2030(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x41ec(%rbp),%edi
mov    -0x41e8(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    -0x18(%rbp),%edi
call   10a0 <close@plt>
jmp    125b <accept_loop+0x6b>
mov    -0x28(%rbp),%eax
add    $0x41f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accept_loop>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4128,%rsp
mov    %edi,%r12d
lea    0x3120(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   10a0 <memset@plt>
lea    0x2120(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   10a0 <memset@plt>
lea    0x1120(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   10a0 <memset@plt>
lea    0x120(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   10a0 <memset@plt>
movl   $0x8,0x4(%rsp)
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %r12d,%edi
call   1110 <accept@plt>
test   %eax,%eax
js     1496 <accept_loop+0x296>
mov    %eax,%ebp
lea    0x120(%rsp),%r15
lea    0x1120(%rsp),%r14
lea    0x2120(%rsp),%r13
mov    0xc(%rsp),%edi
call   1060 <inet_ntoa@plt>
mov    %r12d,%ebx
mov    %rax,%r12
mov    0x8(%rsp),%edi
call   10d0 <ntohs@plt>
lea    0xd48(%rip),%rdi
mov    %r12,%rsi
mov    %ebx,%r12d
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x3120(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   10a0 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1000,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    0xe1a(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
lea    0xe1d(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10c0 <time@plt>
mov    %rax,0x10(%rsp)
lea    0x10(%rsp),%rdi
call   1100 <gmtime@plt>
lea    0xa0(%rsp),%rdi
mov    $0x80,%esi
lea    0xcec(%rip),%rdx
mov    %rax,%rcx
call   10e0 <strftime@plt>
mov    0x10(%rsp),%rax
mov    $0x12c,%ecx
add    %rcx,%rax
mov    %rax,0x18(%rsp)
lea    0x18(%rsp),%rdi
call   1100 <gmtime@plt>
lea    0x20(%rsp),%rdi
mov    $0x80,%esi
lea    0xccc(%rip),%rdx
mov    %rax,%rcx
call   10e0 <strftime@plt>
mov    %r15,%rdi
lea    0xcd3(%rip),%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
lea    0xccd(%rip),%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xcc9(%rip),%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xce5(%rip),%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xce2(%rip),%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xcde(%rip),%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xcd4(%rip),%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xcb2(%rip),%rbx
mov    %rbx,%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xcc9(%rip),%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xcc6(%rip),%rsi
call   1120 <strcat@plt>
mov    %r14,%rdi
lea    0xcc1(%rip),%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
lea    0xcce(%rip),%rsi
call   1120 <strcat@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1120 <strcat@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1120 <strcat@plt>
mov    %r13,%rdi
call   1070 <strlen@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
movl   $0x8,0x4(%rsp)
mov    %r12d,%edi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   1110 <accept@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    12a0 <accept_loop+0xa0>
lea    0xb63(%rip),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%eax
add    $0x4128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
%struct.tm = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [7 x i8] c"accept\00"
@.str.1 = [37 x i8] c"accept!(IPAddress = %s, Port = %hu)\0A\00"
@.str.2 = [24 x i8] c"----- recv begin -----\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [22 x i8] c"----- recv end -----\0A\00"
@.str.5 = [21 x i8] c"%Y/%m/%d %H:%M:%S %Z\00"
@.str.6 = [25 x i8] c"%a, %d %b %Y %H:%M:%S %Z\00"
@.str.7 = [9 x i8] c"<html>\0D\0A\00"
@.str.8 = [11 x i8] c" <head>\0D\0A\00"
@.str.9 = [43 x i8] c" <title>HTTP 401 Unauthorized</title>\0D\0A\00"
@.str.10 = [12 x i8] c" </head>\0D\0A\00"
@.str.11 = [11 x i8] c" <body>\0D\0A\00"
@.str.12 = [5 x i8] c" \00"
@.str.13 = [22 x i8] c"HTTP 401 Unauthorized\00"
@.str.14 = [3 x i8] c"\0D\0A\00"
@.str.15 = [12 x i8] c" </body>\0D\0A\00"
@.str.16 = [10 x i8] c"</html>\0D\0A\00"
@.str.17 = [28 x i8] c"HTTP/1.1 401 Unauthorized\0D\0A\00"
@.str.18 = [26 x i8] c"WWW-Authenticate: Basic\0D\0A\00"
define i32 @accept_loop(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [4096 x i8]
%10 = alloca [4096 x i8]
%11 = alloca [4096 x i8]
%12 = alloca [4096 x i8]
%13 = alloca i64
%14 = alloca %struct.tm*
%15 = alloca [128 x i8]
%16 = alloca i32
%17 = alloca [128 x i8]
%18 = alloca i64
%19 = alloca %struct.tm*
%20 = alloca [128 x i8]
store i32 %0, i32* %2
store i32 0, i32* %8
%21 = bitcast [4096 x i8]* %9 to i8*
%22 = bitcast [4096 x i8]* %10 to i8*
%23 = bitcast [4096 x i8]* %11 to i8*
%24 = bitcast [4096 x i8]* %12 to i8*
store i32 0, i32* %16
br label %25
25: ; preds = %1, %33
store i32 8, i32* %4
%26 = load i32, i32* %2
%27 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%28 = call i32 @accept(i32 %26, %struct.sockaddr* %27, i32* %4)
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %8
br label %102
33: ; preds = %25
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
%35 = load i32, i32* %34
%36 = call i8* @inet_ntoa(i32 %35)
store i8* %36, i8** %6
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%38 = load i32, i32* %37
%39 = call i32 @ntohs(i32 %38)
store i32 %39, i32* %7
%40 = load i8*, i8** %6
%41 = load i32, i32* %7
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %40, i32 %41)
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%44 = call i32 @memset(i8* %43, i32 0, i32 4096)
%45 = load i32, i32* %5
%46 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%47 = call i32 @recv(i32 %45, i8* %46, i32 4096, i32 0)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%49 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%52 = call i64 @time(i32* null)
store i64 %52, i64* %13
%53 = call %struct.tm* @gmtime(i64* %13)
store %struct.tm* %53, %struct.tm** %14
%54 = getelementptr inbounds [128 x i8], [128 x i8]* %15, i64 0, i64 0
%55 = load %struct.tm*, %struct.tm** %14
%56 = call i32 @strftime(i8* %54, i32 128, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), %struct.tm* %55)
%57 = load i64, i64* %13
%58 = add nsw i64 %57, 300
store i64 %58, i64* %18
%59 = call %struct.tm* @gmtime(i64* %18)
store %struct.tm* %59, %struct.tm** %19
%60 = getelementptr inbounds [128 x i8], [128 x i8]* %20, i64 0, i64 0
%61 = load %struct.tm*, %struct.tm** %19
%62 = call i32 @strftime(i8* %60, i32 128, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), %struct.tm* %61)
%63 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%64 = call i32 @strcpy(i8* %63, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%65 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%66 = call i32 @strcat(i8* %65, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%67 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%68 = call i32 @strcat(i8* %67, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0))
%69 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%70 = call i32 @strcat(i8* %69, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%71 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%72 = call i32 @strcat(i8* %71, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
%73 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%74 = call i32 @strcat(i8* %73, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%75 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%76 = call i32 @strcat(i8* %75, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0))
%77 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%78 = call i32 @strcat(i8* %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
%79 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%80 = call i32 @strcat(i8* %79, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0))
%81 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%82 = call i32 @strcat(i8* %81, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0))
%83 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%84 = call i32 @strcpy(i8* %83, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.17, i64 0, i64 0))
%85 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%86 = call i32 @strcat(i8* %85, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.18, i64 0, i64 0))
%87 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%88 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%89 = call i32 @strcpy(i8* %87, i8* %88)
%90 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%91 = call i32 @strcat(i8* %90, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
%92 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%93 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%94 = call i32 @strcat(i8* %92, i8* %93)
%95 = load i32, i32* %5
%96 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%97 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%98 = call i32 @strlen(i8* %97)
%99 = call i32 @send(i32 %95, i8* %96, i32 %98, i32 0)
%100 = load i32, i32* %5
%101 = call i32 @close(i32 %100)
br label %25
102: ; preds = %31
%103 = load i32, i32* %8
ret i32 %103
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
%struct.tm = type { i32 }
@.str = [7 x i8] c"accept\00"
@.str.1 = [37 x i8] c"accept!(IPAddress = %s, Port = %hu)\0A\00"
@.str.5 = [21 x i8] c"%Y/%m/%d %H:%M:%S %Z\00"
@.str.6 = [25 x i8] c"%a, %d %b %Y %H:%M:%S %Z\00"
@.str.7 = [9 x i8] c"<html>\0D\0A\00"
@.str.8 = [11 x i8] c" <head>\0D\0A\00"
@.str.9 = [43 x i8] c" <title>HTTP 401 Unauthorized</title>\0D\0A\00"
@.str.10 = [12 x i8] c" </head>\0D\0A\00"
@.str.11 = [11 x i8] c" <body>\0D\0A\00"
@.str.12 = [5 x i8] c" \00"
@.str.13 = [22 x i8] c"HTTP 401 Unauthorized\00"
@.str.14 = [3 x i8] c"\0D\0A\00"
@.str.15 = [12 x i8] c" </body>\0D\0A\00"
@.str.16 = [10 x i8] c"</html>\0D\0A\00"
@.str.17 = [28 x i8] c"HTTP/1.1 401 Unauthorized\0D\0A\00"
@.str.18 = [26 x i8] c"WWW-Authenticate: Basic\0D\0A\00"
@str = [23 x i8] c"----- recv begin -----\00"
@str.19 = [21 x i8] c"----- recv end -----\00"
define i32 @accept_loop(i32 %0) {
%2 = alloca %struct.sockaddr_in
%3 = alloca i32
%4 = alloca [4096 x i8]
%5 = alloca [4096 x i8]
%6 = alloca [4096 x i8]
%7 = alloca [4096 x i8]
%8 = alloca i64
%9 = alloca [128 x i8]
%10 = alloca i64
%11 = alloca [128 x i8]
%12 = bitcast %struct.sockaddr_in* %2 to i8*
%13 = bitcast i32* %3 to i8*
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%16 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%18 = bitcast i64* %8 to i8*
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%20 = bitcast i64* %10 to i8*
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%22 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
store i32 8, i32* %3
%23 = call i32 @accept(i32 %0, %struct.sockaddr* %22, i32* %3)
%24 = icmp slt i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %1
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
br label %30
28: ; preds = %30, %1
%29 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
ret i32 -1
30: ; preds = %25, %30
%31 = phi i32 [ %23, %25 ], [ %67, %30 ]
%32 = load i32, i32* %26
%33 = call i8* @inet_ntoa(i32 %32)
%34 = load i32, i32* %27
%35 = call i32 @ntohs(i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %33, i32 %35)
%37 = call i32 @memset(i8* %14, i32 0, i32 4096)
%38 = call i32 @recv(i32 %31, i8* %14, i32 4096, i32 0)
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%40 = call i32 @puts(i8* %14)
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.19, i64 0, i64 0))
%42 = call i64 @time(i32* null)
store i64 %42, i64* %8
%43 = call %struct.tm* @gmtime(i64* %8)
%44 = call i32 @strftime(i8* %19, i32 128, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), %struct.tm* %43)
%45 = load i64, i64* %8
%46 = add nsw i64 %45, 300
store i64 %46, i64* %10
%47 = call %struct.tm* @gmtime(i64* %10)
%48 = call i32 @strftime(i8* %21, i32 128, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), %struct.tm* %47)
%49 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%50 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%51 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0))
%52 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%53 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
%54 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%55 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0))
%56 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
%57 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0))
%58 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0))
%59 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.17, i64 0, i64 0))
%60 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.18, i64 0, i64 0))
%61 = call i32 @strcpy(i8* %15, i8* %16)
%62 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
%63 = call i32 @strcat(i8* %15, i8* %17)
%64 = call i32 @strlen(i8* %15)
%65 = call i32 @send(i32 %31, i8* %15, i32 %64, i32 0)
%66 = call i32 @close(i32 %31)
store i32 8, i32* %3
%67 = call i32 @accept(i32 %0, %struct.sockaddr* %22, i32* %3)
%68 = icmp slt i32 %67, 0
br i1 %68, label %28, label %30
}