1contract c {
2    struct Nested {
3        uint256 x;
4        uint256 y;
5    }
6    struct Struct {
7        uint256 a;
8        Nested nested;
9        uint256 c;
10    }
11    mapping(uint256 => Struct) data;
12
13    function set(uint256 k) public returns (bool) {
14        data[k].a = 1;
15        data[k].nested.x = 3;
16        data[k].nested.y = 4;
17        data[k].c = 2;
18        return true;
19    }
20
21    function copy(uint256 from, uint256 to) public returns (bool) {
22        data[to] = data[from];
23        return true;
24    }
25
26    function retrieve(uint256 k)
27        public
28        returns (uint256 a, uint256 x, uint256 y, uint256 c)
29    {
30        a = data[k].a;
31        x = data[k].nested.x;
32        y = data[k].nested.y;
33        c = data[k].c;
34    }
35}
36
37// ====
38// compileViaYul: also
39// ----
40// set(uint256): 7 -> true
41// gas irOptimized: 110011
42// gas legacy: 110616
43// gas legacyOptimized: 110006
44// retrieve(uint256): 7 -> 1, 3, 4, 2
45// copy(uint256,uint256): 7, 8 -> true
46// gas irOptimized: 118707
47// gas legacy: 119166
48// gas legacyOptimized: 118622
49// retrieve(uint256): 7 -> 1, 3, 4, 2
50// retrieve(uint256): 8 -> 1, 3, 4, 2
51// copy(uint256,uint256): 0, 7 -> true
52// retrieve(uint256): 7 -> 0, 0, 0, 0
53// retrieve(uint256): 8 -> 1, 3, 4, 2
54// copy(uint256,uint256): 7, 8 -> true
55// retrieve(uint256): 8 -> 0, 0, 0, 0
56