def fix_index(builder, idx, size):
 is_negative = builder.icmp_signed('<', idx, ir.Constant(size.type, 0))
 wrapped_index = builder.add(idx, size)
 return builder.select(is_negative, wrapped_index, idx)

def fix_index ( builder , idx , size ) : is_negative = builder . icmp_signed ( '<' , idx , ir . Constant ( size . type , 0 ) ) wrapped_index = builder . add ( idx , size ) return builder . select ( is_negative , wrapped_index , idx )
fix negative index by adding *size* to it .