def _define_nrt_decref(module, atomic_decr):
 fn_decref = module.get_or_insert_function(incref_decref_ty, name='NRT_decref')
 calldtor = module.add_function(ir.FunctionType(ir.VoidType(), [_pointer_type]), name='NRT_MemInfo_call_dtor')
 builder = ir.IRBuilder(fn_decref.append_basic_block())
 [ptr] = fn_decref.args
 is_null = builder.icmp_unsigned('==', ptr, cgutils.get_null_value(ptr.type))
 with cgutils.if_unlikely(builder, is_null):
  builder.ret_void()
 if _debug_print:
  cgutils.printf(builder, '*** NRT_Decref %zu [%p]\n', builder.load(ptr), ptr)
 newrefct = builder.call(atomic_decr, [builder.bitcast(ptr, atomic_decr.args[0].type)])
 refct_eq_0 = builder.icmp_unsigned('==', newrefct, ir.Constant(newrefct.type, 0))
 with cgutils.if_unlikely(builder, refct_eq_0):
  builder.call(calldtor, [ptr])
 builder.ret_void()

def _define_nrt_decref ( module , atomic_decr ) : fn_decref = module . get_or_insert_function ( incref_decref_ty , name = 'NRT_decref' ) calldtor = module . add_function ( ir . FunctionType ( ir . VoidType ( ) , [ _pointer_type ] ) , name = 'NRT_MemInfo_call_dtor' ) builder = ir . IRBuilder ( fn_decref . append_basic_block ( ) ) [ ptr ] = fn_decref . args is_null = builder . icmp_unsigned ( '==' , ptr , cgutils . get_null_value ( ptr . type ) ) with cgutils . if_unlikely ( builder , is_null ) : builder . ret_void ( ) if _debug_print : cgutils . printf ( builder , '*** NRT_Decref %zu [%p]\n' , builder . load ( ptr ) , ptr ) newrefct = builder . call ( atomic_decr , [ builder . bitcast ( ptr , atomic_decr . args [ 0 ] . type ) ] ) refct_eq_0 = builder . icmp_unsigned ( '==' , newrefct , ir . Constant ( newrefct . type , 0 ) ) with cgutils . if_unlikely ( builder , refct_eq_0 ) : builder . call ( calldtor , [ ptr ] ) builder . ret_void ( )
implement nrt_decref in the module .