Skip to content

Instantly share code, notes, and snippets.

@Sh4rK
Sh4rK / ffisort.lua
Created July 21, 2015 17:06
LuaJIT FFI array sort
local function sort(arr, len, elemtype, key)
local INSERTION_THRESHOLD = 32
local function insertionSort(arr, len)
for i = 1, len-1 do
local cur = elemtype(arr[i])
local curKey = key(cur)
local j = i
while j > 0 and key(arr[j-1]) > curKey do
arr[j] = arr[j-1]
*** IR Dump Before Interprocedural Sparse Conditional Constant Propagation ***; ModuleID = 'bug.cpp'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-w64-windows-gnu"
@.str = private unnamed_addr constant [4 x i8] c"%f\0A\00", align 1
; Function Attrs: nounwind uwtable
define void @_Z3fooRd(double* dereferenceable(8) %a) #0 {
ret void
}