aboutsummaryrefslogtreecommitdiff
path: root/tools/test-js-optimizer-asm-regs.js
blob: 8c3a1c9880baf9173a1926d85400ccc8936ba63d (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
function asm(x, y) {
  x = +x;
  y = y | 0;
  var int1 = 0, int2 = 0; // do not mix the types!
  var double1 = +0, double2 = +0;
  int1 = (x+x)|0;
  double1 = d(Math.max(10, Math_min(5, f())));
  int2 = (int1+2)|0;
  print(int2);
  double2 = double1*5;
  return double2;
}
function _doit($x, $y$0, $y$1) {
  $x = $x | 0;
  $y$0 = $y$0 | 0;
  $y$1 = $y$1 | 0;
  var __stackBase__ = 0;
  __stackBase__ = STACKTOP;
  _printf(__str | 0, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[(tempInt & 16777215) >> 2] = $y$0, HEAP32[(tempInt + 4 & 16777215) >> 2] = $y$1, tempInt));
  STACKTOP = __stackBase__;
  return 0 | 0;
}
function stackRestore(top) {
  top = top|0;
  STACKTOP = top;
}
function switchey(x, y) {
  x = +x;
  y = y | 0;
  var int1 = 0, int2 = 0; // do not mix the types!
  var double1 = +0, double2 = +0;
  switch(x|0) {
    case 0:
      int1 = (x+x)|0;
      double1 = d(Math.max(10, Math_min(5, f())));
      int2 = (int1+2)|0;
      print(int2);
      double2 = double1*5;
      return double2;
    case 1:
      return 20;
  }
}
function switchey2() {
  var $rng2 = 0, $count_06 = 0, $i_05 = 0, $2 = +0, $3 = +0, $count_1 = 0, $9 = 0, label = 0, __stackBase__ = 0;
  __stackBase__ = STACKTOP;
  STACKTOP = STACKTOP + 8 | 0;
  label = 1;
  while (1) switch (label | 0) {
   case 1:
    $rng2 = __stackBase__ | 0;
    __ZN6RandomC1Ev($rng2);
    $i_05 = 0;
    $count_06 = 0;
    label = 2;
    break;
   case 2:
    $2 = +__ZN6Random3getEf(8, +1);
    $3 = +__ZN6Random3getEf($rng2, +1);
    _printf(24, (tempInt = STACKTOP, STACKTOP = STACKTOP + 16 | 0, HEAPF64[CHECK_ALIGN_8(tempInt | 0) >> 3] = $2, HEAPF64[CHECK_ALIGN_8(tempInt + 8 | 0) >> 3] = $3, tempInt) | 0);
    $count_1 = ($2 != $3 & 1) + $count_06 | 0;
    $9 = $i_05 + 1 | 0;
    if (($9 | 0) < 100) {
      $i_05 = $9;
      $count_06 = $count_1;
      label = 2;
      break;
    } else {
      label = 3;
      break;
    }
   case 3:
    _printf(16, (tempInt = STACKTOP, STACKTOP = STACKTOP + 8 | 0, HEAP32[CHECK_ALIGN_4(tempInt | 0) >> 2] = $count_1, tempInt) | 0);
    STACKTOP = __stackBase__;
    return 0;
  }
  return 0;
}
function iffey() {
  var $rng2 = 0, $count_06 = 0, $i_05 = 0, $2 = +0, $3 = +0, $count_1 = 0, $9 = 0, label = 0, __stackBase__ = 0;
  __stackBase__ = STACKTOP;
  STACKTOP = STACKTOP + 8 | 0;
  label = 1;
  while (1) {
    if (label | 0) {
      $rng2 = __stackBase__ | 0;
      __ZN6RandomC1Ev($rng2);
      $i_05 = 0;
      $count_06 = 0;
      label = 2;
    } else {
      $2 = +__ZN6Random3getEf(8, +1);
      $3 = +__ZN6Random3getEf($rng2, +1);
      _printf(24, (tempInt = STACKTOP, STACKTOP = STACKTOP + 16 | 0, HEAPF64[CHECK_ALIGN_8(tempInt | 0) >> 3] = $2, HEAPF64[CHECK_ALIGN_8(tempInt + 8 | 0) >> 3] = $3, tempInt) | 0);
      $count_1 = ($2 != $3 & 1) + $count_06 | 0;
      $9 = $i_05 + 1 | 0;
      if (($9 | 0) < 100) {
        $i_05 = $9;
        $count_06 = $count_1;
        label = 2;
      } else {
        label = 3;
        return 10;
      }
    }
  }
  return 0;
}
// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "_doit", "stackRestore", "switchey", "switchey2", "iffey"]