3v4l.org

run code in 300+ PHP versions simultaneously
<?php function holy_grail_countdown($number) { while (0 < $number) { $reset = (yield $number); $number = $reset ?: $number - 1; } } $c = holy_grail_countdown(5); foreach ($c as $number) { echo "$number\n"; // outputs 5, then 2 and finally 1. if (5 === $number) { $c->send(3); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 14
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/8i0RC
function name:  (null)
number of ops:  17
compiled vars:  !0 = $c, !1 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'holy_grail_countdown'
          1        SEND_VAL                                                 5
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   11     4      > FE_RESET_R                                       $4      !0, ->15
          5    > > FE_FETCH_R                                               $4, !1, ->15
   12     6    >   NOP                                                      
          7        FAST_CONCAT                                      ~5      !1, '%0A'
          8        ECHO                                                     ~5
   13     9        IS_IDENTICAL                                             !1, 5
         10      > JMPZ                                                     ~6, ->14
   14    11    >   INIT_METHOD_CALL                                         !0, 'send'
         12        SEND_VAL_EX                                              3
         13        DO_FCALL                                      0          
   11    14    > > JMP                                                      ->5
         15    >   FE_FREE                                                  $4
   16    16      > RETURN                                                   1

Function holy_grail_countdown:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
Branch analysis from position: 3
filename:       /in/8i0RC
function name:  holy_grail_countdown
number of ops:  12
compiled vars:  !0 = $number, !1 = $reset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    4     2      > JMP                                                      ->9
    5     3    >   YIELD                                            $2      !0
          4        ASSIGN                                                   !1, $2
    6     5        JMP_SET                                          ~4      !1, ->8
          6        SUB                                              ~5      !0, 1
          7        QM_ASSIGN                                        ~4      ~5
          8        ASSIGN                                                   !0, ~4
    4     9    >   IS_SMALLER                                               0, !0
         10      > JMPNZ                                                    ~7, ->3
    8    11    > > GENERATOR_RETURN                                         

End of function holy_grail_countdown

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.01 ms | 1399 KiB | 14 Q