#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, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int 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>Content-Type</title>\r\n");
    strcat(response_body, "  </head>\r\n");
    strcat(response_body, "  <body>\r\n");
    strcat(response_body, "    ");
    strcat(response_body, time_str);
    strcat(response_body, "\r\n");
    strcat(response_body, "  </body>\r\n");
    strcat(response_body, "</html>\r\n");
    strcpy(response_header, "HTTP/1.0 200 OK\r\n");
    strcat(response_header, "Content-Length: ");
    content_length = strlen(response_body);
    sprintf(content_length_str, "%d", content_length);
    strcat(response_header, content_length_str);
    strcat(response_header, "\r\n");
    strcat(response_header, "Content-Type: text/html\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    12a7 <accept_loop+0xa7>
lea    0xd6a(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x28(%rbp)
jmp    157c <accept_loop+0x37c>
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    0xd3b(%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    0xd29(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x1030(%rbp),%rsi
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd22(%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    0xcf4(%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    0xcc3(%rip),%rdx
call   10d0 <strftime@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcc9(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcbf(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcb7(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcc6(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcbf(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcb7(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    -0x40c0(%rbp),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xc83(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xc83(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xc7c(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x3030(%rbp),%rdi
lea    0xc73(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x3030(%rbp),%rdi
lea    0xc72(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x40c4(%rbp)
lea    -0x4150(%rbp),%rdi
mov    -0x40c4(%rbp),%edx
lea    0xc58(%rip),%rsi
call   1120 <sprintf@plt>
lea    -0x3030(%rbp),%rdi
lea    -0x4150(%rbp),%rsi
call   1110 <strcat@plt>
lea    -0x3030(%rbp),%rdi
lea    0xbe6(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x3030(%rbp),%rdi
lea    0xc22(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x2030(%rbp),%rdi
lea    -0x3030(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x2030(%rbp),%rdi
lea    0xbad(%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    126b <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    $0x41b8,%rsp
mov    %edi,%ebp
lea    0x31b0(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   10a0 <memset@plt>
lea    0x21b0(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   10a0 <memset@plt>
lea    0x11b0(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   10a0 <memset@plt>
lea    0x1b0(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   10a0 <memset@plt>
movl   $0x8,0xc(%rsp)
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebp,%ebx
mov    %ebp,%edi
call   1110 <accept@plt>
test   %eax,%eax
js     14f6 <accept_loop+0x2e6>
mov    %eax,%ebp
lea    0x1b0(%rsp),%r14
mov    %ebx,0x1c(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x14(%rsp),%edi
call   1060 <inet_ntoa@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%edi
call   10d0 <ntohs@plt>
lea    0xd3b(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <printf@plt>
lea    0x31b0(%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    0xdfb(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
lea    0xdfe(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10c0 <time@plt>
mov    %rax,0x20(%rsp)
lea    0x20(%rsp),%rdi
call   1100 <gmtime@plt>
lea    0x130(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
lea    0xcdf(%rip),%rdx
mov    %rax,%rcx
call   10e0 <strftime@plt>
mov    0x20(%rsp),%rax
mov    $0x12c,%ecx
add    %rcx,%rax
mov    %rax,0x28(%rsp)
lea    0x28(%rsp),%rdi
call   1100 <gmtime@plt>
lea    0x30(%rsp),%rdi
mov    $0x80,%esi
lea    0xcbf(%rip),%rdx
mov    %rax,%rcx
call   10e0 <strftime@plt>
mov    %r14,%rdi
lea    0xcc6(%rip),%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
lea    0xcc0(%rip),%rsi
call   1120 <strcat@plt>
mov    %r14,%rdi
lea    0xcbc(%rip),%rsi
call   1120 <strcat@plt>
mov    %r14,%rdi
lea    0xccf(%rip),%rsi
call   1120 <strcat@plt>
mov    %r14,%rdi
lea    0xccc(%rip),%rsi
call   1120 <strcat@plt>
mov    %r14,%rdi
lea    0xcc8(%rip),%rsi
call   1120 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1120 <strcat@plt>
mov    %r14,%rdi
lea    0xca0(%rip),%r13
mov    %r13,%rsi
call   1120 <strcat@plt>
mov    %r14,%rdi
lea    0xca1(%rip),%rsi
call   1120 <strcat@plt>
mov    %r14,%rdi
lea    0xc9e(%rip),%rsi
call   1120 <strcat@plt>
lea    0x11b0(%rsp),%r15
mov    %r15,%rdi
lea    0xc91(%rip),%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
lea    0xc94(%rip),%rsi
call   1120 <strcat@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
lea    0xb0(%rsp),%r12
mov    %r12,%rdi
lea    0xc86(%rip),%rsi
mov    %eax,%edx
call   1130 <sprintf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xc62(%rip),%rsi
call   1120 <strcat@plt>
lea    0x21b0(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1120 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1120 <strcat@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
movl   $0x8,0xc(%rsp)
mov    0x1c(%rsp),%edi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1110 <accept@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    12b0 <accept_loop+0xa0>
lea    0xb03(%rip),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%eax
add    $0x41b8,%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 = [34 x i8] c" <title>Content-Type</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 = [3 x i8] c"\0D\0A\00"
@.str.14 = [12 x i8] c" </body>\0D\0A\00"
@.str.15 = [10 x i8] c"</html>\0D\0A\00"
@.str.16 = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
@.str.17 = [17 x i8] c"Content-Length: \00"
@.str.18 = [3 x i8] c"%d\00"
@.str.19 = [26 x i8] c"Content-Type: text/html\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 %115
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 ([34 x i8], [34 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 = getelementptr inbounds [128 x i8], [128 x i8]* %15, i64 0, i64 0
%77 = call i32 @strcat(i8* %75, i8* %76)
%78 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%79 = call i32 @strcat(i8* %78, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%80 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%81 = call i32 @strcat(i8* %80, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%82 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%83 = call i32 @strcat(i8* %82, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%84 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%85 = call i32 @strcpy(i8* %84, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.16, i64 0, i64 0))
%86 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%87 = call i32 @strcat(i8* %86, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.17, i64 0, i64 0))
%88 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%89 = call i32 @strlen(i8* %88)
store i32 %89, i32* %16
%90 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%91 = load i32, i32* %16
%92 = call i32 @sprintf(i8* %90, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0), i32 %91)
%93 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%94 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%95 = call i32 @strcat(i8* %93, i8* %94)
%96 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%97 = call i32 @strcat(i8* %96, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%98 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%99 = call i32 @strcat(i8* %98, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.19, i64 0, i64 0))
%100 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%101 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%102 = call i32 @strcpy(i8* %100, i8* %101)
%103 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%104 = call i32 @strcat(i8* %103, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%105 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%106 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%107 = call i32 @strcat(i8* %105, i8* %106)
%108 = load i32, i32* %5
%109 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%110 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%111 = call i32 @strlen(i8* %110)
%112 = call i32 @send(i32 %108, i8* %109, i32 %111, i32 0)
%113 = load i32, i32* %5
%114 = call i32 @close(i32 %113)
br label %25
115: ; preds = %31
%116 = load i32, i32* %8
ret i32 %116
}

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 = [34 x i8] c" <title>Content-Type</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 = [3 x i8] c"\0D\0A\00"
@.str.14 = [12 x i8] c" </body>\0D\0A\00"
@.str.15 = [10 x i8] c"</html>\0D\0A\00"
@.str.16 = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
@.str.17 = [17 x i8] c"Content-Length: \00"
@.str.18 = [3 x i8] c"%d\00"
@.str.19 = [26 x i8] c"Content-Type: text/html\0D\0A\00"
@str = [23 x i8] c"----- recv begin -----\00"
@str.20 = [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 [128 x i8]
%11 = alloca i64
%12 = alloca [128 x i8]
%13 = bitcast %struct.sockaddr_in* %2 to i8*
%14 = bitcast i32* %3 to i8*
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%19 = bitcast i64* %8 to i8*
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%22 = bitcast i64* %11 to i8*
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %12, i64 0, i64 0
%24 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
store i32 8, i32* %3
%25 = call i32 @accept(i32 %0, %struct.sockaddr* %24, i32* %3)
%26 = icmp slt i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %1
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
br label %32
30: ; preds = %32, %1
%31 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
ret i32 -1
32: ; preds = %27, %32
%33 = phi i32 [ %25, %27 ], [ %74, %32 ]
%34 = load i32, i32* %28
%35 = call i8* @inet_ntoa(i32 %34)
%36 = load i32, i32* %29
%37 = call i32 @ntohs(i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %35, i32 %37)
%39 = call i32 @memset(i8* %15, i32 0, i32 4096)
%40 = call i32 @recv(i32 %33, i8* %15, i32 4096, i32 0)
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%42 = call i32 @puts(i8* %15)
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.20, i64 0, i64 0))
%44 = call i64 @time(i32* null)
store i64 %44, i64* %8
%45 = call %struct.tm* @gmtime(i64* %8)
%46 = call i32 @strftime(i8* %20, i32 128, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), %struct.tm* %45)
%47 = load i64, i64* %8
%48 = add nsw i64 %47, 300
store i64 %48, i64* %11
%49 = call %struct.tm* @gmtime(i64* %11)
%50 = call i32 @strftime(i8* %23, i32 128, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), %struct.tm* %49)
%51 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%52 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%53 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
%54 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%55 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
%56 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%57 = call i32 @strcat(i8* %18, i8* %20)
%58 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%59 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%60 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0))
%61 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.16, i64 0, i64 0))
%62 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.17, i64 0, i64 0))
%63 = call i32 @strlen(i8* %18)
%64 = call i32 @sprintf(i8* %21, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0), i32 %63)
%65 = call i32 @strcat(i8* %17, i8* %21)
%66 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%67 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.19, i64 0, i64 0))
%68 = call i32 @strcpy(i8* %16, i8* %17)
%69 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%70 = call i32 @strcat(i8* %16, i8* %18)
%71 = call i32 @strlen(i8* %16)
%72 = call i32 @send(i32 %33, i8* %16, i32 %71, i32 0)
%73 = call i32 @close(i32 %33)
store i32 8, i32* %3
%74 = call i32 @accept(i32 %0, %struct.sockaddr* %24, i32* %3)
%75 = icmp slt i32 %74, 0
br i1 %75, label %30, label %32
}