// File: /workspace/github_c_makefile_star2_O3/stetre[P]moonglmath/src/hostmem.c
// Function: Create
static int Create(lua_State *L, int arg, size_t alignment)
    {
    const char *data = NULL;
    char *ptr;
    size_t size;
    (void)alignment;

    if(lua_type(L, arg) == LUA_TSTRING)
        {
        if(!lua_isnoneornil(L, arg+1))
            return CreatePack(L, arg, alignment);
    
        data = luaL_checklstring(L, arg, &size);
        if(size == 0) 
            return luaL_argerror(L, arg, errstring(ERR_LENGTH));
        }
    else
        {
        size = luaL_checkinteger(L, arg);
        if(size == 0) 
            return luaL_argerror(L, arg, errstring(ERR_VALUE));
        }
#if defined(MACOS) /* @@TODO */
    ptr = (char*)Malloc(L, size);
#else
    ptr = (char*)AlignedAlloc(alignment, size);
#endif
    if(!ptr)
        return luaL_error(L, "failed to allocate page aligned memory");
            
    if(data)
        memcpy(ptr, data, size);
    else
        memset(ptr, 0, size);

    CreateAllocated(L, ptr, size);
    return 1;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movl %esi, %r12d
movq %rdi, %rbx
callq 0x8c40
cmpl $0x4, %eax
jne 0xd53b
leal 0x1(%r12), %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x8c40
testl %eax, %eax
jle 0xd58e
movq %rbx, %rdi
movl $0x1, %esi
movl %r12d, %edx
callq 0x8050
movl %eax, %r12d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x8490
movslq %eax, %r13
movl %r12d, %edi
callq 0x8220
movq %rax, %r15
imulq %r13, %r15
testq %r15, %r15
je 0xd5fb
movq %r14, %rdi
movq %r15, %rsi
callq 0x8ca0
testq %rax, %rax
je 0xd620
movq %rax, %r14
movq %rbx, %rdi
movl %r12d, %esi
movq %r13, %rdx
movq %rax, %rcx
movq %r15, %r8
callq 0x85b0
testl %eax, %eax
je 0xd576
movl %eax, %r12d
movq %r14, %rdi
callq 0x8090
movl %r12d, %edi
jmp 0xd600
movq %rbx, %rdi
movl %r12d, %esi
callq 0x86e0
movq %rax, (%rsp)
testq %rax, %rax
je 0xd5d6
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x8ca0
movq %rax, %r14
testq %rax, %rax
je 0xd5e8
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x84f0
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xd666
movl $0x1, %eax
jmp 0xd657
movq %rsp, %r15
movq %rbx, %rdi
movl %r12d, %esi
movq %r15, %rdx
callq 0x85c0
movq (%r15), %r15
testq %r15, %r15
je 0xd63f
movq %rax, %r13
movq %r14, %rdi
movq %r15, %rsi
callq 0x8ca0
testq %rax, %rax
je 0xd5e8
movq %rax, %r14
testq %r13, %r13
je 0xd569
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x8760
jmp 0xd576
movl $0xfffffffd, %edi       # imm = 0xFFFFFFFD
callq 0x8510
movq %rbx, %rdi
movl %r12d, %esi
jmp 0xd60a
leaq 0x9e6e(%rip), %rsi      # 0x1745d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x8a80
jmp 0xd657
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
callq 0x8510
movq %rbx, %rdi
movl %ebp, %esi
movq %rax, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x81b0
leaq 0x9e36(%rip), %rsi      # 0x1745d
movq %rbx, %rdi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8a80
movl $0xfffffff8, %edi       # imm = 0xFFFFFFF8
callq 0x8510
movq %rbx, %rdi
movl %r12d, %esi
movq %rax, %rdx
callq 0x81b0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq