3v4l.org

run code in 300+ PHP versions simultaneously
<?php function Y ($le) {return (function ($f) {return $f($f); })(function ($f) use ($le) {return $le(function ($x) use ($f) {return $f($f)($x); }); }); } $le = function ($factorial) {return function ($n) use ($factorial) {return $n < 2 ? $n : $n * $factorial($n - 1); }; }; $factorial = Y($le); echo $factorial(1) . PHP_EOL; // 1 echo $factorial(2) . PHP_EOL; // 2 echo $factorial(5) . PHP_EOL; // 120
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7AUn2
function name:  (null)
number of ops:  22
compiled vars:  !0 = $le, !1 = $factorial
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7AUn2%3A19%243'
   18     1        ASSIGN                                                   !0, ~2
   29     2        INIT_FCALL                                               'y'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $4      
          5        ASSIGN                                                   !1, $4
   31     6        INIT_DYNAMIC_CALL                                        !1
          7        SEND_VAL_EX                                              1
          8        DO_FCALL                                      0  $6      
          9        CONCAT                                           ~7      $6, '%0A'
         10        ECHO                                                     ~7
   32    11        INIT_DYNAMIC_CALL                                        !1
         12        SEND_VAL_EX                                              2
         13        DO_FCALL                                      0  $8      
         14        CONCAT                                           ~9      $8, '%0A'
         15        ECHO                                                     ~9
   33    16        INIT_DYNAMIC_CALL                                        !1
         17        SEND_VAL_EX                                              5
         18        DO_FCALL                                      0  $10     
         19        CONCAT                                           ~11     $10, '%0A'
         20        ECHO                                                     ~11
         21      > RETURN                                                   1

Function y:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7AUn2
function name:  Y
number of ops:  9
compiled vars:  !0 = $le
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    6     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7AUn2%3A6%240'
    9     2        INIT_DYNAMIC_CALL                                        ~1
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7AUn2%3A9%241'
          4        BIND_LEXICAL                                             ~2, !0
   15     5        SEND_VAL_EX                                              ~2
          6        DO_FCALL                                      0  $3      
          7      > RETURN                                                   $3
   16     8*     > RETURN                                                   null

End of function y

Function %00%7Bclosure%7D%2Fin%2F7AUn2%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7AUn2
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        INIT_DYNAMIC_CALL                                        !0
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
    9     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7AUn2%3A6%240

Function %00%7Bclosure%7D%2Fin%2F7AUn2%3A9%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7AUn2
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $f, !1 = $le
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   11     2        INIT_DYNAMIC_CALL                                        !1
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7AUn2%3A11%242'
          4        BIND_LEXICAL                                             ~2, !0
   14     5        SEND_VAL_EX                                              ~2
          6        DO_FCALL                                      0  $3      
          7      > RETURN                                                   $3
   15     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7AUn2%3A9%241

Function %00%7Bclosure%7D%2Fin%2F7AUn2%3A11%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7AUn2
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $x, !1 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   13     2        INIT_DYNAMIC_CALL                                        !1
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0  $2      
          5        INIT_DYNAMIC_CALL                                        $2
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $3      
          8      > RETURN                                                   $3
   14     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7AUn2%3A11%242

Function %00%7Bclosure%7D%2Fin%2F7AUn2%3A19%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7AUn2
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $factorial
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7AUn2%3A21%244'
   22     2        BIND_LEXICAL                                             ~1, !0
   26     3      > RETURN                                                   ~1
   27     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7AUn2%3A19%243

Function %00%7Bclosure%7D%2Fin%2F7AUn2%3A21%244:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7AUn2
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $n, !1 = $factorial
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   24     2        IS_SMALLER                                               !0, 2
          3      > JMPZ                                                     ~2, ->6
          4    >   QM_ASSIGN                                        ~3      !0
          5      > JMP                                                      ->12
   25     6    >   INIT_DYNAMIC_CALL                                        !1
          7        SUB                                              ~4      !0, 1
          8        SEND_VAL_EX                                              ~4
          9        DO_FCALL                                      0  $5      
         10        MUL                                              ~6      !0, $5
         11        QM_ASSIGN                                        ~3      ~6
         12    > > RETURN                                                   ~3
   26    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7AUn2%3A21%244

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.73 ms | 1407 KiB | 14 Q