// File: /workspace/github_c_makefile_star2_O3/michaelforney[P]wld/wayland.c
// Function: wld_wayland_create_context
wld_context *
wld_wayland_create_context(struct wl_display *display, enum wld_wayland_interface_id id, ...)
{
	struct wayland_context *context = NULL;
	struct wl_event_queue *queue;
	va_list requested_impls;
	bool impls_tried[ARRAY_LENGTH(impls)] = { 0 };
	const char *interface_string;

	if (!(queue = wl_display_create_queue(display)))
		return NULL;

	if ((interface_string = getenv("WLD_WAYLAND_INTERFACE"))) {
		id = interface_id(interface_string);

		if ((context = impls[id]->create_context(display, queue)))
			return &context->base;

		fprintf(stderr, "Could not create context for Wayland interface '%s'\n",
		        interface_string);

		return NULL;
	}

	va_start(requested_impls, id);

	while (id >= 0) {
		if (impls_tried[id] || !impls[id])
			continue;

		if ((context = impls[id]->create_context(display, queue)))
			goto done;

		impls_tried[id] = true;
		id = va_arg(requested_impls, enum wld_wayland_interface_id);
	}

	va_end(requested_impls);

	/* If the user specified WLD_ANY, try any remaining implementations. */
	if (!context && id == WLD_ANY) {
		for (id = 0; id < ARRAY_LENGTH(impls); ++id) {
			if (impls_tried[id] || !impls[id])
				continue;

			if ((context = impls[id]->create_context(display, queue)))
				break;
		}
	}

	if (!context) {
		DEBUG("Could not initialize any of the specified implementations\n");
		return NULL;
	}

done:
	context->impl = impls[id];
	context->display = display;
	context->queue = queue;

	return &context->base;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movq %rdx, 0x40(%rsp)
movq %rcx, 0x48(%rsp)
movq %r8, 0x50(%rsp)
movq %r9, 0x58(%rsp)
testb %al, %al
je 0xdcec
movaps %xmm0, 0x60(%rsp)
movaps %xmm1, 0x70(%rsp)
movaps %xmm2, 0x80(%rsp)
movaps %xmm3, 0x90(%rsp)
movaps %xmm4, 0xa0(%rsp)
movaps %xmm5, 0xb0(%rsp)
movaps %xmm6, 0xc0(%rsp)
movaps %xmm7, 0xd0(%rsp)
movw $0x0, 0xe(%rsp)
callq 0x9750
testq %rax, %rax
je 0xde2f
movq %rax, %r14
leaq 0x3865(%rip), %rdi      # 0x11570
callq 0x9030
testq %rax, %rax
je 0xdd64
movq %rax, %r12
movq %rax, %rdi
callq 0xdc30
cltq
leaq 0x9e57(%rip), %rcx      # 0x17b80
movq (%rcx,%rax,8), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *(%rax)
movq %rax, %r15
testq %rax, %rax
jne 0xde4f
movq 0xa2a8(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x3834(%rip), %rsi      # 0x11586
xorl %r15d, %r15d
movq %r12, %rdx
xorl %eax, %eax
callq 0x9480
jmp 0xde4f
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x120(%rsp), %rax
movq %rax, 0x18(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, 0x10(%rsp)
testl %ebp, %ebp
js 0xdded
leaq 0x9deb(%rip), %r12      # 0x17b80
movl %ebp, %ebp
cmpb $0x1, 0xe(%rsp,%rbp)
je 0xde34
movq (%r12,%rbp,8), %r13
movq %rbx, %rdi
movq %r14, %rsi
callq *(%r13)
testq %rax, %rax
jne 0xde40
movb $0x1, 0xe(%rsp,%rbp)
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0xddd9
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0xdde7
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
movl (%rax), %ebp
testl %ebp, %ebp
jns 0xdd95
cmpl $-0x1, %ebp
jne 0xde2a
movb $0x1, %bpl
xorl %r12d, %r12d
leaq 0x9d81(%rip), %r13      # 0x17b80
cmpb $0x0, 0xe(%rsp,%r12)
jne 0xde19
movq (%r13,%r12,8), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *(%rax)
testq %rax, %rax
jne 0xde36
movl $0x1, %r12d
testb $0x1, %bpl
movl $0x0, %ebp
jne 0xddff
callq 0x99fe
xorl %r15d, %r15d
jmp 0xde4f
jmp 0xde34
movq %rax, %r15
movq (%r13,%r12,8), %r13
jmp 0xde43
movq %rax, %r15
movq %r13, 0x8(%r15)
movq %rbx, 0x10(%r15)
movq %r14, 0x18(%r15)
movq %r15, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq