// File: /workspace/github_c_makefile_star2_O0/rouming[P]io/io-test.c
// Function: run_event_loop
static int run_event_loop(void)
{
	int err, sigfd, socks[2];
	int exit_rc = EXIT_SUCCESS;
	void *poller = NULL;
	struct loop_ctx ctx;
	struct io_queue sig_q;
	struct io_req sig_req;

	err = socketpair(AF_UNIX, SOCK_STREAM, 0, socks);
	assert(err == 0);

	sigfd = create_signalfd();
	assert(sigfd >= 0);

	io_queue_init(&ctx.master);
	io_queue_init(&ctx.slave);
	io_queue_init(&sig_q);

	err = poller_create(&poller);
	assert(err == 0);
	assert(poller != NULL);

	err = io_queue_bind(&ctx.master, poller, socks[0]);
	assert(err == 0);
	err = io_queue_bind(&ctx.slave, poller, socks[1]);
	assert(err == 0);
	err = io_queue_bind(&sig_q, poller, sigfd);
	assert(err == 0);

	io_req_init(&sig_req, &sig_q, REQ_RD, &ctx, on_signal);
	sig_req.buf = (struct io_buf){
		.iov[0] = {
			.iov_base = NULL,
			.iov_len  = sizeof(struct signalfd_siginfo)
		},
		.iov_num  = 1,
		.is_vari_len = false
	};

	err = io_queue_submit(&sig_req);
	assert(err == 0);

	ctx.shutdown = false;
	while (!ctx.shutdown) {
		int i;
		struct poller_item *items[16];

		err = poller_wait(poller, items, ARRAY_SIZE(items), INT_MAX);
		if (err == 0)
			continue;
		else if (err < 0) {
			printf("poller_wait() failed, errno=%d\n", -err);
			break;
		}
		/* Handle events */
		for (i = 0; i < err; i++) {
			err = poller_do_action(poller, items[i]);
			if (err) {
				/* We are done. */
				exit_rc = (err > 0 ? EXIT_SUCCESS :
						     EXIT_FAILURE);
				goto out;
			}
		}
	}
out:
	io_req_deinit(&sig_req);

	io_queue_unbind(&ctx.master);
	io_queue_unbind(&ctx.slave);
	io_queue_unbind(&sig_q);

	io_queue_deinit(&ctx.master);
	io_queue_deinit(&ctx.slave);
	io_queue_deinit(&sig_q);

	poller_destroy(poller);

	close(sigfd);
	close(socks[0]);
	close(socks[1]);

	return exit_rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x7f0, %rsp            # imm = 0x7F0
movl $0x0, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
leaq -0x10(%rbp), %rcx
movl $0x1, %esi
xorl %edx, %edx
movl %esi, %edi
callq 0x1150
movl %eax, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0x1317
jmp 0x1336
leaq 0x6d0b(%rip), %rdi      # 0x8029
leaq 0x6d0d(%rip), %rsi      # 0x8032
movl $0x19f, %edx            # imm = 0x19F
leaq 0x6d0b(%rip), %rcx      # 0x803c
callq 0x1090
callq 0x16b0
movl %eax, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
jl 0x1346
jmp 0x1365
leaq 0x6d08(%rip), %rdi      # 0x8055
leaq 0x6cde(%rip), %rsi      # 0x8032
movl $0x1a2, %edx            # imm = 0x1A2
leaq 0x6cdc(%rip), %rcx      # 0x803c
callq 0x1090
leaq -0x318(%rbp), %rdi
callq 0x4440
leaq -0x318(%rbp), %rdi
addq $0x178, %rdi            # imm = 0x178
callq 0x4440
leaq -0x490(%rbp), %rdi
callq 0x4440
leaq -0x20(%rbp), %rdi
callq 0x67b0
movl %eax, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0x13a4
jmp 0x13c3
leaq 0x6c7e(%rip), %rdi      # 0x8029
leaq 0x6c80(%rip), %rsi      # 0x8032
movl $0x1a9, %edx            # imm = 0x1A9
leaq 0x6c7e(%rip), %rcx      # 0x803c
callq 0x1090
cmpq $0x0, -0x20(%rbp)
je 0x13cc
jmp 0x13eb
leaq 0x6c8d(%rip), %rdi      # 0x8060
leaq 0x6c58(%rip), %rsi      # 0x8032
movl $0x1aa, %edx            # imm = 0x1AA
leaq 0x6c56(%rip), %rcx      # 0x803c
callq 0x1090
leaq -0x318(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x10(%rbp), %edx
callq 0x4600
movl %eax, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0x1409
jmp 0x1428
leaq 0x6c19(%rip), %rdi      # 0x8029
leaq 0x6c1b(%rip), %rsi      # 0x8032
movl $0x1ad, %edx            # imm = 0x1AD
leaq 0x6c19(%rip), %rcx      # 0x803c
callq 0x1090
leaq -0x318(%rbp), %rdi
addq $0x178, %rdi            # imm = 0x178
movq -0x20(%rbp), %rsi
movl -0xc(%rbp), %edx
callq 0x4600
movl %eax, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0x144d
jmp 0x146c
leaq 0x6bd5(%rip), %rdi      # 0x8029
leaq 0x6bd7(%rip), %rsi      # 0x8032
movl $0x1af, %edx            # imm = 0x1AF
leaq 0x6bd5(%rip), %rcx      # 0x803c
callq 0x1090
movq -0x20(%rbp), %rsi
movl -0x8(%rbp), %edx
leaq -0x490(%rbp), %rdi
callq 0x4600
movl %eax, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0x148a
jmp 0x14a9
leaq 0x6b98(%rip), %rdi      # 0x8029
leaq 0x6b9a(%rip), %rsi      # 0x8032
movl $0x1b1, %edx            # imm = 0x1B1
leaq 0x6b98(%rip), %rcx      # 0x803c
callq 0x1090
leaq -0x610(%rbp), %rdi
leaq -0x490(%rbp), %rsi
xorl %edx, %edx
leaq -0x318(%rbp), %rcx
leaq 0x289(%rip), %r8        # 0x1750
callq 0x4c80
leaq -0x610(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x7e8(%rbp)
leaq -0x758(%rbp), %rdi
xorl %esi, %esi
movl $0x148, %edx            # imm = 0x148
callq 0x10a0
movq -0x7e8(%rbp), %rdi
movq $0x80, -0x750(%rbp)
movq $0x1, -0x638(%rbp)
movb $0x0, -0x630(%rbp)
leaq -0x758(%rbp), %rsi
movl $0x148, %edx            # imm = 0x148
callq 0x1140
leaq -0x610(%rbp), %rdi
callq 0x4950
movl %eax, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0x153d
jmp 0x155c
leaq 0x6ae5(%rip), %rdi      # 0x8029
leaq 0x6ae7(%rip), %rsi      # 0x8032
movl $0x1be, %edx            # imm = 0x1BE
leaq 0x6ae5(%rip), %rcx      # 0x803c
callq 0x1090
movb $0x0, -0x28(%rbp)
movb -0x28(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x156e
jmp 0x1613
movq -0x20(%rbp), %rdi
leaq -0x7e0(%rbp), %rsi
movl $0x10, %edx
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
callq 0x6d80
movl %eax, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0x1593
jmp 0x1560
cmpl $0x0, -0x4(%rbp)
jge 0x15ae
xorl %esi, %esi
subl -0x4(%rbp), %esi
leaq 0x6aca(%rip), %rdi      # 0x806f
movb $0x0, %al
callq 0x1080
jmp 0x1613
jmp 0x15b0
movl $0x0, -0x75c(%rbp)
movl -0x75c(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x160e
movq -0x20(%rbp), %rdi
movslq -0x75c(%rbp), %rax
movq -0x7e0(%rbp,%rax,8), %rsi
callq 0x7070
movl %eax, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
je 0x15fb
movl -0x4(%rbp), %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovgl %ecx, %eax
movl %eax, -0x14(%rbp)
jmp 0x1615
jmp 0x15fd
movl -0x75c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x75c(%rbp)
jmp 0x15ba
jmp 0x1560
jmp 0x1615
leaq -0x610(%rbp), %rdi
callq 0x4d30
leaq -0x318(%rbp), %rdi
callq 0x4800
leaq -0x318(%rbp), %rdi
addq $0x178, %rdi            # imm = 0x178
callq 0x4800
leaq -0x490(%rbp), %rdi
callq 0x4800
leaq -0x318(%rbp), %rdi
callq 0x44b0
leaq -0x318(%rbp), %rdi
addq $0x178, %rdi            # imm = 0x178
callq 0x44b0
leaq -0x490(%rbp), %rdi
callq 0x44b0
movq -0x20(%rbp), %rdi
callq 0x6870
movl -0x8(%rbp), %edi
callq 0x10c0
movl -0x10(%rbp), %edi
callq 0x10c0
movl -0xc(%rbp), %edi
callq 0x10c0
movl -0x14(%rbp), %eax
addq $0x7f0, %rsp            # imm = 0x7F0
popq %rbp
retq
nopw %cs:(%rax,%rax)