summaryrefslogtreecommitdiff
path: root/test/passes/O.bin.txt
blob: fc4724490ced9f53fb0ff5dd1d04434f1727bc6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
(module
 (type $0 (func (param i64) (result i64)))
 (export "fac-rec" (func $0))
 (export "fac-rec-named" (func $1))
 (export "fac-iter" (func $2))
 (export "fac-iter-named" (func $3))
 (export "fac-opt" (func $4))
 (func $0 (param $0 i64) (result i64)
  (if (result i64)
   (i64.eqz
    (local.get $0)
   )
   (then
    (i64.const 1)
   )
   (else
    (i64.mul
     (call $0
      (i64.sub
       (local.get $0)
       (i64.const 1)
      )
     )
     (local.get $0)
    )
   )
  )
 )
 (func $1 (param $0 i64) (result i64)
  (if (result i64)
   (i64.eqz
    (local.get $0)
   )
   (then
    (i64.const 1)
   )
   (else
    (i64.mul
     (call $1
      (i64.sub
       (local.get $0)
       (i64.const 1)
      )
     )
     (local.get $0)
    )
   )
  )
 )
 (func $2 (param $0 i64) (result i64)
  (unreachable)
 )
 (func $3 (param $0 i64) (result i64)
  (local $1 i64)
  (local.set $1
   (i64.const 1)
  )
  (loop $label
   (if
    (i32.eqz
     (i64.eqz
      (local.get $0)
     )
    )
    (then
     (local.set $1
      (i64.mul
       (local.get $0)
       (local.get $1)
      )
     )
     (local.set $0
      (i64.sub
       (local.get $0)
       (i64.const 1)
      )
     )
     (br $label)
    )
   )
  )
  (local.get $1)
 )
 (func $4 (param $0 i64) (result i64)
  (local $1 i64)
  (local.set $1
   (i64.const 1)
  )
  (if
   (i64.ge_s
    (local.get $0)
    (i64.const 2)
   )
   (then
    (loop $label
     (local.set $1
      (i64.mul
       (local.get $0)
       (local.get $1)
      )
     )
     (br_if $label
      (i64.gt_s
       (local.tee $0
        (i64.sub
         (local.get $0)
         (i64.const 1)
        )
       )
       (i64.const 1)
      )
     )
    )
   )
  )
  (local.get $1)
 )
)