// File: UTAP[P]APHTTP/examples/handlers.cpp
// Function: RandomNumberHandler::callback(Request*)
Response *RandomNumberHandler::callback(Request *req) {
  Response *res = new Response;
  res->setHeader("Content-Type", "text/html");
  string body;
  body += "<!DOCTYPE html>";
  body += "<html>";
  body += "<body style=\"text-align: center;\">";
  body += "<h1>AP HTTP</h1>";
  body += "<p>";
  body += "a random number in [1, 10] is: ";
  body += to_string(rand() % 10 + 1);
  body += "</p>";
  body += "<p>";
  body += "SeddionId: ";
  body += req->getSessionId();
  body += "</p>";
  body += "</body>";
  body += "</html>";
  res->setBody(body);
  return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x78, %edi
callq 0x4400
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x100(%rbp)
movl $0xc8, %esi
callq 0xb460
jmp 0x89c6
movq -0x100(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x46c0
movq -0x108(%rbp), %rdx
leaq 0x1875d(%rip), %rsi     # 0x21157
leaq -0x48(%rbp), %rdi
callq 0x4550
jmp 0x8a05
leaq -0x71(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x46c0
movq -0x118(%rbp), %rdx
leaq 0x18741(%rip), %rsi     # 0x21164
leaq -0x70(%rbp), %rdi
callq 0x4550
jmp 0x8a2e
movq -0x110(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0xccb0
jmp 0x8a44
leaq -0x70(%rbp), %rdi
callq 0x4768
leaq -0x71(%rbp), %rdi
callq 0x4440
leaq -0x48(%rbp), %rdi
callq 0x4768
leaq -0x49(%rbp), %rdi
callq 0x4440
leaq -0x98(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x4560
movq -0x120(%rbp), %rdi
leaq 0x186e5(%rip), %rsi     # 0x2116e
callq 0x43c0
jmp 0x8a90
leaq 0x186e7(%rip), %rsi     # 0x2117e
leaq -0x98(%rbp), %rdi
callq 0x43c0
jmp 0x8aa5
leaq 0x186d9(%rip), %rsi     # 0x21185
leaq -0x98(%rbp), %rdi
callq 0x43c0
jmp 0x8aba
leaq 0x186e7(%rip), %rsi     # 0x211a8
leaq -0x98(%rbp), %rdi
callq 0x43c0
jmp 0x8acf
leaq 0x186e3(%rip), %rsi     # 0x211b9
leaq -0x98(%rbp), %rdi
callq 0x43c0
jmp 0x8ae4
leaq 0x186d2(%rip), %rsi     # 0x211bd
leaq -0x98(%rbp), %rdi
callq 0x43c0
jmp 0x8af9
callq 0x4150
movl %eax, %ecx
movslq %ecx, %rax
imulq $0x66666667, %rax, %rdx # imm = 0x66666667
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x22, %rdx
addl %eax, %edx
addl %edx, %edx
movl %edx, %eax
leal (%rax,%rax,4), %edx
movl %ecx, %eax
negl %edx
movl %edx, %ecx
leal 0x1(%rax,%rcx), %esi
leaq -0xb8(%rbp), %rdi
callq 0x98c0
jmp 0x8b36
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x44e0
jmp 0x8b4b
leaq -0xb8(%rbp), %rdi
callq 0x4768
leaq 0x1867f(%rip), %rsi     # 0x211dd
leaq -0x98(%rbp), %rdi
callq 0x43c0
jmp 0x8b6c
leaq 0x18646(%rip), %rsi     # 0x211b9
leaq -0x98(%rbp), %rdi
callq 0x43c0
jmp 0x8b81
leaq 0x1865a(%rip), %rsi     # 0x211e2
leaq -0x98(%rbp), %rdi
callq 0x43c0
jmp 0x8b96
movq -0x10(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x10b20
jmp 0x8ba8
leaq -0x98(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x44e0
jmp 0x8bbd
leaq -0xd8(%rbp), %rdi
callq 0x4768
leaq 0x1860d(%rip), %rsi     # 0x211dd
leaq -0x98(%rbp), %rdi
callq 0x43c0
jmp 0x8bde
leaq 0x18609(%rip), %rsi     # 0x211ee
leaq -0x98(%rbp), %rdi
callq 0x43c0
jmp 0x8bf3
leaq 0x185fc(%rip), %rsi     # 0x211f6
leaq -0x98(%rbp), %rdi
callq 0x43c0
jmp 0x8c08
movq -0x18(%rbp), %rax
movq %rax, -0x128(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x4200
jmp 0x8c28
movq -0x128(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0xccf0
jmp 0x8c3d
leaq -0xf8(%rbp), %rdi
callq 0x4768
movq -0x18(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x4768
movq -0x130(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x100(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x43a0
jmp 0x8d41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x8cd0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x8cbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x4768
leaq -0x71(%rbp), %rdi
callq 0x4440
leaq -0x48(%rbp), %rdi
callq 0x4768
leaq -0x49(%rbp), %rdi
callq 0x4440
jmp 0x8d41
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x8d35
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x4768
jmp 0x8d35
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x4768
jmp 0x8d35
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x4768
leaq -0x98(%rbp), %rdi
callq 0x4768
movq -0x20(%rbp), %rdi
callq 0x46b0
nopw (%rax,%rax)