// File: stetre[P]moonvulkan/src/buffer_view.c
// Function: Create
static int Create(lua_State *L)
    {
    int err;
    ud_t *ud, *buffer_ud;
    VkResult ec;
    VkBufferView buffer_view;
    VkBufferViewCreateInfo* info;

    VkBuffer buffer = checkbuffer(L, 1, &buffer_ud);
    VkDevice device = buffer_ud->device;
    const VkAllocationCallbacks *allocator = optallocator(L, 3);

#define CLEANUP zfreeVkBufferViewCreateInfo(L, info, 1)
    info = zcheckVkBufferViewCreateInfo(L, 2, &err);
    if(err) { CLEANUP; return argerror(L, 2); }
    info->buffer = buffer;

    ec = buffer_ud->ddt->CreateBufferView(device, info, allocator, &buffer_view);
    CLEANUP;
    CheckError(L, ec);
#undef CLEANUP
    TRACE_CREATE(buffer_view, "buffer_view");
    ud = newuserdata_nondispatchable(L, buffer_view, BUFFER_VIEW_MT);
    ud->parent_ud = buffer_ud;
    ud->device = device;
    ud->instance = UD(device)->instance;
    ud->allocator = allocator;
    ud->destructor = freebuffer_view;
    ud->ddt = buffer_ud->ddt;
    return 1;
    }

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq 0x58(%rsp), %rdi
movl $0x1, %esi
leaq 0x40(%rsp), %rdx
leaq 0xb4021(%rip), %rcx     # 0xcf000
callq 0x1a640
movq %rax, 0x20(%rsp)
movq 0x40(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x58(%rsp), %rdi
movl $0x3, %esi
callq 0x19260
movq %rax, 0x10(%rsp)
movq 0x58(%rsp), %rdi
movl $0x2, %esi
leaq 0x54(%rsp), %rdx
callq 0x19a80
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x54(%rsp)
je 0x1b077
movq 0x58(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
movq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x58(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %edx
callq 0x186d0
movq 0x8(%rsp), %rdi
movq %rax, %rdx
movl $0x2, %esi
callq 0x18460
movl %eax, 0x64(%rsp)
jmp 0x1b19a
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x40(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x118(%rax), %rax
movq 0x18(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x30(%rsp), %rcx
callq *%rax
movl %eax, 0x3c(%rsp)
movq 0x58(%rsp), %rdi
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x19210
cmpl $0x0, 0x3c(%rsp)
je 0x1b0ed
movq 0x58(%rsp), %rdi
movl 0x3c(%rsp), %edx
xorl %esi, %esi
callq 0x18a00
movq 0x58(%rsp), %rdi
callq 0x19ad0
movl %eax, 0x64(%rsp)
jmp 0x1b19a
jmp 0x1b0ef
jmp 0x1b0f1
movq 0xe1ea0(%rip), %rax     # 0xfcf98
cmpl $0x0, (%rax)
je 0x1b110
movq 0x30(%rsp), %rsi
leaq 0xb3fb2(%rip), %rdi     # 0xcf0bb
movb $0x0, %al
callq 0x189d0
jmp 0x1b112
movq 0x58(%rsp), %rdi
movq 0x30(%rsp), %rsi
leaq 0xb3f42(%rip), %rdx     # 0xcf065
xorl %ecx, %ecx
callq 0x18350
movq %rax, 0x48(%rsp)
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x18(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x18(%rsp), %rdi
callq 0x19fd0
movq 0x18(%rax), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x10(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x40(%rax)
movq 0x48(%rsp), %rax
leaq 0x74(%rip), %rcx        # 0x1b1f0
movq %rcx, 0x8(%rax)
movq 0x40(%rsp), %rax
movq 0x50(%rax), %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x50(%rax)
movl $0x1, 0x64(%rsp)
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)