// File: /workspace/github_c_makefile_star2_O0/TimeToogo[P]ff-proxy/src/server.c
// Function: ff_proxy_process_incoming_packet
void ff_proxy_process_incoming_packet(struct ff_config *config, struct ff_hash_table *requests, struct sockaddr *src_address, void *packet_buff, int buff_len)
{
    bool is_raw_http = ff_request_is_raw_http(buff_len, packet_buff);
    uint64_t request_id = 0;
    struct ff_request *request;
    pthread_t thread;
    pthread_attr_t thread_attrs;
    struct ff_process_request_args *thread_args;

    if (is_raw_http)
    {
        ff_log(FF_DEBUG, "Incoming packet is raw HTTP request");
        request = ff_request_alloc();
        ff_request_parse_chunk(request, buff_len, packet_buff);
    }
    else
    {
        ff_log(FF_DEBUG, "Parsing incoming packet");
        request_id = ff_request_parse_id(buff_len, packet_buff);

        if (request_id == 0)
        {
            ff_log(FF_DEBUG, "Could not parse request ID from incoming packet");
            goto done;
        }

        request = (struct ff_request *)ff_hash_table_get_item(requests, request_id);

        if (request == NULL)
        {
            request = ff_request_alloc();
            time(&request->received_at);
            memcpy(&request->source, src_address, sizeof(struct sockaddr));
            ff_hash_table_put_item(requests, request_id, (void *)request);
        }

        if (memcmp(&request->source, src_address, sizeof(struct sockaddr)) != 0)
        {
            ff_log(FF_WARNING, "Incoming packet IP address does not match original source IP address/port for request %lu (will discard)", request->request_id);
            goto done;
        }

        ff_request_parse_chunk(request, buff_len, packet_buff);
    }

    switch (request->state)
    {
    case FF_REQUEST_STATE_RECEIVING:
        break;

    case FF_REQUEST_STATE_RECEIVING_FAIL:
        if (request_id != 0)
        {
            ff_hash_table_remove_item(requests, request_id);
        }
        ff_request_free(request);
        break;

    case FF_REQUEST_STATE_RECEIVED:
        ff_log(FF_DEBUG, "Finished receiving incoming request");

        thread_args = malloc(sizeof(struct ff_process_request_args));
        thread_args->config = config;
        thread_args->request = request;
        thread_args->requests = requests;

        pthread_attr_init(&thread_attrs);
        pthread_attr_setdetachstate(&thread_attrs, PTHREAD_CREATE_DETACHED);

        pthread_create(&thread, &thread_attrs, (void *)ff_proxy_process_request, (void *)thread_args);

        pthread_attr_destroy(&thread_attrs);
        break;
    default:
        ff_log(FF_ERROR, "Encountered invalid request state: %d", request->state);
        break;
    }

done:
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl -0x24(%rbp), %edi
movq -0x20(%rbp), %rsi
callq 0x5750
andb $0x1, %al
movb %al, -0x25(%rbp)
movq $0x0, -0x30(%rbp)
testb $0x1, -0x25(%rbp)
je 0x673f
movl $0x1, %edi
leaq 0x1c9f(%rip), %rsi      # 0x83b9
movb $0x0, %al
callq 0x4d70
callq 0x5f90
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0x4ff0
jmp 0x6831
movl $0x1, %edi
leaq 0x1c92(%rip), %rsi      # 0x83dd
movb $0x0, %al
callq 0x4d70
movl -0x24(%rbp), %edi
movq -0x20(%rbp), %rsi
callq 0x5690
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x6781
movl $0x1, %edi
leaq 0x1c80(%rip), %rsi      # 0x83f5
movb $0x0, %al
callq 0x4d70
jmp 0x6920
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x36e0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x67d7
callq 0x5f90
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
addq $0x18, %rdi
callq 0x22a0
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x37a0
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq -0x18(%rbp), %rcx
movups (%rcx), %xmm1
movups (%rax), %xmm0
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %eax
subl $0xffff, %eax           # imm = 0xFFFF
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x6821
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdx
movl $0x3, %edi
leaq 0x1c10(%rip), %rsi      # 0x8425
movb $0x0, %al
callq 0x4d70
jmp 0x6920
movq -0x38(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0x4ff0
movq -0x38(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x84(%rbp)
testl %eax, %eax
je 0x6860
jmp 0x6843
movl -0x84(%rbp), %eax
subl $0x1, %eax
je 0x6887
jmp 0x6850
movl -0x84(%rbp), %eax
subl $0x2, %eax
je 0x6865
jmp 0x6905
jmp 0x691e
cmpq $0x0, -0x30(%rbp)
je 0x6879
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x38f0
movq -0x38(%rbp), %rdi
callq 0x5fc0
jmp 0x691e
movl $0x1, %edi
leaq 0x1bfb(%rip), %rsi      # 0x848e
movb $0x0, %al
callq 0x4d70
movl $0x18, %edi
callq 0x23e0
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rcx
movq -0x80(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rcx
movq -0x80(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rcx
movq -0x80(%rbp), %rax
movq %rcx, 0x10(%rax)
leaq -0x78(%rbp), %rdi
callq 0x2370
leaq -0x78(%rbp), %rdi
movl $0x1, %esi
callq 0x23c0
movq -0x80(%rbp), %rcx
leaq -0x40(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq 0x3b(%rip), %rdx        # 0x6930
callq 0x24c0
leaq -0x78(%rbp), %rdi
callq 0x2470
jmp 0x691e
movq -0x38(%rbp), %rax
movl (%rax), %edx
movl $0x4, %edi
leaq 0x1b9b(%rip), %rsi      # 0x84b2
movb $0x0, %al
callq 0x4d70
jmp 0x6920
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)