// File: /workspace/github_c_makefile_star2_O2/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 0xd333
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)
andw $0x0, 0xe(%rsp)
callq 0x9750
testq %rax, %rax
je 0xd39f
movq %rax, %r14
leaq 0x423f(%rip), %rdi      # 0x1158c
callq 0x9030
testq %rax, %rax
je 0xd3a7
movq %rax, %r12
movq %rax, %rdi
callq 0xd27c
cltq
leaq 0xb815(%rip), %rcx      # 0x18b80
movq (%rcx,%rax,8), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *(%rax)
movq %rax, %r15
testq %rax, %rax
jne 0xd49c
movq 0xbc66(%rip), %rax      # 0x18ff0
movq (%rax), %rdi
leaq 0x420e(%rip), %rsi      # 0x115a2
xorl %r15d, %r15d
movq %r12, %rdx
jmp 0xd495
xorl %r15d, %r15d
jmp 0xd49c
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)
leaq 0xb7ac(%rip), %r12      # 0x18b80
movl %ebp, %r13d
testl %ebp, %ebp
js 0xd42a
cmpb $0x1, 0xe(%rsp,%r13)
je 0xd428
movq (%r12,%r13,8), %rbp
movq %rbx, %rdi
movq %r14, %rsi
callq *(%rbp)
testq %rax, %rax
jne 0xd45f
movb $0x1, 0xe(%rsp,%r13)
movl 0x10(%rsp), %ecx
cmpq $0x28, %rcx
ja 0xd416
movq %rcx, %rax
addq 0x20(%rsp), %rax
addl $0x8, %ecx
movl %ecx, 0x10(%rsp)
jmp 0xd424
movq 0x18(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x18(%rsp)
movl (%rax), %ebp
jmp 0xd3d4
jmp 0xd428
cmpl $-0x1, %r13d
jne 0xd47a
leaq 0xe(%rsp), %rbp
xorl %r13d, %r13d
cmpq $0x10, %r13
je 0xd47a
cmpb $0x0, (%rbp)
jne 0xd456
movq (%r13,%r12), %rax
movq %rbx, %rdi
movq %r14, %rsi
callq *(%rax)
testq %rax, %rax
jne 0xd464
addq $0x8, %r13
incq %rbp
jmp 0xd438
movq %rax, %r15
jmp 0xd46c
movq %rax, %r15
movq (%r13,%r12), %rbp
movq %rbp, 0x8(%r15)
movq %rbx, 0x10(%r15)
movq %r14, 0x18(%r15)
jmp 0xd49c
movq 0xbb6f(%rip), %rax      # 0x18ff0
movq (%rax), %rdi
leaq 0x414c(%rip), %rsi      # 0x115d7
leaq 0x4186(%rip), %rdx      # 0x11618
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x9480
movq %r15, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq