// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/TelevisionHttp.cxx
// Function: TelevisionHttp::send_index_html()
int TelevisionHttp::send_index_html()
{
  std::string header;
  const char *page =
    "<html>\n<body onload='init();' bgcolor='#000000'>\n"
    "<script type='text/javascript'>\n"
    "var queue = '';\n"
    "function init()\n"
    "{\n"
      "setTimeout(refresh_image, 2000);\n"
      "window.addEventListener('keydown', function(event)\n"
      "{\n"
        "if (event.defaultPrevented) { return; }\n"
        "switch(event.keyCode)\n"
        "{\n"
          "case 40: queue += 's'; break;\n"
          "case 38: queue += 'w'; break;\n"
          "case 37: queue += 'a'; break;\n"
          "case 39: queue += 'd'; break;\n"
          "case 32: queue += 'f'; break;\n"
          "case 13: queue += 'e'; break;\n"
          "case 67: queue += 'c'; break;\n"
          "default: break;\n"
        "}\n"
      "});\n"
      "window.addEventListener('keyup', function(event)\n"
      "{\n"
        "if (event.defaultPrevented) { return; }\n"
        "switch(event.keyCode)\n"
        "{\n"
          "case 40: queue += 'S'; break;\n"
          "case 38: queue += 'W'; break;\n"
          "case 37: queue += 'A'; break;\n"
          "case 39: queue += 'D'; break;\n"
          "case 32: queue += 'F'; break;\n"
          "case 13: queue += 'E'; break;\n"
          "case 67: queue += 'C'; break;\n"
          "default: break;\n"
        "}\n"
      "});\n"
    "}\n"
    "function refresh_image()\n"
    "{\n"
    //"console.log('refresh_image()');\n"
    "var atari = document.getElementById('atari');\n"
    "if (atari.complete)\n"
    "{\n"
    "atari.src = 'image.gif?' + queue + '#' + new Date().getTime();\n"
    "queue = '';\n"
    "}\n"
    "setTimeout(refresh_image, 33);\n"
    "}\n"
    "</script>\n"
    "<table width=100%% height=100%%>"
    "<tr><td width=100%% height=100%% align='center'>"
    "<img src='image.gif' id='atari'></td></tr>"
    "</body>\n</html>\n\n";

  header =
    "HTTP/1.1 200 OK\n"
    "Cache-Control: no-cache, must-revalidate\n"
    "Pragma: no-cache\n"
    "Content-Type: text/html\n"
    "Content-Length: " + std::to_string(strlen(page)) + "\n\n";

  net_send((uint8_t *)header.c_str(), header.size());
  net_send((uint8_t *)page, strlen(page));

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
leaq 0x58(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x48(%rsp), %rdi
movl $0x4, %esi
xorl %edx, %edx
callq 0x4210
leaq 0x48(%rsp), %r14
movq (%r14), %rdi
movl 0x8(%r14), %esi
movl $0x4b0, %edx            # imm = 0x4B0
callq 0x8faa
leaq 0x29d9(%rip), %rcx      # 0xb0f6
movl $0x72, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4200
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x8756
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x875e
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
leaq 0x8(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x2972(%rip), %rsi      # 0xb0f3
callq 0x4340
leaq 0x78(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x87ad
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
jmp 0x87b4
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
movq 0x8(%rax), %rdx
leaq 0x68(%rsp), %r14
movq %rdx, 0x8(%r14)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x4250
movq (%r14), %rdi
cmpq %rbp, %rdi
je 0x87f2
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x41d0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x8809
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x41d0
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x8820
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x41d0
addq $0x20, %rbx
movq 0x28(%rsp), %rsi
movl 0x30(%rsp), %edx
movq %rbx, %rdi
callq 0x719c
leaq 0x2409(%rip), %rsi      # 0xac45
movq %rbx, %rdi
movl $0x4b0, %edx            # imm = 0x4B0
callq 0x719c
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x8860
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x41d0
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x8893
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x41d0
jmp 0x8893
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x88b1
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x41d0
jmp 0x88b1
jmp 0x88ae
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x88c8
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x41d0
movq %rbx, %rdi
callq 0x4330