3v4l.org

run code in 300+ PHP versions simultaneously
<?php $assertions = [ 1 => 1, 4 => 4, 5 => 5, 6 => 4, 8 => 2, 9 => 1, 10 => 2, 11 => 3, 12 => 4, 13 => 5, 14 => 4, 15 => 3, 16 => 2, 17 => 1, 18 => 2, 19 => 3, 20 => 4, 21 => 5, 22 => 4, ]; /** * @param positive-int $count * @return positive-int */ function countFingerPingPong(int $count): int { $remainder = max(1, $count%5); $directionCircle = floor($count/5); var_dump($remainder); var_dump($directionCircle); return $directionCircle%2 === 0 ? $directionCircle -1 : 4 - $remainder; } foreach($assertions as $count => $assert) { if (countFingerPingPong($count) !== $assert) { throw new Exeption('Assesstions failed.'); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 14
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/Qv09Q
function name:  (null)
number of ops:  16
compiled vars:  !0 = $assertions, !1 = $assert, !2 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   40     1      > FE_RESET_R                                       $4      !0, ->14
          2    > > FE_FETCH_R                                       ~5      $4, !1, ->14
          3    >   ASSIGN                                                   !2, ~5
   41     4        INIT_FCALL                                               'countfingerpingpong'
          5        SEND_VAR                                                 !2
          6        DO_FCALL                                      0  $7      
          7        IS_NOT_IDENTICAL                                         !1, $7
          8      > JMPZ                                                     ~8, ->13
   42     9    >   NEW                                              $9      'Exeption'
         10        SEND_VAL_EX                                              'Assesstions+failed.'
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $9
   40    13    > > JMP                                                      ->2
         14    >   FE_FREE                                                  $4
   44    15      > RETURN                                                   1

Function countfingerpingpong:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qv09Q
function name:  countFingerPingPong
number of ops:  30
compiled vars:  !0 = $count, !1 = $remainder, !2 = $directionCircle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   31     1        INIT_FCALL                                               'max'
          2        SEND_VAL                                                 1
          3        MOD                                              ~3      !0, 5
          4        SEND_VAL                                                 ~3
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !1, $4
   32     7        INIT_FCALL                                               'floor'
          8        DIV                                              ~6      !0, 5
          9        SEND_VAL                                                 ~6
         10        DO_ICALL                                         $7      
         11        ASSIGN                                                   !2, $7
   34    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                                 
   35    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
   37    18        MOD                                              ~11     !2, 2
         19        IS_IDENTICAL                                             ~11, 0
         20      > JMPZ                                                     ~12, ->24
         21    >   SUB                                              ~13     !2, 1
         22        QM_ASSIGN                                        ~14     ~13
         23      > JMP                                                      ->26
         24    >   SUB                                              ~15     4, !1
         25        QM_ASSIGN                                        ~14     ~15
         26    >   VERIFY_RETURN_TYPE                                       ~14
         27      > RETURN                                                   ~14
   38    28*       VERIFY_RETURN_TYPE                                       
         29*     > RETURN                                                   null

End of function countfingerpingpong

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
127.62 ms | 1407 KiB | 20 Q