// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
testb %al, %al
je 0x10e7e
movaps %xmm0, -0xd0(%rbp)
movaps %xmm1, -0xc0(%rbp)
movaps %xmm2, -0xb0(%rbp)
movaps %xmm3, -0xa0(%rbp)
movaps %xmm4, -0x90(%rbp)
movaps %xmm5, -0x80(%rbp)
movaps %xmm6, -0x70(%rbp)
movaps %xmm7, -0x60(%rbp)
movq %r9, -0xd8(%rbp)
movq %r8, -0xe0(%rbp)
movq %rcx, -0xe8(%rbp)
movq %rdx, -0xf0(%rbp)
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
leaq -0x42(%rbp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x93c0
movq -0x10(%rbp), %rdi
callq 0x9770
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x10ed9
movq $0x0, -0x8(%rbp)
jmp 0x11122
leaq 0x41b8(%rip), %rdi      # 0x15098
callq 0x9030
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x10f57
movq -0x50(%rbp), %rdi
callq 0x10dc0
movl %eax, -0x14(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0xb5aa(%rip), %rax      # 0x1c4b0
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq *%rax
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x10f2e
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x11122
movq 0xb0bb(%rip), %rax      # 0x1bff0
movq (%rax), %rdi
movq -0x50(%rbp), %rdx
leaq 0x416b(%rip), %rsi      # 0x150ae
movb $0x0, %al
callq 0x94a0
movq $0x0, -0x8(%rbp)
jmp 0x11122
leaq -0x40(%rbp), %rax
leaq -0x100(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x10, (%rax)
cmpl $0x0, -0x14(%rbp)
jl 0x11041
movslq -0x14(%rbp), %rax
testb $0x1, -0x42(%rbp,%rax)
jne 0x10fa2
movslq -0x14(%rbp), %rcx
leaq 0xb515(%rip), %rax      # 0x1c4b0
cmpq $0x0, (%rax,%rcx,8)
jne 0x10fa4
jmp 0x10f7b
movslq -0x14(%rbp), %rcx
leaq 0xb501(%rip), %rax      # 0x1c4b0
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq *%rax
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x10fcf
jmp 0x110eb
movslq -0x14(%rbp), %rax
movb $0x1, -0x42(%rbp,%rax)
leaq -0x40(%rbp), %rax
movq %rax, -0x110(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x104(%rbp)
cmpl $0x28, %eax
ja 0x11013
movq -0x110(%rbp), %rcx
movl -0x104(%rbp), %edx
movslq %edx, %rax
addq 0x10(%rcx), %rax
addl $0x8, %edx
movl %edx, (%rcx)
movq %rax, -0x118(%rbp)
jmp 0x11030
movq -0x110(%rbp), %rcx
movq 0x8(%rcx), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, 0x8(%rcx)
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
jmp 0x10f7b
leaq -0x40(%rbp), %rax
cmpq $0x0, -0x20(%rbp)
jne 0x110b9
cmpl $-0x1, -0x14(%rbp)
jne 0x110b9
movl $0x0, -0x14(%rbp)
movslq -0x14(%rbp), %rax
cmpq $0x2, %rax
jae 0x110b7
movslq -0x14(%rbp), %rax
testb $0x1, -0x42(%rbp,%rax)
jne 0x11080
movslq -0x14(%rbp), %rcx
leaq 0xb437(%rip), %rax      # 0x1c4b0
cmpq $0x0, (%rax,%rcx,8)
jne 0x11082
jmp 0x110ac
movslq -0x14(%rbp), %rcx
leaq 0xb423(%rip), %rax      # 0x1c4b0
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq *%rax
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x110aa
jmp 0x110b7
jmp 0x110ac
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x11059
jmp 0x110b9
cmpq $0x0, -0x20(%rbp)
jne 0x110e9
movq 0xaf29(%rip), %rax      # 0x1bff0
movq (%rax), %rdi
leaq 0x4012(%rip), %rsi      # 0x150e3
leaq 0x404c(%rip), %rdx      # 0x15124
movb $0x0, %al
callq 0x94a0
movq $0x0, -0x8(%rbp)
jmp 0x11122
jmp 0x110eb
movslq -0x14(%rbp), %rcx
leaq 0xb3ba(%rip), %rax      # 0x1c4b0
movq (%rax,%rcx,8), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nop