// File: /workspace/github_c_makefile_star2_O0/somethingnew2-0[P]CS537-P4/request.c
// Function: requestServeDynamic
void requestServeDynamic(int fd, char *filename, char *cgiargs, long arrival, long dispatch, thread *worker)
{
   char buf[MAXLINE], *emptylist[] = {NULL};

   // The server does only a little bit of the header.  
   // The CGI script has to finish writing out the header.
   sprintf(buf, "HTTP/1.0 200 OK\r\n");
   sprintf(buf, "%sServer: CS537 Web Server\r\n", buf);

	 /* CS537: Your statistics go here -- fill in the 0's with something useful! */
	 sprintf(buf, "%s Stat-req-arrival: %ld\r\n", buf, arrival);
	 sprintf(buf, "%s Stat-req-dispatch: %d\r\n", buf, (int)(dispatch - arrival));
	 sprintf(buf, "%s Stat-thread-id: %d\r\n", buf, worker->id);
	 sprintf(buf, "%s Stat-thread-count: %d\r\n", buf, worker->count);
	 sprintf(buf, "%s Stat-thread-static: %d\r\n", buf, worker->statics);
	 sprintf(buf, "%s Stat-thread-dynamic: %d\r\n", buf, worker->dynamics);

   Rio_writen(fd, buf, strlen(buf));

   if (Fork() == 0) {
      /* Child process */
      Setenv("QUERY_STRING", cgiargs, 1);
      /* When the CGI process writes to stdout, it will instead go to the socket */
      Dup2(fd, STDOUT_FILENO);
      Execve(filename, emptylist, environ);
   }
   Wait(NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2050, %rsp           # imm = 0x2050
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
leaq -0x2038(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x2150
leaq -0x2030(%rbp), %rdi
leaq 0x2030(%rip), %rsi      # 0x5173
movb $0x0, %al
callq 0x22f0
leaq -0x2030(%rbp), %rdi
leaq -0x2030(%rbp), %rdx
leaq 0x2026(%rip), %rsi      # 0x5185
movb $0x0, %al
callq 0x22f0
leaq -0x2030(%rbp), %rdi
leaq -0x2030(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0x2023(%rip), %rsi      # 0x51a2
movb $0x0, %al
callq 0x22f0
leaq -0x2030(%rbp), %rdi
leaq -0x2030(%rbp), %rdx
movq -0x28(%rbp), %rax
subq -0x20(%rbp), %rax
movl %eax, %ecx
leaq 0x2018(%rip), %rsi      # 0x51bd
movb $0x0, %al
callq 0x22f0
leaq -0x2030(%rbp), %rdi
leaq -0x2030(%rbp), %rdx
movq -0x30(%rbp), %rax
movl (%rax), %ecx
leaq 0x2011(%rip), %rsi      # 0x51d8
movb $0x0, %al
callq 0x22f0
leaq -0x2030(%rbp), %rdi
leaq -0x2030(%rbp), %rdx
movq -0x30(%rbp), %rax
movl 0x4(%rax), %ecx
leaq 0x2006(%rip), %rsi      # 0x51f0
movb $0x0, %al
callq 0x22f0
leaq -0x2030(%rbp), %rdi
leaq -0x2030(%rbp), %rdx
movq -0x30(%rbp), %rax
movl 0x8(%rax), %ecx
leaq 0x1ffe(%rip), %rsi      # 0x520b
movb $0x0, %al
callq 0x22f0
leaq -0x2030(%rbp), %rdi
leaq -0x2030(%rbp), %rdx
movq -0x30(%rbp), %rax
movl 0xc(%rax), %ecx
leaq 0x1ff7(%rip), %rsi      # 0x5227
movb $0x0, %al
callq 0x22f0
movl -0x4(%rbp), %eax
movl %eax, -0x2044(%rbp)
leaq -0x2030(%rbp), %rax
movq %rax, -0x2040(%rbp)
leaq -0x2030(%rbp), %rdi
callq 0x20d0
movl -0x2044(%rbp), %edi
movq -0x2040(%rbp), %rsi
movq %rax, %rdx
callq 0x4470
callq 0x3a50
cmpl $0x0, %eax
jne 0x32b5
movq -0x18(%rbp), %rsi
leaq 0x1fc0(%rip), %rdi      # 0x5244
movl $0x1, %edx
callq 0x3a10
movl -0x4(%rbp), %edi
movl $0x1, %esi
callq 0x3cb0
movq -0x10(%rbp), %rdi
leaq -0x2038(%rbp), %rsi
movq 0x4d33(%rip), %rax      # 0x7fe0
movq (%rax), %rdx
callq 0x3a80
xorl %eax, %eax
movl %eax, %edi
callq 0x3ac0
addq $0x2050, %rsp           # imm = 0x2050
popq %rbp
retq
nopw (%rax,%rax)