//! > Check that literals are moved to the right arm.

//! > test_runner_name
test_delay_var_def

//! > function
fn foo() -> felt252 {
   let opt = get_option();

   let unused = 17;
   let unused2 = ();

   let one = 1;
   let two = 2;
   let three = 3;

   match opt {
        Option::Some(_) => one + two,
        Option::None(_) => {
            let four = 4;
            match opt {
                Option::Some(_) => three + four,
                Option::None(_) => one,
            }
        }
   }
}

//! > function_name
foo

//! > module_code
extern fn get_option() -> Option<u16> nopanic;

//! > semantic_diagnostics

//! > lowering_diagnostics

//! > before
Parameters:
blk0 (root):
Statements:
End:
  Match(match test::get_option() {
    Option::Some(v0) => blk1,
    Option::None => blk2,
  })

blk1:
Statements:
  (v1: core::option::Option::<core::integer::u16>) <- Option::Some(v0)
End:
  Goto(blk3, {v1 -> v4})

blk2:
Statements:
  (v2: ()) <- struct_construct()
  (v3: core::option::Option::<core::integer::u16>) <- Option::None(v2)
End:
  Goto(blk3, {v3 -> v4})

blk3:
Statements:
  (v5: core::felt252) <- 17u
  (v6: ()) <- struct_construct()
  (v7: core::felt252) <- 1u
  (v8: core::felt252) <- 2u
  (v9: core::felt252) <- 3u
End:
  Match(match_enum(v4) {
    Option::Some(v10) => blk4,
    Option::None(v12) => blk5,
  })

blk4:
Statements:
  (v11: core::felt252) <- core::Felt252Add::add(v7, v8)
End:
  Goto(blk9, {v11 -> v18})

blk5:
Statements:
  (v13: core::felt252) <- 4u
End:
  Match(match_enum(v4) {
    Option::Some(v14) => blk6,
    Option::None(v16) => blk7,
  })

blk6:
Statements:
  (v15: core::felt252) <- core::Felt252Add::add(v9, v13)
End:
  Goto(blk8, {v15 -> v17})

blk7:
Statements:
End:
  Goto(blk8, {v7 -> v17})

blk8:
Statements:
End:
  Goto(blk9, {v17 -> v18})

blk9:
Statements:
End:
  Return(v18)

//! > after
Parameters:
blk0 (root):
Statements:
End:
  Match(match test::get_option() {
    Option::Some(v0) => blk1,
    Option::None => blk2,
  })

blk1:
Statements:
  (v1: core::option::Option::<core::integer::u16>) <- Option::Some(v0)
End:
  Goto(blk3, {v1 -> v4})

blk2:
Statements:
  (v2: ()) <- struct_construct()
  (v3: core::option::Option::<core::integer::u16>) <- Option::None(v2)
End:
  Goto(blk3, {v3 -> v4})

blk3:
Statements:
  (v7: core::felt252) <- 1u
End:
  Match(match_enum(v4) {
    Option::Some(v10) => blk4,
    Option::None(v12) => blk5,
  })

blk4:
Statements:
  (v8: core::felt252) <- 2u
  (v11: core::felt252) <- core::Felt252Add::add(v7, v8)
End:
  Goto(blk9, {v11 -> v18})

blk5:
Statements:
End:
  Match(match_enum(v4) {
    Option::Some(v14) => blk6,
    Option::None(v16) => blk7,
  })

blk6:
Statements:
  (v9: core::felt252) <- 3u
  (v13: core::felt252) <- 4u
  (v15: core::felt252) <- core::Felt252Add::add(v9, v13)
End:
  Goto(blk8, {v15 -> v17})

blk7:
Statements:
End:
  Goto(blk8, {v7 -> v17})

blk8:
Statements:
End:
  Goto(blk9, {v17 -> v18})

blk9:
Statements:
End:
  Return(v18)
