// File: /workspace/github_c_makefile_star2_O0/weaslepalace[P]FreeRTOS_Posix_Sim/AsyncIO/AsyncIO.c
// Function: prvSignalHandler
void prvSignalHandler( int signal, siginfo_t * data, void * pvParam )
{
int iSocket = 0, iReturn;
xAsyncIOCallback *pxIterator;
struct pollfd xFileDescriptorPollEvents;
	if ( SIG_MSG_RX == signal )	/* Are we in the correct signal handler. */
	{
		if ( data->si_code == SI_SIGIO )	/* Do we know which socket caused the signal? */
		{
			iSocket = data->si_fd;	/* Yes we do. Find the owner. */

			for ( pxIterator = &xHead; ( pxIterator->pxNext != NULL ) && ( pxIterator->iFileHandle != iSocket ); pxIterator = pxIterator->pxNext );

			if ( pxIterator->iFileHandle == iSocket )
			{
				( pxIterator->pvFunction )( iSocket, pxIterator->pvContext );
			}
			else
			{
				printf( "No socket owner.\n" );
			}
		}
		else
		{
			/* We don't know which socket cause the signal. Use poll to find the socket. */
			for ( pxIterator = &xHead; pxIterator != NULL; pxIterator = pxIterator->pxNext )
			{
				xFileDescriptorPollEvents.fd = pxIterator->iFileHandle;
				xFileDescriptorPollEvents.events = POLLIN;
				xFileDescriptorPollEvents.revents = 0;
				if ( xFileDescriptorPollEvents.fd != 0 )
				{
					iReturn = poll( &xFileDescriptorPollEvents, 1, 0 );	/* Need to kick off the signal handling. */

					if ( ( 1 == iReturn ) && ( POLLIN == xFileDescriptorPollEvents.revents ) )
					{
						if ( pxIterator->pvFunction != NULL )
						{
							( pxIterator->pvFunction )( xFileDescriptorPollEvents.fd, pxIterator->pvContext );
						}
					}
				}
			}
			/* Note that poll should really be passed all of the sockets in one go and then iterate over the results. */
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x1d, %eax
cmpl -0x4(%rbp), %eax
jne 0x99a7
movq -0x10(%rbp), %rax
cmpl $-0x5, 0x8(%rax)
jne 0x9918
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x1c(%rbp)
leaq 0x50b1(%rip), %rax      # 0xe958
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x18(%rcx)
movb %al, -0x31(%rbp)
je 0x98ca
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl -0x1c(%rbp), %eax
setne %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x98d3
jmp 0x98e3
jmp 0x98d5
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x98ab
movq -0x28(%rbp), %rax
movl (%rax), %eax
cmpl -0x1c(%rbp), %eax
jne 0x9905
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %edi
movq -0x28(%rbp), %rcx
movq 0x10(%rcx), %rsi
callq *%rax
jmp 0x9913
leaq 0x18e2(%rip), %rdi      # 0xb1ee
movb $0x0, %al
callq 0x4180
jmp 0x99a5
leaq 0x5039(%rip), %rax      # 0xe958
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x99a3
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x30(%rbp)
movw $0x1, -0x2c(%rbp)
movw $0x0, -0x2a(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x9993
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x4530
movl %eax, -0x20(%rbp)
movl $0x1, %eax
cmpl -0x20(%rbp), %eax
jne 0x9991
movswl -0x2a(%rbp), %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jne 0x9991
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x998f
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x30(%rbp), %edi
movq -0x28(%rbp), %rcx
movq 0x10(%rcx), %rsi
callq *%rax
jmp 0x9991
jmp 0x9993
jmp 0x9995
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x9923
jmp 0x99a5
jmp 0x99a7
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)