// File: /workspace/github_c_makefile_star2_O0/weaslepalace[P]FreeRTOS_Posix_Sim/AsyncIO/PosixMessageQueueIPC.c
// Function: xPosixIPCOpen
mqd_t xPosixIPCOpen( const portCHAR *pcPipeName, void (*vMessageInterruptHandler)(xMessageObject,void*), void *pvContext )
{
mqd_t hPipeHandle;
struct sigaction sigrt;

	hPipeHandle = mq_open( pcPipeName, O_RDWR | O_CREAT | O_NONBLOCK, S_IRUSR | S_IWUSR, NULL );
	if ( -1 == hPipeHandle )
	{
		hPipeHandle = mq_unlink( pcPipeName );
		hPipeHandle = 0;
		printf( "Problem opening message pipe.\n" );
	}
	else
	{
		printf( "Pipe Open: %s\n", pcPipeName );
	}

	/* If this is a receive pipe then we set-up the interrupt handler. */
	if ( ( 0 != hPipeHandle ) && ( NULL != vMessageInterruptHandler ) )
	{
		/* Establish the signal handler. */
		sigrt.sa_flags = SA_SIGINFO;						/* Need some information to be passed. */
		sigrt.sa_handler = (__sighandler_t)prvPosixIPCInterruptHandler;		/* This is the function to call. */
		sigfillset( &sigrt.sa_mask );
		sigdelset( &sigrt.sa_mask, SIG_MSG_RX );
		sigdelset( &sigrt.sa_mask, SIG_TICK );

		if ( 0 != sigaction( SIG_MSG_RX, &sigrt, NULL ) )	/* Register the Signal Handler. */
		{
			printf( "Problem installing SIG_MSG_RT\n" );
		}		/* Parameters to the signal handler. */

		/* No establish the notify parameters. */
		xActualParameters.hPipe = hPipeHandle;
		xActualParameters.pvFunction = vMessageInterruptHandler;
		xActualParameters.pvContext = pvContext;
		xParameters.sival_ptr = &xActualParameters;

		/* Set-up the notifcation. */
		xMessageEvent.sigev_notify = SIGEV_SIGNAL;				/* How to signal. */
		xMessageEvent.sigev_signo = SIG_MSG_RX;					/* Signal number to use. */
		xMessageEvent.sigev_value = xParameters;				/* Parameters to pass to the signal handler. */
		xMessageEvent.sigev_notify_function = NULL;				/* Signal handler function. */
		xMessageEvent.sigev_notify_attributes = NULL;			/* Parameters if a new thread is created to execute the signal handler. */

		/* Register the notification. */
		if ( 0 != mq_notify( hPipeHandle, &xMessageEvent ) )
		{
			printf( "Failed to install Rx interrupt handler: %d.\n", errno );
		}
	}
	return hPipeHandle;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movl $0x842, %esi            # imm = 0x842
movl $0x180, %edx            # imm = 0x180
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x4370
movl %eax, -0x1c(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl -0x1c(%rbp), %eax
jne 0x9e40
movq -0x8(%rbp), %rdi
callq 0x4700
movl %eax, -0x1c(%rbp)
movl $0x0, -0x1c(%rbp)
leaq 0x145c(%rip), %rdi      # 0xb293
movb $0x0, %al
callq 0x4180
jmp 0x9e52
movq -0x8(%rbp), %rsi
leaq 0x1467(%rip), %rdi      # 0xb2b2
movb $0x0, %al
callq 0x4180
xorl %eax, %eax
cmpl -0x1c(%rbp), %eax
je 0x9f76
xorl %eax, %eax
cmpq -0x10(%rbp), %rax
je 0x9f76
movl $0x4, -0x30(%rbp)
leaq 0x119(%rip), %rax       # 0x9f90
movq %rax, -0xb8(%rbp)
leaq -0xb8(%rbp), %rdi
addq $0x8, %rdi
callq 0x4350
leaq -0xb8(%rbp), %rdi
addq $0x8, %rdi
movl $0x22, %esi
callq 0x4610
leaq -0xb8(%rbp), %rdi
addq $0x8, %rdi
movl $0xe, %esi
callq 0x4610
movl $0x22, %edi
leaq -0xb8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x40e0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x9ee3
leaq 0x13e5(%rip), %rdi      # 0xb2c1
movb $0x0, %al
callq 0x4180
movl -0x1c(%rbp), %eax
movl %eax, 0x4e94(%rip)      # 0xed80
movq -0x10(%rbp), %rax
movq %rax, 0x4e91(%rip)      # 0xed88
movq -0x18(%rbp), %rax
movq %rax, 0x4e8e(%rip)      # 0xed90
leaq 0x4e77(%rip), %rax      # 0xed80
movq %rax, 0x4e88(%rip)      # 0xed98
movl $0x0, 0x4e92(%rip)      # 0xedac
movl $0x22, 0x4e84(%rip)     # 0xeda8
movq 0x4e6d(%rip), %rax      # 0xed98
movq %rax, 0x4e6e(%rip)      # 0xeda0
movq $0x0, 0x4e73(%rip) # 0xedb0
movq $0x0, 0x4e70(%rip) # 0xedb8
movl -0x1c(%rbp), %edi
leaq 0x4e4e(%rip), %rsi      # 0xeda0
callq 0x4640
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x9f74
callq 0x40a0
movl (%rax), %esi
leaq 0x139b(%rip), %rdi      # 0xb308
movb $0x0, %al
callq 0x4180
jmp 0x9f76
movl -0x1c(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)