fn codegen_atomic_cxchg(
        &mut self,
        intrinsic: &str,
        mut fargs: Vec<Expr>,
        p: &Place<'tcx>,
        loc: Location,
    ) -> Stmt {
        emit_concurrency_warning!(intrinsic, loc);
        let var1_ref = fargs.remove(0);
        let var1 = var1_ref.dereference().with_location(loc.clone());
        let tmp = self.gen_temp_variable(var1.typ().clone(), loc.clone()).to_expr();
        let decl_stmt = Stmt::decl(tmp.clone(), Some(var1.to_owned()), loc.clone());
        let var2 = fargs.remove(0).with_location(loc.clone());
        let var3 = fargs.remove(0).with_location(loc.clone());
        let eq_expr = (var1.clone()).eq(var2.clone());
        let assign_stmt = (var1.clone()).assign(var3, loc.clone());
        let cond_update_stmt = Stmt::if_then_else(eq_expr, assign_stmt, None, loc.clone());
        let place_type = self.place_ty(p);
        let res_type = self.codegen_ty(place_type);
        let tuple_expr =
            Expr::struct_expr_from_values(res_type, vec![tmp, Expr::c_true()], &self.symbol_table)
                .with_location(loc.clone());
        let res_stmt = self.codegen_expr_to_place(p, tuple_expr);
        Stmt::atomic_block(vec![decl_stmt, cond_update_stmt, res_stmt], loc)
    }
/// An atomic compare-and-exchange updates the value referenced in
/// its primary argument and returns a tuple that contains:
///  * the previous value
///  * a boolean value indicating whether the operation was successful or not
/// In a sequential context, the update is always sucessful so we assume the
/// second value to be true.
/// -------------------------
/// var = atomic_cxchg(var1, var2, var3)
/// -------------------------
/// unsigned char tmp;
/// tmp = *var1;
/// if (*var1 == var2) *var1 = var3;
/// var = (tmp, true);
/// -------------------------
An atomic compare-and-exchange updates the value referenced in
its primary argument and returns a tuple that contains:
the previous value
a boolean value indicating whether the operation was successful or not
In a sequential context, the update is always sucessful so we assume the
second value to be true.

var = atomic_cxchg(var1, var2, var3)


An atomic compare - and - exchange updates the value referenced in its primary argument and returns a tuple that contains : the previous value a boolean value indicating whether the operation was successful or not In a sequential context the update is always sucessful so we assume the second value to be true . var = atomic_cxchg ( var1 var2 var3 )
fn codegen_atomic_cxchg(
        &mut self,
        intrinsic: &str,
        mut fargs: Vec<Expr>,
        p: &Place<'tcx>,
        loc: Location,
    ) -> Stmt {
        emit_concurrency_warning!(intrinsic, loc);
        let var1_ref = fargs.remove(0);
        let var1 = var1_ref.dereference().with_location(loc.clone());
        let tmp = self.gen_temp_variable(var1.typ().clone(), loc.clone()).to_expr();
        let decl_stmt = Stmt::decl(tmp.clone(), Some(var1.to_owned()), loc.clone());
        let var2 = fargs.remove(0).with_location(loc.clone());
        let var3 = fargs.remove(0).with_location(loc.clone());
        let eq_expr = (var1.clone()).eq(var2.clone());
        let assign_stmt = (var1.clone()).assign(var3, loc.clone());
        let cond_update_stmt = Stmt::if_then_else(eq_expr, assign_stmt, None, loc.clone());
        let place_type = self.place_ty(p);
        let res_type = self.codegen_ty(place_type);
        let tuple_expr =
            Expr::struct_expr_from_values(res_type, vec![tmp, Expr::c_true()], &self.symbol_table)
                .with_location(loc.clone());
        let res_stmt = self.codegen_expr_to_place(p, tuple_expr);
        Stmt::atomic_block(vec![decl_stmt, cond_update_stmt, res_stmt], loc)
    }
fn codegen_atomic_cxchg ( & mut self , intrinsic : & str , mut fargs : Vec < Expr > , p : & Place < ' tcx > , loc : Location , ) -> Stmt { emit_concurrency_warning ! ( intrinsic loc ) ; let var1_ref = fargs . remove ( 0 ) ; let var1 = var1_ref . dereference ( ) . with_location ( loc . clone ( ) ) ; let tmp = self . gen_temp_variable ( var1 . typ ( ) . clone ( ) , loc . clone ( ) ) . to_expr ( ) ; let decl_stmt = Stmt :: decl ( tmp . clone ( ) , Some ( var1 . to_owned ( ) ) , loc . clone ( ) ) ; let var2 = fargs . remove ( 0 ) . with_location ( loc . clone ( ) ) ; let var3 = fargs . remove ( 0 ) . with_location ( loc . clone ( ) ) ; let eq_expr = ( var1 . clone ( ) ) . eq ( var2 . clone ( ) ) ; let assign_stmt = ( var1 . clone ( ) ) . assign ( var3 , loc . clone ( ) ) ; let cond_update_stmt = Stmt :: if_then_else ( eq_expr , assign_stmt , None , loc . clone ( ) ) ; let place_type = self . place_ty ( p ) ; let res_type = self . codegen_ty ( place_type ) ; let tuple_expr = Expr :: struct_expr_from_values ( res_type , vec ! [ tmp Expr c_true ( ) ] , & self . symbol_table ) . with_location ( loc . clone ( ) ) ; let res_stmt = self . codegen_expr_to_place ( p , tuple_expr ) ; Stmt :: atomic_block ( vec ! [ decl_stmt cond_update_stmt res_stmt ] , loc ) }
An atomic compare-and-exchange updates the value referenced in
its primary argument and returns a tuple that contains:
 the previous value
 a boolean value indicating whether the operation was successful or not
In a sequential context, the update is always sucessful so we assume the
second value to be true.
An atomic compare - and - exchange updates the value referenced in its primary argument and returns a tuple that contains : the previous value a boolean value indicating whether the operation was successful or not In a sequential context the update is always sucessful so we assume the second value to be true .
&mut self
intrinsic
&str
fargs
Vec<Expr>
p
&Place<'tcx>
loc
Location