def memset(builder, ptr, size, value):
 sizety = size.type
 memset = ('llvm.memset.p0i8.i%d' % sizety.width)
 fn = builder.module.declare_intrinsic('llvm.memset', (voidptr_t, size.type))
 ptr = builder.bitcast(ptr, voidptr_t)
 if isinstance(value, int):
  value = int8_t(value)
 builder.call(fn, [ptr, value, size, int32_t(0), bool_t(0)])

def memset ( builder , ptr , size , value ) : sizety = size . type memset = ( 'llvm.memset.p0i8.i%d' % sizety . width ) fn = builder . module . declare_intrinsic ( 'llvm.memset' , ( voidptr_t , size . type ) ) ptr = builder . bitcast ( ptr , voidptr_t ) if isinstance ( value , int ) : value = int8_t ( value ) builder . call ( fn , [ ptr , value , size , int32_t ( 0 ) , bool_t ( 0 ) ] )
fill *size* bytes starting from *ptr* with *value* .