|
| 1 | +extern crate libcc2rs; |
| 2 | +use libcc2rs::*; |
| 3 | +use std::cell::RefCell; |
| 4 | +use std::collections::BTreeMap; |
| 5 | +use std::io::prelude::*; |
| 6 | +use std::io::{Read, Seek, Write}; |
| 7 | +use std::os::fd::AsFd; |
| 8 | +use std::rc::{Rc, Weak}; |
| 9 | +pub fn first_nonnull_0(count: i32, args: &[VaArg]) -> i32 { |
| 10 | + let count: Value<i32> = Rc::new(RefCell::new(count)); |
| 11 | + let ap: Value<VaList> = Rc::new(RefCell::new(VaList::default())); |
| 12 | + (*ap.borrow_mut()) = VaList::new(args); |
| 13 | + let result: Value<i32> = Rc::new(RefCell::new(-1_i32)); |
| 14 | + let i: Value<i32> = Rc::new(RefCell::new(0)); |
| 15 | + 'loop_: while ((((*i.borrow()) < (*count.borrow())) as i32) != 0) { |
| 16 | + let p: Value<Ptr<i32>> = |
| 17 | + Rc::new(RefCell::new(((*ap.borrow_mut()).arg::<Ptr<i32>>()).clone())); |
| 18 | + if (((!((*p.borrow()).is_null())) as i32) != 0) { |
| 19 | + let __rhs = ((*p.borrow()).read()); |
| 20 | + (*result.borrow_mut()) = __rhs; |
| 21 | + break; |
| 22 | + } |
| 23 | + (*i.borrow_mut()).postfix_inc(); |
| 24 | + } |
| 25 | + return (*result.borrow()); |
| 26 | +} |
| 27 | +pub fn main() { |
| 28 | + std::process::exit(main_0()); |
| 29 | +} |
| 30 | +fn main_0() -> i32 { |
| 31 | + let x: Value<i32> = Rc::new(RefCell::new(42)); |
| 32 | + assert!( |
| 33 | + (((({ |
| 34 | + let _count: i32 = 2; |
| 35 | + first_nonnull_0( |
| 36 | + _count, |
| 37 | + &[(AnyPtr::default()).into(), (x.as_pointer()).into()], |
| 38 | + ) |
| 39 | + }) == 42) as i32) |
| 40 | + != 0) |
| 41 | + ); |
| 42 | + assert!( |
| 43 | + (((({ |
| 44 | + let _count: i32 = 3; |
| 45 | + first_nonnull_0( |
| 46 | + _count, |
| 47 | + &[ |
| 48 | + (AnyPtr::default()).into(), |
| 49 | + (AnyPtr::default()).into(), |
| 50 | + (x.as_pointer()).into(), |
| 51 | + ], |
| 52 | + ) |
| 53 | + }) == 42) as i32) |
| 54 | + != 0) |
| 55 | + ); |
| 56 | + assert!( |
| 57 | + (((({ |
| 58 | + let _count: i32 = 1; |
| 59 | + first_nonnull_0(_count, &[(AnyPtr::default()).into()]) |
| 60 | + }) == -1_i32) as i32) |
| 61 | + != 0) |
| 62 | + ); |
| 63 | + return 0; |
| 64 | +} |
0 commit comments