// File: Cristian-Castillo[P]Multithreaded-HTTP-Server/./httpserver_definitions.cpp
// Function: create_worker(unsigned long*, int*, command_line_inputs*)
void create_worker(pthread_t *workerArr, int *thread_array,struct command_line_inputs *configs){
                                       
    size_t s1;                                                           
    pthread_attr_t attr;                                                            
    char msg[100];
    int index,ret,rc;       
    int numWorker = configs->N_threads;
    free(&configs);                                               
                                                                                
   rc = pthread_attr_init(&attr);                                               
   
   if(rc == -1){                                                              
      perror("error in pthread_attr_init");                                     
      exit(1);                                                                  
   }                                                                            
    /* Make thread safe set stack size attributes */                                                               
   s1 = 4096;                                                                   
   rc = pthread_attr_setstacksize(&attr, s1);                                   
   
   if(rc == -1){                                                              
      perror("error in pthread_attr_setstacksize");                             
      exit(2);                                                                  
   } 
    /* Dispatcher - N Thread Pool */
	for(index = 0; index < numWorker; index++){
        
        thread_array[index] = index;
        ret = pthread_create(&workerArr[index],&attr, worker_thread, &thread_array[index]);
        
        if(ret){
			sprintf(msg, "Failed on pthread_create()%d\n", ret);
            exit(EXIT_FAILURE); 
		}		
	}
    free(&thread_array); 
    free(&workerArr);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xd0(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x5560
leaq -0x58(%rbp), %rdi
callq 0x5590
movl %eax, -0xcc(%rbp)
cmpl $-0x1, -0xcc(%rbp)
jne 0x7f4a
leaq 0x2d972(%rip), %rdi     # 0x358ad
callq 0x53f0
movl $0x1, %edi
callq 0x5580
movq $0x1000, -0x20(%rbp)    # imm = 0x1000
movq -0x20(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x5650
movl %eax, -0xcc(%rbp)
cmpl $-0x1, -0xcc(%rbp)
jne 0x7f84
leaq 0x2d953(%rip), %rdi     # 0x358c8
callq 0x53f0
movl $0x2, %edi
callq 0x5580
movl $0x0, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
cmpl -0xd0(%rbp), %eax
jge 0x8032
movl -0xc4(%rbp), %edx
movq -0x10(%rbp), %rax
movslq -0xc4(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rdi
movslq -0xc4(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rcx
movslq -0xc4(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rcx
leaq -0x58(%rbp), %rsi
leaq 0x6d(%rip), %rdx        # 0x8050
callq 0x5870
movl %eax, -0xc8(%rbp)
cmpl $0x0, -0xc8(%rbp)
je 0x801c
leaq -0xc0(%rbp), %rdi
movl -0xc8(%rbp), %edx
leaq 0x2d8e0(%rip), %rsi     # 0x358eb
movb $0x0, %al
callq 0x50b0
movl $0x1, %edi
callq 0x5580
jmp 0x801e
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x7f8e
leaq -0x10(%rbp), %rdi
callq 0x5560
leaq -0x8(%rbp), %rdi
callq 0x5560
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)