// File: /workspace/github_cpp_makefile_star2_O3/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 0x4220
leaq 0x48(%rsp), %r14
movq (%r14), %rdi
movl 0x8(%r14), %esi
movl $0x4b0, %edx            # imm = 0x4B0
callq 0x9162
leaq 0x3999(%rip), %rcx      # 0xc27a
movl $0x72, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4210
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x891a
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x8922
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 0x3932(%rip), %rsi      # 0xc277
callq 0x4350
leaq 0x78(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x8971
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
jmp 0x8978
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 0x4260
movq (%r14), %rdi
cmpq %rbp, %rdi
je 0x89b6
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x41e0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x89cd
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x41e0
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x89e4
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x41e0
addq $0x20, %rbx
movq 0x28(%rsp), %rsi
movl 0x30(%rsp), %edx
movq %rbx, %rdi
callq 0x7242
leaq 0x33c9(%rip), %rsi      # 0xbdc9
movq %rbx, %rdi
movl $0x4b0, %edx            # imm = 0x4B0
callq 0x7242
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x8a24
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x41e0
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 0x8a57
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x41e0
jmp 0x8a57
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x8a75
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x41e0
jmp 0x8a75
jmp 0x8a72
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x8a8c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x41e0
movq %rbx, %rdi
callq 0x4340