#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_3__ TYPE_1__;

/* 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;
struct TYPE_3__ {
  int length;
  int /*<<< orphan*/ data;
};
typedef TYPE_1__ BUF_MEM;
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_f_base64();
int /*<<< orphan*/ BIO_flush(int /*<<< orphan*/ *);
int /*<<< orphan*/ BIO_free_all(int /*<<< orphan*/ *);
int /*<<< orphan*/ BIO_get_mem_ptr(int /*<<< orphan*/ *, TYPE_1__ **);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ *BIO_push(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ BIO_s_mem();
int /*<<< orphan*/ BIO_write(int /*<<< orphan*/ *, char *, int);
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ close(int);
struct tm *gmtime(scalar_t__ *);
char *inet_ntoa(int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, int /*<<< orphan*/, int);
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*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, 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];
  char basic_authorization_header_str[] = "Authorization: Basic ";
  char *s = NULL;
  char *e = NULL;
  char basic_str[256] = {0};
  BIO *base64 = NULL;
  BIO *mem = NULL;
  BUF_MEM *bptr = NULL;
  char buf[1024] = {0};
  base64 = BIO_new(BIO_f_base64());
  mem = BIO_new(BIO_s_mem());
  base64 = BIO_push(base64, mem);
  BIO_write(base64, "testuser:test123", strlen("testuser:test123"));
  BIO_flush(base64);
  BIO_get_mem_ptr(base64, &bptr);
  memcpy(buf, bptr->data, bptr->length - 1);
  buf[bptr->length - 1] = '\0';
  printf("buf = [%s]\n", buf);
  BIO_free_all(base64);
  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");
    s = strstr(recv_buf, basic_authorization_header_str);
    if (s) {
      s = s + strlen(basic_authorization_header_str);
      e = strstr(s, "\r");
      if (e) {
        strncpy(basic_str, s, e - s);
        basic_str[e - s] = '\0';
        printf("basic_str = [%s]\n", basic_str);
      }
    }
    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);
    if (strcmp(basic_str, buf) == 0) {
      strcpy(response_body, "<html>\r\n");
      strcat(response_body, "  <head>\r\n");
      strcat(response_body, "    <title>HTTP 200 OK</title>\r\n");
      strcat(response_body, "  </head>\r\n");
      strcat(response_body, "  <body>\r\n");
      strcat(response_body, "    ");
      strcat(response_body, "HTTP 200 OK");
      strcat(response_body, "\r\n");
      strcat(response_body, "  </body>\r\n");
      strcat(response_body, "</html>\r\n");
      strcpy(response_header, "HTTP/1.1 200 OK\r\n");
    } else {
      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    $0x4750,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x28(%rbp)
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   10c0 <memset@plt>
lea    -0x2030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   10c0 <memset@plt>
lea    -0x3030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   10c0 <memset@plt>
lea    -0x4030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   10c0 <memset@plt>
movl   $0x0,-0x40c4(%rbp)
mov    0xcde(%rip),%rax
mov    %rax,-0x4200(%rbp)
mov    0xcd8(%rip),%rax
mov    %rax,-0x41f8(%rbp)
mov    0xcd3(%rip),%eax
mov    %eax,-0x41f0(%rbp)
mov    0xcca(%rip),%ax
mov    %ax,-0x41ec(%rbp)
movq   $0x0,-0x4208(%rbp)
movq   $0x0,-0x4210(%rbp)
lea    -0x4310(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   10c0 <memset@plt>
movq   $0x0,-0x4318(%rbp)
movq   $0x0,-0x4320(%rbp)
movq   $0x0,-0x4328(%rbp)
lea    -0x4730(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   10c0 <memset@plt>
mov    $0x0,%al
call   1090 <BIO_f_base64@plt>
mov    %eax,%edi
call   1110 <BIO_new@plt>
mov    %rax,-0x4318(%rbp)
mov    $0x0,%al
call   11b0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1110 <BIO_new@plt>
mov    %rax,-0x4320(%rbp)
mov    -0x4318(%rbp),%rdi
mov    -0x4320(%rbp),%rsi
call   1070 <BIO_push@plt>
mov    %rax,-0x4318(%rbp)
mov    -0x4318(%rbp),%rax
mov    %rax,-0x4738(%rbp)
lea    0xc0f(%rip),%rdi
call   1080 <strlen@plt>
mov    -0x4738(%rbp),%rdi
mov    %eax,%edx
lea    0xbfa(%rip),%rsi
call   11a0 <BIO_write@plt>
mov    -0x4318(%rbp),%rdi
call   11d0 <BIO_flush@plt>
mov    -0x4318(%rbp),%rdi
lea    -0x4328(%rbp),%rsi
call   1190 <BIO_get_mem_ptr@plt>
lea    -0x4730(%rbp),%rdi
mov    -0x4328(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x4328(%rbp),%rax
mov    (%rax),%edx
sub    $0x1,%edx
call   10f0 <memcpy@plt>
mov    -0x4328(%rbp),%rax
mov    (%rax),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x4730(%rbp,%rax,1)
lea    -0x4730(%rbp),%rsi
lea    0xba1(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0x4318(%rbp),%rdi
call   1170 <BIO_free_all@plt>
movl   $0x8,-0x14(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1160 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    14d5 <accept_loop+0x225>
lea    0xb6f(%rip),%rdi
call   1140 <perror@plt>
movl   $0xffffffff,-0x28(%rbp)
jmp    1912 <accept_loop+0x662>
mov    -0xc(%rbp),%edi
call   1060 <inet_ntoa@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
call   1120 <ntohs@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    0xb40(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   10c0 <memset@plt>
mov    -0x18(%rbp),%edi
lea    -0x1030(%rbp),%rsi
mov    $0x1000,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    0xb2e(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    -0x1030(%rbp),%rsi
lea    0xb31(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    0xb27(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    -0x1030(%rbp),%rdi
lea    -0x4200(%rbp),%rsi
call   11c0 <strstr@plt>
mov    %rax,-0x4208(%rbp)
cmpq   $0x0,-0x4208(%rbp)
je     1634 <accept_loop+0x384>
mov    -0x4208(%rbp),%rax
mov    %rax,-0x4740(%rbp)
lea    -0x4200(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x4740(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x4208(%rbp)
mov    -0x4208(%rbp),%rdi
lea    0xad0(%rip),%rsi
call   11c0 <strstr@plt>
mov    %rax,-0x4210(%rbp)
cmpq   $0x0,-0x4210(%rbp)
je     162f <accept_loop+0x37f>
lea    -0x4310(%rbp),%rdi
mov    -0x4208(%rbp),%rsi
mov    -0x4210(%rbp),%rax
mov    -0x4208(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    -0x4210(%rbp),%rax
mov    -0x4208(%rbp),%rcx
sub    %rcx,%rax
movb   $0x0,-0x4310(%rbp,%rax,1)
lea    -0x4310(%rbp),%rsi
lea    0xa6b(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    1634 <accept_loop+0x384>
xor    %eax,%eax
mov    %eax,%edi
call   1100 <time@plt>
mov    %rax,-0x4038(%rbp)
lea    -0x4038(%rbp),%rdi
call   1150 <gmtime@plt>
mov    %rax,-0x4040(%rbp)
lea    -0x40c0(%rbp),%rdi
mov    -0x4040(%rbp),%rcx
mov    $0x80,%esi
lea    0xa34(%rip),%rdx
call   1130 <strftime@plt>
mov    -0x4038(%rbp),%rax
add    $0x12c,%rax
mov    %rax,-0x4158(%rbp)
lea    -0x4158(%rbp),%rdi
call   1150 <gmtime@plt>
mov    %rax,-0x4160(%rbp)
lea    -0x41e0(%rbp),%rdi
mov    -0x4160(%rbp),%rcx
mov    $0x80,%esi
lea    0xa03(%rip),%rdx
call   1130 <strftime@plt>
lea    -0x4310(%rbp),%rdi
lea    -0x4730(%rbp),%rsi
call   10e0 <strcmp@plt>
cmp    $0x0,%rax
jne    17af <accept_loop+0x4ff>
lea    -0x4030(%rbp),%rdi
lea    0x9ec(%rip),%rsi
call   1050 <strcpy@plt>
lea    -0x4030(%rbp),%rdi
lea    0x9e2(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x9da(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x9e8(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x9e1(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x9d9(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x9cb(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x9a5(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x9b1(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x9aa(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x3030(%rbp),%rdi
lea    0x9a1(%rip),%rsi
call   1050 <strcpy@plt>
jmp    1893 <accept_loop+0x5e3>
lea    -0x4030(%rbp),%rdi
lea    0x916(%rip),%rsi
call   1050 <strcpy@plt>
lea    -0x4030(%rbp),%rdi
lea    0x90c(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x975(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x912(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x90b(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x903(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x954(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x8cf(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x8db(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x4030(%rbp),%rdi
lea    0x8d4(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x3030(%rbp),%rdi
lea    0x91e(%rip),%rsi
call   1050 <strcpy@plt>
lea    -0x3030(%rbp),%rdi
lea    0x927(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x2030(%rbp),%rdi
lea    -0x3030(%rbp),%rsi
call   1050 <strcpy@plt>
lea    -0x2030(%rbp),%rdi
lea    0x85d(%rip),%rsi
call   1180 <strcat@plt>
lea    -0x2030(%rbp),%rdi
lea    -0x4030(%rbp),%rsi
call   1180 <strcat@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x474c(%rbp)
lea    -0x2030(%rbp),%rax
mov    %rax,-0x4748(%rbp)
lea    -0x2030(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x474c(%rbp),%edi
mov    -0x4748(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10a0 <send@plt>
mov    -0x18(%rbp),%edi
call   10d0 <close@plt>
jmp    1499 <accept_loop+0x1e9>
mov    -0x28(%rbp),%eax
add    $0x4750,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accept_loop>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4658,%rsp
mov    %edi,%r15d
lea    0x3650(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   10e0 <memset@plt>
lea    0x2650(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   10e0 <memset@plt>
lea    0x650(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   10e0 <memset@plt>
lea    0x1650(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   10e0 <memset@plt>
movaps 0xcc5(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movabs $0x20636973614220,%rax
mov    %rax,0x3e(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x250(%rsp),%r14
mov    $0x400,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   10e0 <memset@plt>
xor    %eax,%eax
call   10a0 <BIO_f_base64@plt>
mov    %eax,%edi
call   1130 <BIO_new@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   11d0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1130 <BIO_new@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
call   1080 <BIO_push@plt>
mov    %rax,%rbp
lea    0xbf9(%rip),%rbx
mov    %rbx,%rdi
call   1090 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   11c0 <BIO_write@plt>
mov    %rbp,%rdi
call   11f0 <BIO_flush@plt>
lea    0x8(%rsp),%rsi
mov    %rbp,%rdi
call   11b0 <BIO_get_mem_ptr@plt>
mov    0x8(%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
add    $0xffffffff,%edx
mov    %r14,%rdi
call   1110 <memcpy@plt>
mov    0x8(%rsp),%rax
movslq (%rax),%rax
movb   $0x0,-0x1(%rax,%r14,1)
lea    0xbb6(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   10d0 <printf@plt>
mov    %rbp,%rdi
call   1190 <BIO_free_all@plt>
movl   $0x8,0x4(%rsp)
lea    0x10(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %r15d,0x1c(%rsp)
mov    %r15d,%edi
call   1180 <accept@plt>
test   %eax,%eax
jns    14c9 <accept_loop+0x1f9>
lea    0xb86(%rip),%rdi
call   1160 <perror@plt>
mov    $0xffffffff,%eax
add    $0x4658,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r15d
lea    0x1650(%rsp),%r12
lea    0xc02(%rip),%r14
jmp    15e8 <accept_loop+0x318>
lea    0xc3d(%rip),%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
lea    0xbde(%rip),%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
lea    0xbdb(%rip),%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
lea    0xbd7(%rip),%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
lea    0xc2c(%rip),%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
mov    %rbp,%r14
mov    %rbp,%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
lea    0xbbc(%rip),%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
lea    0xbb9(%rip),%rsi
call   11a0 <strcat@plt>
lea    0x650(%rsp),%rbp
mov    %rbp,%rdi
lea    0xbff(%rip),%rsi
call   1050 <strcpy@plt>
mov    %rbp,%rdi
lea    0xc0c(%rip),%rsi
call   11a0 <strcat@plt>
lea    0x2650(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   11a0 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   11a0 <strcat@plt>
mov    %rbx,%rdi
call   1090 <strlen@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <send@plt>
mov    %r15d,%edi
call   10f0 <close@plt>
movl   $0x8,0x4(%rsp)
mov    0x1c(%rsp),%edi
lea    0x10(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   1180 <accept@plt>
mov    %eax,%r15d
test   %eax,%eax
js     14a6 <accept_loop+0x1d6>
mov    %r14,%rbp
mov    0x14(%rsp),%edi
call   1070 <inet_ntoa@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%edi
call   1140 <ntohs@plt>
lea    0xa33(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10d0 <printf@plt>
lea    0x3650(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   10e0 <memset@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x1000,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    0xb58(%rip),%rdi
call   1060 <puts@plt>
mov    %rbx,%rdi
call   1060 <puts@plt>
lea    0xb5b(%rip),%rdi
call   1060 <puts@plt>
mov    %rbx,%rdi
lea    0x30(%rsp),%rsi
call   11e0 <strstr@plt>
test   %rax,%rax
je     16c2 <accept_loop+0x3f2>
mov    %rax,%r13
lea    0x30(%rsp),%rdi
call   1090 <strlen@plt>
cltq
add    %rax,%r13
mov    %r13,%rdi
mov    $0xd,%esi
call   10c0 <strchr@plt>
test   %rax,%rax
je     16c2 <accept_loop+0x3f2>
mov    %rax,%r14
sub    %r13,%r14
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r14d,%edx
call   1040 <strncpy@plt>
movb   $0x0,0x50(%rsp,%r14,1)
lea    0x9a7(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10d0 <printf@plt>
xor    %edi,%edi
call   1120 <time@plt>
mov    %rax,0x20(%rsp)
lea    0x20(%rsp),%rdi
call   1170 <gmtime@plt>
lea    0x1d0(%rsp),%rdi
mov    $0x80,%esi
lea    0x985(%rip),%rdx
mov    %rax,%rcx
call   1150 <strftime@plt>
mov    0x20(%rsp),%rax
mov    $0x12c,%ecx
add    %rcx,%rax
mov    %rax,0x28(%rsp)
lea    0x28(%rsp),%rdi
call   1170 <gmtime@plt>
lea    0x150(%rsp),%rdi
mov    $0x80,%esi
lea    0x962(%rip),%rdx
mov    %rax,%rcx
call   1150 <strftime@plt>
lea    0x50(%rsp),%rdi
lea    0x250(%rsp),%rsi
call   1100 <strcmp@plt>
mov    %rax,%rbx
mov    %r12,%rdi
lea    0x954(%rip),%rsi
call   1050 <strcpy@plt>
mov    %r12,%rdi
lea    0x94e(%rip),%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
test   %rbx,%rbx
jne    14e0 <accept_loop+0x210>
lea    0x941(%rip),%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
lea    0x953(%rip),%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
lea    0x950(%rip),%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
lea    0x94c(%rip),%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
lea    0x942(%rip),%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
mov    %rbp,%r14
mov    %rbp,%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
lea    0x931(%rip),%rsi
call   11a0 <strcat@plt>
mov    %r12,%rdi
lea    0x92e(%rip),%rsi
call   11a0 <strcat@plt>
lea    0x650(%rsp),%rbp
mov    %rbp,%rdi
lea    0x921(%rip),%rsi
call   1050 <strcpy@plt>
jmp    157a <accept_loop+0x2aa>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
%struct.tm = type { i32 }
%struct.TYPE_3__ = type { i32, i32 }
%struct.sockaddr = type { i32 }
@__const.accept_loop.basic_authorization_header_str = [22 x i8] c"Authorization: Basic \00"
@.str = [17 x i8] c"testuser:test123\00"
@.str.1 = [12 x i8] c"buf = [%s]\0A\00"
@.str.2 = [7 x i8] c"accept\00"
@.str.3 = [37 x i8] c"accept!(IPAddress = %s, Port = %hu)\0A\00"
@.str.4 = [24 x i8] c"----- recv begin -----\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [22 x i8] c"----- recv end -----\0A\00"
@.str.7 = [2 x i8] c"\0D\00"
@.str.8 = [18 x i8] c"basic_str = [%s]\0A\00"
@.str.9 = [21 x i8] c"%Y/%m/%d %H:%M:%S %Z\00"
@.str.10 = [25 x i8] c"%a, %d %b %Y %H:%M:%S %Z\00"
@.str.11 = [9 x i8] c"<html>\0D\0A\00"
@.str.12 = [11 x i8] c" <head>\0D\0A\00"
@.str.13 = [33 x i8] c" <title>HTTP 200 OK</title>\0D\0A\00"
@.str.14 = [12 x i8] c" </head>\0D\0A\00"
@.str.15 = [11 x i8] c" <body>\0D\0A\00"
@.str.16 = [5 x i8] c" \00"
@.str.17 = [12 x i8] c"HTTP 200 OK\00"
@.str.18 = [3 x i8] c"\0D\0A\00"
@.str.19 = [12 x i8] c" </body>\0D\0A\00"
@.str.20 = [10 x i8] c"</html>\0D\0A\00"
@.str.21 = [18 x i8] c"HTTP/1.1 200 OK\0D\0A\00"
@.str.22 = [43 x i8] c" <title>HTTP 401 Unauthorized</title>\0D\0A\00"
@.str.23 = [22 x i8] c"HTTP 401 Unauthorized\00"
@.str.24 = [28 x i8] c"HTTP/1.1 401 Unauthorized\0D\0A\00"
@.str.25 = [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]
%21 = alloca [22 x i8]
%22 = alloca i8*
%23 = alloca i8*
%24 = alloca [256 x i8]
%25 = alloca i32*
%26 = alloca i32*
%27 = alloca %struct.TYPE_3__*
%28 = alloca [1024 x i8]
store i32 %0, i32* %2
store i32 0, i32* %8
%29 = bitcast [4096 x i8]* %9 to i8*
%30 = bitcast [4096 x i8]* %10 to i8*
%31 = bitcast [4096 x i8]* %11 to i8*
%32 = bitcast [4096 x i8]* %12 to i8*
store i32 0, i32* %16
%33 = bitcast [22 x i8]* %21 to i8*
store i8* null, i8** %22
store i8* null, i8** %23
%34 = bitcast [256 x i8]* %24 to i8*
store i32* null, i32** %25
store i32* null, i32** %26
store %struct.TYPE_3__* null, %struct.TYPE_3__** %27
%35 = bitcast [1024 x i8]* %28 to i8*
%36 = call i32 (...) @BIO_f_base64()
%37 = call i32* @BIO_new(i32 %36)
store i32* %37, i32** %25
%38 = call i32 (...) @BIO_s_mem()
%39 = call i32* @BIO_new(i32 %38)
store i32* %39, i32** %26
%40 = load i32*, i32** %25
%41 = load i32*, i32** %26
%42 = call i32* @BIO_push(i32* %40, i32* %41)
store i32* %42, i32** %25
%43 = load i32*, i32** %25
%44 = call i32 @strlen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%45 = call i32 @BIO_write(i32* %43, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %44)
%46 = load i32*, i32** %25
%47 = call i32 @BIO_flush(i32* %46)
%48 = load i32*, i32** %25
%49 = call i32 @BIO_get_mem_ptr(i32* %48, %struct.TYPE_3__** %27)
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %28, i64 0, i64 0
%51 = load %struct.TYPE_3__*, %struct.TYPE_3__** %27
%52 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %51, i32 0, i32 1
%53 = load i32, i32* %52
%54 = load %struct.TYPE_3__*, %struct.TYPE_3__** %27
%55 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %54, i32 0, i32 0
%56 = load i32, i32* %55
%57 = sub nsw i32 %56, 1
%58 = call i32 @memcpy(i8* %50, i32 %53, i32 %57)
%59 = load %struct.TYPE_3__*, %struct.TYPE_3__** %27
%60 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %59, i32 0, i32 0
%61 = load i32, i32* %60
%62 = sub nsw i32 %61, 1
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %28, i64 0, i64 %63
store i8 0, i8* %64
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %28, i64 0, i64 0
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %65)
%67 = load i32*, i32** %25
%68 = call i32 @BIO_free_all(i32* %67)
br label %69
69: ; preds = %1, %194
store i32 8, i32* %4
%70 = load i32, i32* %2
%71 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%72 = call i32 @accept(i32 %70, %struct.sockaddr* %71, i32* %4)
store i32 %72, i32* %5
%73 = load i32, i32* %5
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %69
%76 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %8
br label %210
77: ; preds = %69
%78 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
%79 = load i32, i32* %78
%80 = call i8* @inet_ntoa(i32 %79)
store i8* %80, i8** %6
%81 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%82 = load i32, i32* %81
%83 = call i32 @ntohs(i32 %82)
store i32 %83, i32* %7
%84 = load i8*, i8** %6
%85 = load i32, i32* %7
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %84, i32 %85)
%87 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%88 = call i32 @memset(i8* %87, i32 0, i32 4096)
%89 = load i32, i32* %5
%90 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%91 = call i32 @recv(i32 %89, i8* %90, i32 4096, i32 0)
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%93 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %93)
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%96 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%97 = getelementptr inbounds [22 x i8], [22 x i8]* %21, i64 0, i64 0
%98 = call i8* @strstr(i8* %96, i8* %97)
store i8* %98, i8** %22
%99 = load i8*, i8** %22
%100 = icmp ne i8* %99, null
br i1 %100, label %101, label %130
101: ; preds = %77
%102 = load i8*, i8** %22
%103 = getelementptr inbounds [22 x i8], [22 x i8]* %21, i64 0, i64 0
%104 = call i32 @strlen(i8* %103)
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8, i8* %102, i64 %105
store i8* %106, i8** %22
%107 = load i8*, i8** %22
%108 = call i8* @strstr(i8* %107, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i8* %108, i8** %23
%109 = load i8*, i8** %23
%110 = icmp ne i8* %109, null
br i1 %110, label %111, label %129
111: ; preds = %101
%112 = getelementptr inbounds [256 x i8], [256 x i8]* %24, i64 0, i64 0
%113 = load i8*, i8** %22
%114 = load i8*, i8** %23
%115 = load i8*, i8** %22
%116 = ptrtoint i8* %114 to i64
%117 = ptrtoint i8* %115 to i64
%118 = sub i64 %116, %117
%119 = trunc i64 %118 to i32
%120 = call i32 @strncpy(i8* %112, i8* %113, i32 %119)
%121 = load i8*, i8** %23
%122 = load i8*, i8** %22
%123 = ptrtoint i8* %121 to i64
%124 = ptrtoint i8* %122 to i64
%125 = sub i64 %123, %124
%126 = getelementptr inbounds [256 x i8], [256 x i8]* %24, i64 0, i64 %125
store i8 0, i8* %126
%127 = getelementptr inbounds [256 x i8], [256 x i8]* %24, i64 0, i64 0
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8* %127)
br label %129
129: ; preds = %111, %101
br label %130
130: ; preds = %129, %77
%131 = call i64 @time(i32* null)
store i64 %131, i64* %13
%132 = call %struct.tm* @gmtime(i64* %13)
store %struct.tm* %132, %struct.tm** %14
%133 = getelementptr inbounds [128 x i8], [128 x i8]* %15, i64 0, i64 0
%134 = load %struct.tm*, %struct.tm** %14
%135 = call i32 @strftime(i8* %133, i32 128, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), %struct.tm* %134)
%136 = load i64, i64* %13
%137 = add nsw i64 %136, 300
store i64 %137, i64* %18
%138 = call %struct.tm* @gmtime(i64* %18)
store %struct.tm* %138, %struct.tm** %19
%139 = getelementptr inbounds [128 x i8], [128 x i8]* %20, i64 0, i64 0
%140 = load %struct.tm*, %struct.tm** %19
%141 = call i32 @strftime(i8* %139, i32 128, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), %struct.tm* %140)
%142 = getelementptr inbounds [256 x i8], [256 x i8]* %24, i64 0, i64 0
%143 = getelementptr inbounds [1024 x i8], [1024 x i8]* %28, i64 0, i64 0
%144 = call i64 @strcmp(i8* %142, i8* %143)
%145 = icmp eq i64 %144, 0
br i1 %145, label %146, label %169
146: ; preds = %130
%147 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%148 = call i32 @strcpy(i8* %147, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
%149 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%150 = call i32 @strcat(i8* %149, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
%151 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%152 = call i32 @strcat(i8* %151, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0))
%153 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%154 = call i32 @strcat(i8* %153, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%155 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%156 = call i32 @strcat(i8* %155, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
%157 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%158 = call i32 @strcat(i8* %157, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%159 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%160 = call i32 @strcat(i8* %159, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0))
%161 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%162 = call i32 @strcat(i8* %161, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0))
%163 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%164 = call i32 @strcat(i8* %163, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.19, i64 0, i64 0))
%165 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%166 = call i32 @strcat(i8* %165, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.20, i64 0, i64 0))
%167 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%168 = call i32 @strcpy(i8* %167, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.21, i64 0, i64 0))
br label %194
169: ; preds = %130
%170 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%171 = call i32 @strcpy(i8* %170, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
%172 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%173 = call i32 @strcat(i8* %172, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
%174 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%175 = call i32 @strcat(i8* %174, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.22, i64 0, i64 0))
%176 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%177 = call i32 @strcat(i8* %176, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%178 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%179 = call i32 @strcat(i8* %178, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
%180 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%181 = call i32 @strcat(i8* %180, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%182 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%183 = call i32 @strcat(i8* %182, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.23, i64 0, i64 0))
%184 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%185 = call i32 @strcat(i8* %184, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0))
%186 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%187 = call i32 @strcat(i8* %186, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.19, i64 0, i64 0))
%188 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%189 = call i32 @strcat(i8* %188, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.20, i64 0, i64 0))
%190 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%191 = call i32 @strcpy(i8* %190, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.24, i64 0, i64 0))
%192 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%193 = call i32 @strcat(i8* %192, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.25, i64 0, i64 0))
br label %194
194: ; preds = %169, %146
%195 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%196 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%197 = call i32 @strcpy(i8* %195, i8* %196)
%198 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%199 = call i32 @strcat(i8* %198, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0))
%200 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%201 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%202 = call i32 @strcat(i8* %200, i8* %201)
%203 = load i32, i32* %5
%204 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%205 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%206 = call i32 @strlen(i8* %205)
%207 = call i32 @send(i32 %203, i8* %204, i32 %206, i32 0)
%208 = load i32, i32* %5
%209 = call i32 @close(i32 %208)
br label %69
210: ; preds = %75
%211 = load i32, i32* %8
ret i32 %211
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.TYPE_3__ = type { i32, i32 }
%struct.sockaddr = type { i32 }
%struct.tm = type { i32 }
@__const.accept_loop.basic_authorization_header_str = [22 x i8] c"Authorization: Basic \00"
@.str = [17 x i8] c"testuser:test123\00"
@.str.1 = [12 x i8] c"buf = [%s]\0A\00"
@.str.2 = [7 x i8] c"accept\00"
@.str.3 = [37 x i8] c"accept!(IPAddress = %s, Port = %hu)\0A\00"
@.str.8 = [18 x i8] c"basic_str = [%s]\0A\00"
@.str.9 = [21 x i8] c"%Y/%m/%d %H:%M:%S %Z\00"
@.str.10 = [25 x i8] c"%a, %d %b %Y %H:%M:%S %Z\00"
@.str.11 = [9 x i8] c"<html>\0D\0A\00"
@.str.12 = [11 x i8] c" <head>\0D\0A\00"
@.str.13 = [33 x i8] c" <title>HTTP 200 OK</title>\0D\0A\00"
@.str.14 = [12 x i8] c" </head>\0D\0A\00"
@.str.15 = [11 x i8] c" <body>\0D\0A\00"
@.str.16 = [5 x i8] c" \00"
@.str.17 = [12 x i8] c"HTTP 200 OK\00"
@.str.18 = [3 x i8] c"\0D\0A\00"
@.str.19 = [12 x i8] c" </body>\0D\0A\00"
@.str.20 = [10 x i8] c"</html>\0D\0A\00"
@.str.21 = [18 x i8] c"HTTP/1.1 200 OK\0D\0A\00"
@.str.22 = [43 x i8] c" <title>HTTP 401 Unauthorized</title>\0D\0A\00"
@.str.23 = [22 x i8] c"HTTP 401 Unauthorized\00"
@.str.24 = [28 x i8] c"HTTP/1.1 401 Unauthorized\0D\0A\00"
@.str.25 = [26 x i8] c"WWW-Authenticate: Basic\0D\0A\00"
@str = [23 x i8] c"----- recv begin -----\00"
@str.26 = [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 = alloca [22 x i8]
%13 = alloca [256 x i8]
%14 = alloca %struct.TYPE_3__*
%15 = alloca [1024 x i8]
%16 = bitcast %struct.sockaddr_in* %2 to i8*
%17 = bitcast i32* %3 to i8*
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%21 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%22 = bitcast i64* %8 to i8*
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%24 = bitcast i64* %10 to i8*
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%26 = getelementptr inbounds [22 x i8], [22 x i8]* %12, i64 0, i64 0
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%28 = bitcast %struct.TYPE_3__** %14 to i8*
store %struct.TYPE_3__* null, %struct.TYPE_3__** %14
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%30 = tail call i32 (...) @BIO_f_base64()
%31 = tail call i32* @BIO_new(i32 %30)
%32 = tail call i32 (...) @BIO_s_mem()
%33 = tail call i32* @BIO_new(i32 %32)
%34 = tail call i32* @BIO_push(i32* %31, i32* %33)
%35 = tail call i32 @strlen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%36 = tail call i32 @BIO_write(i32* %34, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = tail call i32 @BIO_flush(i32* %34)
%38 = call i32 @BIO_get_mem_ptr(i32* %34, %struct.TYPE_3__** %14)
%39 = load %struct.TYPE_3__*, %struct.TYPE_3__** %14
%40 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %39, i64 0, i32 1
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %39, i64 0, i32 0
%43 = load i32, i32* %42
%44 = add nsw i32 %43, -1
%45 = call i32 @memcpy(i8* %29, i32 %41, i32 %44)
%46 = load %struct.TYPE_3__*, %struct.TYPE_3__** %14
%47 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %46, i64 0, i32 0
%48 = load i32, i32* %47
%49 = add nsw i32 %48, -1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 %50
store i8 0, i8* %51
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%53 = call i32 @BIO_free_all(i32* %34)
%54 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
store i32 8, i32* %3
%55 = call i32 @accept(i32 %0, %struct.sockaddr* %54, i32* %3)
%56 = icmp slt i32 %55, 0
br i1 %56, label %60, label %57
57: ; preds = %1
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
%59 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
br label %62
60: ; preds = %123, %1
%61 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
ret i32 -1
62: ; preds = %57, %123
%63 = phi i32 [ %55, %57 ], [ %130, %123 ]
%64 = load i32, i32* %58
%65 = call i8* @inet_ntoa(i32 %64)
%66 = load i32, i32* %59
%67 = call i32 @ntohs(i32 %66)
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %65, i32 %67)
%69 = call i32 @memset(i8* %18, i32 0, i32 4096)
%70 = call i32 @recv(i32 %63, i8* %18, i32 4096, i32 0)
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%72 = call i32 @puts(i8* %18)
%73 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.26, i64 0, i64 0))
%74 = call i8* @strstr(i8* %18, i8* %26)
%75 = icmp eq i8* %74, null
br i1 %75, label %90, label %76
76: ; preds = %62
%77 = call i32 @strlen(i8* %26)
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i8, i8* %74, i64 %78
%80 = call i8* @strchr(i8* %79, i32 13)
%81 = icmp eq i8* %80, null
br i1 %81, label %90, label %82
82: ; preds = %76
%83 = ptrtoint i8* %80 to i64
%84 = ptrtoint i8* %79 to i64
%85 = sub i64 %83, %84
%86 = trunc i64 %85 to i32
%87 = call i32 @strncpy(i8* %27, i8* %79, i32 %86)
%88 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 %85
store i8 0, i8* %88
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8* %27)
br label %90
90: ; preds = %76, %82, %62
%91 = call i64 @time(i32* null)
store i64 %91, i64* %8
%92 = call %struct.tm* @gmtime(i64* %8)
%93 = call i32 @strftime(i8* %23, i32 128, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), %struct.tm* %92)
%94 = load i64, i64* %8
%95 = add nsw i64 %94, 300
store i64 %95, i64* %10
%96 = call %struct.tm* @gmtime(i64* %10)
%97 = call i32 @strftime(i8* %25, i32 128, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), %struct.tm* %96)
%98 = call i64 @strcmp(i8* %27, i8* %29)
%99 = icmp eq i64 %98, 0
%100 = call i32 @strcpy(i8* %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
%101 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
br i1 %99, label %102, label %112
102: ; preds = %90
%103 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.13, i64 0, i64 0))
%104 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%105 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
%106 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%107 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i64 0, i64 0))
%108 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0))
%109 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.19, i64 0, i64 0))
%110 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.20, i64 0, i64 0))
%111 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.21, i64 0, i64 0))
br label %123
112: ; preds = %90
%113 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.22, i64 0, i64 0))
%114 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0))
%115 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
%116 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
%117 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.23, i64 0, i64 0))
%118 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0))
%119 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.19, i64 0, i64 0))
%120 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.20, i64 0, i64 0))
%121 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.24, i64 0, i64 0))
%122 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.25, i64 0, i64 0))
br label %123
123: ; preds = %112, %102
%124 = call i32 @strcpy(i8* %19, i8* %20)
%125 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0))
%126 = call i32 @strcat(i8* %19, i8* %21)
%127 = call i32 @strlen(i8* %19)
%128 = call i32 @send(i32 %63, i8* %19, i32 %127, i32 0)
%129 = call i32 @close(i32 %63)
store i32 8, i32* %3
%130 = call i32 @accept(i32 %0, %struct.sockaddr* %54, i32* %3)
%131 = icmp slt i32 %130, 0
br i1 %131, label %60, label %62
}