#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 int /*<<< orphan*/ 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*/ client_addr;

/* Variables and functions */
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ close(int);
struct tm *gmtime(int /*<<< orphan*/ *);
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 *);
int /*<<< orphan*/ 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];
  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);
    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");
    strcat(response_header, "Set-Cookie: key1=value1\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    $0x4160,%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    1548 <accept_loop+0x348>
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    %eax,-0x4034(%rbp)
lea    -0x4034(%rbp),%rdi
call   10f0 <gmtime@plt>
mov    %rax,-0x4040(%rbp)
lea    -0x40c0(%rbp),%rdi
mov    -0x4040(%rbp),%rcx
mov    $0x80,%esi
lea    0xcf5(%rip),%rdx
call   10d0 <strftime@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcf7(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x4030(%rbp),%rdi
lea    0xced(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xce5(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcf4(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xced(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xce5(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    -0x40c0(%rbp),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xd31(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcb1(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0xcaa(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x3030(%rbp),%rdi
lea    0xca1(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x3030(%rbp),%rdi
lea    0xca0(%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    0xc86(%rip),%rsi
call   1120 <sprintf@plt>
lea    -0x3030(%rbp),%rdi
lea    -0x4150(%rbp),%rsi
call   1110 <strcat@plt>
lea    -0x3030(%rbp),%rdi
lea    0xc94(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x3030(%rbp),%rdi
lea    0xc50(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x3030(%rbp),%rdi
lea    0xc57(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x2030(%rbp),%rdi
lea    -0x3030(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x2030(%rbp),%rdi
lea    0xc48(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x2030(%rbp),%rdi
lea    -0x4030(%rbp),%rsi
call   1110 <strcat@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x415c(%rbp)
lea    -0x2030(%rbp),%rax
mov    %rax,-0x4158(%rbp)
lea    -0x2030(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x415c(%rbp),%edi
mov    -0x4158(%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    $0x4160,%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,%ebp
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,0xc(%rsp)
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %ebp,%ebx
mov    %ebp,%edi
call   1110 <accept@plt>
test   %eax,%eax
js     14cc <accept_loop+0x2bc>
mov    %eax,%ebp
lea    0x120(%rsp),%r15
mov    %ebx,0x18(%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    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    0xdfc(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
lea    0xdff(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10c0 <time@plt>
mov    %eax,0x1c(%rsp)
lea    0x1c(%rsp),%rdi
call   1100 <gmtime@plt>
lea    0xa0(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
lea    0xce0(%rip),%rdx
mov    %rax,%rcx
call   10e0 <strftime@plt>
mov    %r15,%rdi
lea    0xce3(%rip),%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
lea    0xcdd(%rip),%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xcd9(%rip),%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xcec(%rip),%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xce9(%rip),%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xce5(%rip),%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xd3d(%rip),%r13
mov    %r13,%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xcbe(%rip),%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
lea    0xcbb(%rip),%rsi
call   1120 <strcat@plt>
lea    0x1120(%rsp),%r14
mov    %r14,%rdi
lea    0xcae(%rip),%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
lea    0xcb1(%rip),%rsi
call   1120 <strcat@plt>
mov    %r15,%rdi
call   1070 <strlen@plt>
lea    0x20(%rsp),%r12
mov    %r12,%rdi
lea    0xca6(%rip),%rsi
mov    %eax,%edx
call   1130 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1120 <strcat@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1120 <strcat@plt>
mov    %r14,%rdi
lea    0xc82(%rip),%rsi
call   1120 <strcat@plt>
mov    %r14,%rdi
lea    0xc8d(%rip),%rsi
call   1120 <strcat@plt>
lea    0x2120(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1120 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%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    0x18(%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    0xb2d(%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 = [9 x i8] c"<html>\0D\0A\00"
@.str.7 = [11 x i8] c" <head>\0D\0A\00"
@.str.8 = [34 x i8] c" <title>Content-Type</title>\0D\0A\00"
@.str.9 = [12 x i8] c" </head>\0D\0A\00"
@.str.10 = [11 x i8] c" <body>\0D\0A\00"
@.str.11 = [5 x i8] c" \00"
@.str.12 = [3 x i8] c"\0D\0A\00"
@.str.13 = [12 x i8] c" </body>\0D\0A\00"
@.str.14 = [10 x i8] c"</html>\0D\0A\00"
@.str.15 = [18 x i8] c"HTTP/1.0 200 OK\0D\0A\00"
@.str.16 = [17 x i8] c"Content-Length: \00"
@.str.17 = [3 x i8] c"%d\00"
@.str.18 = [26 x i8] c"Content-Type: text/html\0D\0A\00"
@.str.19 = [26 x i8] c"Set-Cookie: key1=value1\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 i32
%14 = alloca %struct.tm*
%15 = alloca [128 x i8]
%16 = alloca i32
%17 = alloca [128 x i8]
store i32 %0, i32* %2
store i32 0, i32* %8
%18 = bitcast [4096 x i8]* %9 to i8*
%19 = bitcast [4096 x i8]* %10 to i8*
%20 = bitcast [4096 x i8]* %11 to i8*
%21 = bitcast [4096 x i8]* %12 to i8*
store i32 0, i32* %16
br label %22
22: ; preds = %1, %30
store i32 8, i32* %4
%23 = load i32, i32* %2
%24 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%25 = call i32 @accept(i32 %23, %struct.sockaddr* %24, i32* %4)
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %8
br label %108
30: ; preds = %22
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
%32 = load i32, i32* %31
%33 = call i8* @inet_ntoa(i32 %32)
store i8* %33, i8** %6
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%35 = load i32, i32* %34
%36 = call i32 @ntohs(i32 %35)
store i32 %36, i32* %7
%37 = load i8*, i8** %6
%38 = load i32, i32* %7
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %37, i32 %38)
%40 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%41 = call i32 @memset(i8* %40, i32 0, i32 4096)
%42 = load i32, i32* %5
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%44 = call i32 @recv(i32 %42, i8* %43, i32 4096, i32 0)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%46 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%49 = call i32 @time(i32* null)
store i32 %49, i32* %13
%50 = call %struct.tm* @gmtime(i32* %13)
store %struct.tm* %50, %struct.tm** %14
%51 = getelementptr inbounds [128 x i8], [128 x i8]* %15, i64 0, i64 0
%52 = load %struct.tm*, %struct.tm** %14
%53 = call i32 @strftime(i8* %51, i32 128, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), %struct.tm* %52)
%54 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%55 = call i32 @strcpy(i8* %54, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%56 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%57 = call i32 @strcat(i8* %56, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%58 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%59 = call i32 @strcat(i8* %58, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.8, i64 0, i64 0))
%60 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%61 = call i32 @strcat(i8* %60, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%62 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%63 = call i32 @strcat(i8* %62, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%64 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%65 = call i32 @strcat(i8* %64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%66 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%67 = getelementptr inbounds [128 x i8], [128 x i8]* %15, i64 0, i64 0
%68 = call i32 @strcat(i8* %66, i8* %67)
%69 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%70 = call i32 @strcat(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, 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 ([12 x i8], [12 x i8]* @.str.13, 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 ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0))
%75 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%76 = call i32 @strcpy(i8* %75, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0))
%77 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%78 = call i32 @strcat(i8* %77, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0))
%79 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%80 = call i32 @strlen(i8* %79)
store i32 %80, i32* %16
%81 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%82 = load i32, i32* %16
%83 = call i32 @sprintf(i8* %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0), i32 %82)
%84 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%85 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%86 = call i32 @strcat(i8* %84, i8* %85)
%87 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%88 = call i32 @strcat(i8* %87, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%89 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%90 = call i32 @strcat(i8* %89, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.18, i64 0, i64 0))
%91 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%92 = call i32 @strcat(i8* %91, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.19, i64 0, i64 0))
%93 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%94 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%95 = call i32 @strcpy(i8* %93, i8* %94)
%96 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%97 = call i32 @strcat(i8* %96, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%98 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%99 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%100 = call i32 @strcat(i8* %98, i8* %99)
%101 = load i32, i32* %5
%102 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%103 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%104 = call i32 @strlen(i8* %103)
%105 = call i32 @send(i32 %101, i8* %102, i32 %104, i32 0)
%106 = load i32, i32* %5
%107 = call i32 @close(i32 %106)
br label %22
108: ; preds = %28
%109 = load i32, i32* %8
ret i32 %109
}

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