3v4l.org

run code in 300+ PHP versions simultaneously
<?php function compare($a, $b) { // Sort by weight, unless disabled. if ($a->region != -1) { $weight = $a->weight - $b->weight; if ($weight) { return $weight; } } // Sort by label. return strcmp($a->label, $b->label); } $a = (object)['region' => 1, 'weight' => 1, 'label' => 'A']; $b = (object)['region' => -1, 'weight' => 2, 'label' => 'A']; $c = (object)['region' => 1, 'weight' => 0, 'label' => 'B']; assert(-1 === compare($a, $b)); assert(-1 === compare($b, $c)); assert(-1 === compare($c, $a));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GCCld
function name:  (null)
number of ops:  37
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   CAST                                          8  ~3      <array>
          1        ASSIGN                                                   !0, ~3
   17     2        CAST                                          8  ~5      <array>
          3        ASSIGN                                                   !1, ~5
   18     4        CAST                                          8  ~7      <array>
          5        ASSIGN                                                   !2, ~7
   20     6        ASSERT_CHECK                                             
          7        INIT_FCALL                                               'assert'
          8        INIT_FCALL                                               'compare'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        DO_FCALL                                      0  $9      
         12        IS_IDENTICAL                                     ~10     $9, -1
         13        SEND_VAL                                                 ~10
         14        SEND_VAL                                                 'assert%28-1+%3D%3D%3D+compare%28%24a%2C+%24b%29%29'
         15        DO_ICALL                                                 
   21    16        ASSERT_CHECK                                             
         17        INIT_FCALL                                               'assert'
         18        INIT_FCALL                                               'compare'
         19        SEND_VAR                                                 !1
         20        SEND_VAR                                                 !2
         21        DO_FCALL                                      0  $12     
         22        IS_IDENTICAL                                     ~13     $12, -1
         23        SEND_VAL                                                 ~13
         24        SEND_VAL                                                 'assert%28-1+%3D%3D%3D+compare%28%24b%2C+%24c%29%29'
         25        DO_ICALL                                                 
   22    26        ASSERT_CHECK                                             
         27        INIT_FCALL                                               'assert'
         28        INIT_FCALL                                               'compare'
         29        SEND_VAR                                                 !2
         30        SEND_VAR                                                 !0
         31        DO_FCALL                                      0  $15     
         32        IS_IDENTICAL                                     ~16     $15, -1
         33        SEND_VAL                                                 ~16
         34        SEND_VAL                                                 'assert%28-1+%3D%3D%3D+compare%28%24c%2C+%24a%29%29'
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Function compare:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/GCCld
function name:  compare
number of ops:  19
compiled vars:  !0 = $a, !1 = $b, !2 = $weight
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        FETCH_OBJ_R                                      ~3      !0, 'region'
          3        IS_NOT_EQUAL                                             ~3, -1
          4      > JMPZ                                                     ~4, ->11
    7     5    >   FETCH_OBJ_R                                      ~5      !0, 'weight'
          6        FETCH_OBJ_R                                      ~6      !1, 'weight'
          7        SUB                                              ~7      ~5, ~6
          8        ASSIGN                                                   !2, ~7
    8     9      > JMPZ                                                     !2, ->11
    9    10    > > RETURN                                                   !2
   13    11    >   INIT_FCALL                                               'strcmp'
         12        FETCH_OBJ_R                                      ~9      !0, 'label'
         13        SEND_VAL                                                 ~9
         14        FETCH_OBJ_R                                      ~10     !1, 'label'
         15        SEND_VAL                                                 ~10
         16        DO_ICALL                                         $11     
         17      > RETURN                                                   $11
   14    18*     > RETURN                                                   null

End of function compare

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.91 ms | 1010 KiB | 18 Q