<s> from parakeet . testing_helpers import expect , run_local_tests <EOL> def volatile_licm_mistake ( ) : <EOL> i = <NUM_LIT:0> <EOL> x = [ <NUM_LIT:0> ] <EOL> while i < <NUM_LIT:10> : <EOL> alloc = [ <NUM_LIT:1> ] <EOL> if i == <NUM_LIT:5> : <EOL> x = alloc <EOL> else : <EOL> alloc [ <NUM_LIT:0> ] = <NUM_LIT:100> <EOL> i = i + <NUM_LIT:1> <EOL> return x [ <NUM_LIT:0> ] <EOL> def test_volatile_licm_mistake ( ) : <EOL> expect ( volatile_licm_mistake , [ ] , volatile_licm_mistake ( ) ) <EOL> def licm_nested_loops ( ) : <EOL> total = <NUM_LIT:0> <EOL> a = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] <EOL> for _ in range ( <NUM_LIT:3> ) : <EOL> for _ in range ( <NUM_LIT:2> ) : <EOL> for j in range ( len ( a ) ) : <EOL> a [ j ] *= <NUM_LIT:10> <EOL> total += a [ <NUM_LIT:1> ] <EOL> return total <EOL> def test_licm_nested_loops ( ) : <EOL> expect ( licm_nested_loops , [ ] , licm_nested_loops ( ) ) <EOL> def loop_invariant_alloc ( ) : <EOL> b = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> total = <NUM_LIT:0> <EOL> for i in xrange ( <NUM_LIT:3> ) : <EOL> a = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> for j in xrange ( <NUM_LIT:3> ) : <EOL> a [ j ] = b [ j ] <EOL> total += a [ i ] <EOL> return total <EOL> def test_loop_invariant_alloc ( ) : <EOL> expect ( loop_invariant_alloc , [ ] , loop_invariant_alloc ( ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> run_local_tests ( ) </s>
