ats_void_type
array_ptr_exch__intsz_01527_ats_int_type (ats_ref_type arg0, ats_int_type arg1, ats_int_type arg2) {
/* local vardec */
// ATSlocal_void (tmp36) ;
ATSlocal (ats_size_type, tmp37) ;
ATSlocal (ats_size_type, tmp38) ;

__ats_lab_array_ptr_exch__intsz_01527_ats_int_type:
tmp37 = atspre_size1_of_int1 (arg1) ;
tmp38 = atspre_size1_of_int1 (arg2) ;
/* tmp36 = */ array_ptr_exch_01523_ats_int_type (arg0, tmp37, tmp38) ;
return /* (tmp36) */ ;
} /* end of [array_ptr_exch__intsz_01527_ats_int_type] */
ats_void_type
atslib_randsize_r (ats_ref_type arg0, ats_size_type arg1, ats_ref_type arg2) {
/* local vardec */
// ATSlocal_void (tmp57) ;
ATSlocal (ats_double_type, tmp58) ;
ATSlocal (ats_int_type, tmp59) ;
ATSlocal (ats_ullint_type, tmp60) ;
ATSlocal (ats_double_type, tmp61) ;
ATSlocal (ats_double_type, tmp62) ;
ATSlocal (ats_bool_type, tmp63) ;
ATSlocal (ats_size_type, tmp64) ;

__ats_lab_atslib_randsize_r:
/* ats_double_type tmp58 ; */
tmp59 = atslib_drand48_r (arg0, (&tmp58)) ;
tmp62 = atspre_double_of_size (arg1) ;
tmp61 = atspre_mul_double_double (tmp58, tmp62) ;
tmp60 = atspre_ullint_of_double (tmp61) ;
tmp63 = atspre_lt_size1_size1 (ats_castfn_mac(ats_size_type, ats_castfn_mac(ats_size_type, tmp60)), arg1) ;
if (tmp63) {
ats_ptrget_mac(ats_size_type, arg2) = ats_castfn_mac(ats_size_type, ats_castfn_mac(ats_size_type, tmp60)) ;
} else {
tmp64 = atspre_size1_of_int1 (0) ;
ats_ptrget_mac(ats_size_type, arg2) = tmp64 ;
} /* end of [if] */
return /* (tmp57) */ ;
} /* end of [atslib_randsize_r] */
ats_size_type
loop_4 (ats_int_type arg0, ats_ptr_type arg1, ats_size_type arg2, ats_ref_type arg3) {
/* local vardec */
ATSlocal (ats_size_type, tmp14) ;
ATSlocal (ats_bool_type, tmp15) ;
ATSlocal (ats_ssize_type, tmp16) ;
ATSlocal (ats_bool_type, tmp17) ;
ATSlocal (ats_ptr_type, tmp18) ;
ATSlocal (ats_size_type, tmp19) ;
ATSlocal (ats_bool_type, tmp20) ;
ATSlocal (ats_bool_type, tmp21) ;
ATSlocal (ats_int_type, tmp22) ;
ATSlocal (ats_bool_type, tmp24) ;
ATSlocal (ats_int_type, tmp25) ;

__ats_lab_loop_4:
tmp15 = atspre_gt_size1_int1 (arg2, 0) ;
if (tmp15) {
tmp16 = atslib_fildes_read_err (arg0, arg1, arg2) ;
tmp17 = atspre_gt_ssize1_int1 (tmp16, 0) ;
if (tmp17) {
tmp18 = atspre_padd_size (arg1, ats_castfn_mac(ats_size_type, tmp16)) ;
tmp19 = atspre_sub_size1_size1 (arg2, ats_castfn_mac(ats_size_type, tmp16)) ;
arg0 = arg0 ;
arg1 = tmp18 ;
arg2 = tmp19 ;
arg3 = arg3 ;
goto __ats_lab_loop_4 ; // tail call
} else {
tmp21 = atspre_lt_ssize1_int1 (tmp16, 0) ;
if (tmp21) {
tmp22 = atslib_errno_get () ;
tmp20 = atslib_eq_errno_errno (tmp22, EINTR) ;
} else {
tmp20 = ats_false_bool ;
} /* end of [if] */
if (tmp20) {
arg0 = arg0 ;
arg1 = arg1 ;
arg2 = arg2 ;
arg3 = arg3 ;
goto __ats_lab_loop_4 ; // tail call
} else {
tmp24 = atspre_lt_ssize1_int1 (tmp16, 0) ;
if (tmp24) {
tmp25 = atspre_add_int_int (ats_ptrget_mac(ats_int_type, arg3), 1) ;
ats_ptrget_mac(ats_int_type, arg3) = tmp25 ;
} else {
/* empty */
} /* end of [if] */
tmp14 = arg2 ;
} /* end of [if] */
} /* end of [if] */
} else {
tmp14 = atspre_size1_of_int1 (0) ;
} /* end of [if] */
return (tmp14) ;
} /* end of [loop_4] */
ats_size_type
loop_7 (ats_int_type arg0, ats_ptr_type arg1, ats_size_type arg2, ats_ref_type arg3) {
/* local vardec */
ATSlocal (ats_size_type, tmp35) ;
ATSlocal (ats_bool_type, tmp36) ;
ATSlocal (ats_ssize_type, tmp37) ;
ATSlocal (ats_bool_type, tmp38) ;
ATSlocal (ats_ptr_type, tmp39) ;
ATSlocal (ats_size_type, tmp40) ;
ATSlocal (ats_bool_type, tmp41) ;
ATSlocal (ats_bool_type, tmp42) ;
ATSlocal (ats_int_type, tmp43) ;
ATSlocal (ats_int_type, tmp44) ;

__ats_lab_loop_7:
tmp36 = atspre_gt_size1_int1 (arg2, 0) ;
if (tmp36) {
tmp37 = atslib_fildes_write_err (arg0, arg1, arg2) ;
tmp38 = atspre_gt_ssize1_int1 (tmp37, 0) ;
if (tmp38) {
tmp39 = atspre_padd_size (arg1, ats_castfn_mac(ats_size_type, tmp37)) ;
tmp40 = atspre_sub_size1_size1 (arg2, ats_castfn_mac(ats_size_type, tmp37)) ;
arg0 = arg0 ;
arg1 = tmp39 ;
arg2 = tmp40 ;
arg3 = arg3 ;
goto __ats_lab_loop_7 ; // tail call
} else {
tmp42 = atspre_lt_ssize1_int1 (tmp37, 0) ;
if (tmp42) {
tmp43 = atslib_errno_get () ;
tmp41 = atslib_eq_errno_errno (tmp43, EINTR) ;
} else {
tmp41 = ats_true_bool ;
} /* end of [if] */
if (tmp41) {
arg0 = arg0 ;
arg1 = arg1 ;
arg2 = arg2 ;
arg3 = arg3 ;
goto __ats_lab_loop_7 ; // tail call
} else {
tmp44 = atspre_add_int_int (ats_ptrget_mac(ats_int_type, arg3), 1) ;
ats_ptrget_mac(ats_int_type, arg3) = tmp44 ;
tmp35 = arg2 ;
} /* end of [if] */
} /* end of [if] */
} else {
tmp35 = atspre_size1_of_int1 (0) ;
} /* end of [if] */
return (tmp35) ;
} /* end of [loop_7] */
ats_ptr_type
ATS_2d0_2e2_2e10_2libc_2SATS_2random_2esats__randperm (ats_int_type arg0) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp20) ;
ATSlocal (ats_size_type, tmp21) ;
ATSlocal (ats_ptr_type, tmp22) ;
ATSlocal (ats_ptr_type, tmp24) ;
// ATSlocal_void (tmp29) ;
// ATSlocal_void (tmp50) ;

__ats_lab_ATS_2d0_2e2_2e10_2libc_2SATS_2random_2esats__randperm:
tmp21 = atspre_size1_of_int1 (arg0) ;
tmp22 = array_ptr_alloc_01535_ats_int_type (tmp21) ;
tmp24 = ats_selsin_mac(tmp22, atslab_2) ;
/* tmp29 = */ loop_5 (arg0, tmp24, 0) ;
/* tmp50 = */ loop_6 (arg0, tmp24, 0) ;
tmp20 = tmp24 ;
return (tmp20) ;
} /* end of [ATS_2d0_2e2_2e10_2libc_2SATS_2random_2esats__randperm] */
ats_size_type
atslib_randsize (ats_size_type arg0) {
/* local vardec */
ATSlocal (ats_size_type, tmp14) ;
ATSlocal (ats_double_type, tmp15) ;
ATSlocal (ats_ullint_type, tmp16) ;
ATSlocal (ats_double_type, tmp17) ;
ATSlocal (ats_double_type, tmp18) ;
ATSlocal (ats_bool_type, tmp19) ;

__ats_lab_atslib_randsize:
tmp15 = atslib_drand48 () ;
tmp18 = atspre_double_of_size (arg0) ;
tmp17 = atspre_mul_double_double (tmp15, tmp18) ;
tmp16 = atspre_ullint_of_double (tmp17) ;
tmp19 = atspre_lt_size1_size1 (ats_castfn_mac(ats_size_type, ats_castfn_mac(ats_size_type, tmp16)), arg0) ;
if (tmp19) {
tmp14 = ats_castfn_mac(ats_size_type, ats_castfn_mac(ats_size_type, tmp16)) ;
} else {
tmp14 = atspre_size1_of_int1 (0) ;
} /* end of [if] */
return (tmp14) ;
} /* end of [atslib_randsize] */