summaryrefslogtreecommitdiff
path: root/base/QuickSort.opt.vapor
blob: 6e14e5a541ddc3b3e24837bf3d1ca37a7a302ccc (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378

const empty_QS


func Main()
  t.0 = HeapAllocZ(8)
  if t.0 goto :null1
    Error("null pointer")
  null1:
  t.1 = call :QS.Start(t.0 10)
  PrintIntS(t.1)
  ret

func QS.Start(this sz)
  aux01 = call :QS.Init(this sz)
  aux01 = call :QS.Print(this)
  PrintIntS(9999)
  t.0 = [this+4]
  aux01 = Sub(t.0 1)
  aux01 = call :QS.Sort(this 0 aux01)
  aux01 = call :QS.Print(this)
  ret 0

func QS.Sort(this left right)
  t = 0
  t.0 = LtS(left right)
  if0 t.0 goto :if1_else
    t.1 = [this+0]
    if t.1 goto :null2
      Error("null pointer")
    null2:
    t.2 = [t.1]
    t.2 = Lt(right t.2)
    if t.2 goto :bounds1
      Error("array index out of bounds")
    bounds1:
    t.2 = MulS(right 4)
    t.2 = Add(t.2 t.1)
    v = [t.2+4]
    i = Sub(left 1)
    j = right
    cont01 = 1
    while1_top:
    if0 cont01 goto :while1_end
      cont02 = 1
      while2_top:
      if0 cont02 goto :while2_end
        i = Add(i 1)
        t.3 = [this+0]
        if t.3 goto :null3
          Error("null pointer")
        null3:
        t.4 = [t.3]
        t.4 = Lt(i t.4)
        if t.4 goto :bounds2
          Error("array index out of bounds")
        bounds2:
        t.4 = MulS(i 4)
        t.4 = Add(t.4 t.3)
        aux03 = [t.4+4]
        t.5 = LtS(aux03 v)
        if t.5 goto :if2_else
          cont02 = 0
          goto :if2_end
        if2_else:
          cont02 = 1
        if2_end:
        goto :while2_top
      while2_end:
      cont02 = 1
      while3_top:
      if0 cont02 goto :while3_end
        j = Sub(j 1)
        t.6 = [this+0]
        if t.6 goto :null4
          Error("null pointer")
        null4:
        t.7 = [t.6]
        t.7 = Lt(j t.7)
        if t.7 goto :bounds3
          Error("array index out of bounds")
        bounds3:
        t.7 = MulS(j 4)
        t.7 = Add(t.7 t.6)
        aux03 = [t.7+4]
        t.8 = LtS(v aux03)
        if t.8 goto :if3_else
          cont02 = 0
          goto :if3_end
        if3_else:
          cont02 = 1
        if3_end:
        goto :while3_top
      while3_end:
      t.9 = [this+0]
      if t.9 goto :null5
        Error("null pointer")
      null5:
      t.10 = [t.9]
      t.10 = Lt(i t.10)
      if t.10 goto :bounds4
        Error("array index out of bounds")
      bounds4:
      t.10 = MulS(i 4)
      t.10 = Add(t.10 t.9)
      t = [t.10+4]
      t.11 = [this+0]
      if t.11 goto :null6
        Error("null pointer")
      null6:
      t.12 = [t.11]
      t.12 = Lt(i t.12)
      if t.12 goto :bounds5
        Error("array index out of bounds")
      bounds5:
      t.12 = MulS(i 4)
      t.12 = Add(t.12 t.11)
      t.13 = [this+0]
      if t.13 goto :null7
        Error("null pointer")
      null7:
      t.14 = [t.13]
      t.14 = Lt(j t.14)
      if t.14 goto :bounds6
        Error("array index out of bounds")
      bounds6:
      t.14 = MulS(j 4)
      t.14 = Add(t.14 t.13)
      t.15 = [t.14+4]
      [t.12+4] = t.15
      t.16 = [this+0]
      if t.16 goto :null8
        Error("null pointer")
      null8:
      t.17 = [t.16]
      t.17 = Lt(j t.17)
      if t.17 goto :bounds7
        Error("array index out of bounds")
      bounds7:
      t.17 = MulS(j 4)
      t.17 = Add(t.17 t.16)
      [t.17+4] = t
      t.18 = Add(i 1)
      t.19 = LtS(j t.18)
      if0 t.19 goto :if4_else
        cont01 = 0
        goto :if4_end
      if4_else:
        cont01 = 1
      if4_end:
      goto :while1_top
    while1_end:
    t.20 = [this+0]
    if t.20 goto :null9
      Error("null pointer")
    null9:
    t.21 = [t.20]
    t.21 = Lt(j t.21)
    if t.21 goto :bounds8
      Error("array index out of bounds")
    bounds8:
    t.21 = MulS(j 4)
    t.21 = Add(t.21 t.20)
    t.22 = [this+0]
    if t.22 goto :null10
      Error("null pointer")
    null10:
    t.23 = [t.22]
    t.23 = Lt(i t.23)
    if t.23 goto :bounds9
      Error("array index out of bounds")
    bounds9:
    t.23 = MulS(i 4)
    t.23 = Add(t.23 t.22)
    t.24 = [t.23+4]
    [t.21+4] = t.24
    t.25 = [this+0]
    if t.25 goto :null11
      Error("null pointer")
    null11:
    t.26 = [t.25]
    t.26 = Lt(i t.26)
    if t.26 goto :bounds10
      Error("array index out of bounds")
    bounds10:
    t.26 = MulS(i 4)
    t.26 = Add(t.26 t.25)
    t.27 = [this+0]
    if t.27 goto :null12
      Error("null pointer")
    null12:
    t.28 = [t.27]
    t.28 = Lt(right t.28)
    if t.28 goto :bounds11
      Error("array index out of bounds")
    bounds11:
    t.28 = MulS(right 4)
    t.28 = Add(t.28 t.27)
    t.29 = [t.28+4]
    [t.26+4] = t.29
    t.30 = [this+0]
    if t.30 goto :null13
      Error("null pointer")
    null13:
    t.31 = [t.30]
    t.31 = Lt(right t.31)
    if t.31 goto :bounds12
      Error("array index out of bounds")
    bounds12:
    t.31 = MulS(right 4)
    t.31 = Add(t.31 t.30)
    [t.31+4] = t
    t.32 = Sub(i 1)
    nt = call :QS.Sort(this left t.32)
    t.33 = Add(i 1)
    nt = call :QS.Sort(this t.33 right)
    goto :if1_end
  if1_else:
    nt = 0
  if1_end:
  ret 0

func QS.Print(this)
  j = 0
  while4_top:
  t.0 = [this+4]
  t.1 = LtS(j t.0)
  if0 t.1 goto :while4_end
    t.2 = [this+0]
    if t.2 goto :null14
      Error("null pointer")
    null14:
    t.3 = [t.2]
    t.3 = Lt(j t.3)
    if t.3 goto :bounds13
      Error("array index out of bounds")
    bounds13:
    t.3 = MulS(j 4)
    t.3 = Add(t.3 t.2)
    t.4 = [t.3+4]
    PrintIntS(t.4)
    j = Add(j 1)
    goto :while4_top
  while4_end:
  ret 0

func QS.Init(this sz)
  [this+4] = sz
  t.0 = call :AllocArray(sz)
  [this+0] = t.0
  t.1 = [this+0]
  if t.1 goto :null15
    Error("null pointer")
  null15:
  t.2 = [t.1]
  t.2 = Lt(0 t.2)
  if t.2 goto :bounds14
    Error("array index out of bounds")
  bounds14:
  t.2 = MulS(0 4)
  t.2 = Add(t.2 t.1)
  [t.2+4] = 20
  t.3 = [this+0]
  if t.3 goto :null16
    Error("null pointer")
  null16:
  t.4 = [t.3]
  t.4 = Lt(1 t.4)
  if t.4 goto :bounds15
    Error("array index out of bounds")
  bounds15:
  t.4 = MulS(1 4)
  t.4 = Add(t.4 t.3)
  [t.4+4] = 7
  t.5 = [this+0]
  if t.5 goto :null17
    Error("null pointer")
  null17:
  t.6 = [t.5]
  t.6 = Lt(2 t.6)
  if t.6 goto :bounds16
    Error("array index out of bounds")
  bounds16:
  t.6 = MulS(2 4)
  t.6 = Add(t.6 t.5)
  [t.6+4] = 12
  t.7 = [this+0]
  if t.7 goto :null18
    Error("null pointer")
  null18:
  t.8 = [t.7]
  t.8 = Lt(3 t.8)
  if t.8 goto :bounds17
    Error("array index out of bounds")
  bounds17:
  t.8 = MulS(3 4)
  t.8 = Add(t.8 t.7)
  [t.8+4] = 18
  t.9 = [this+0]
  if t.9 goto :null19
    Error("null pointer")
  null19:
  t.10 = [t.9]
  t.10 = Lt(4 t.10)
  if t.10 goto :bounds18
    Error("array index out of bounds")
  bounds18:
  t.10 = MulS(4 4)
  t.10 = Add(t.10 t.9)
  [t.10+4] = 2
  t.11 = [this+0]
  if t.11 goto :null20
    Error("null pointer")
  null20:
  t.12 = [t.11]
  t.12 = Lt(5 t.12)
  if t.12 goto :bounds19
    Error("array index out of bounds")
  bounds19:
  t.12 = MulS(5 4)
  t.12 = Add(t.12 t.11)
  [t.12+4] = 11
  t.13 = [this+0]
  if t.13 goto :null21
    Error("null pointer")
  null21:
  t.14 = [t.13]
  t.14 = Lt(6 t.14)
  if t.14 goto :bounds20
    Error("array index out of bounds")
  bounds20:
  t.14 = MulS(6 4)
  t.14 = Add(t.14 t.13)
  [t.14+4] = 6
  t.15 = [this+0]
  if t.15 goto :null22
    Error("null pointer")
  null22:
  t.16 = [t.15]
  t.16 = Lt(7 t.16)
  if t.16 goto :bounds21
    Error("array index out of bounds")
  bounds21:
  t.16 = MulS(7 4)
  t.16 = Add(t.16 t.15)
  [t.16+4] = 9
  t.17 = [this+0]
  if t.17 goto :null23
    Error("null pointer")
  null23:
  t.18 = [t.17]
  t.18 = Lt(8 t.18)
  if t.18 goto :bounds22
    Error("array index out of bounds")
  bounds22:
  t.18 = MulS(8 4)
  t.18 = Add(t.18 t.17)
  [t.18+4] = 19
  t.19 = [this+0]
  if t.19 goto :null24
    Error("null pointer")
  null24:
  t.20 = [t.19]
  t.20 = Lt(9 t.20)
  if t.20 goto :bounds23
    Error("array index out of bounds")
  bounds23:
  t.20 = MulS(9 4)
  t.20 = Add(t.20 t.19)
  [t.20+4] = 5
  ret 0

func AllocArray(size)
  bytes = MulS(size 4)
  bytes = Add(bytes 4)
  v = HeapAllocZ(bytes)
  [v] = size
  ret v