3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Get bit in specified position from right (LSB position = 0) function getBIT($number, $position) { return ($number >> $position) & 1;} // Set bit in specified position from right (LSB position = 0) function setBIT($number, $position, $value) { if(getBIT($number, $position)){ if(!$value) { $number -= pow(2, $position); if($color == "r"){ $setBITcountR++; //echo "set BITr "; } if($color == "g"){ $setBITcountG++; //echo "set BITg "; } if($color == "b"){ $setBITcountB++; //echo "set BITb "; } } } else { if($value){ $number += pow(2, $position); if($color == "r"){ $setBITcountR++; //echo "set BITr "; } if($color == "g"){ $setBITcountG++; //echo "set BITg "; } if($color == "b"){ $setBITcountB++; //echo "set BITb "; } } } return $number; } echo decbin(setBIT(0b01101001, 3, 0));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HfVXV
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   INIT_FCALL                                               'decbin'
          1        INIT_FCALL                                               'setbit'
          2        SEND_VAL                                                 105
          3        SEND_VAL                                                 3
          4        SEND_VAL                                                 0
          5        DO_FCALL                                      0  $0      
          6        SEND_VAR                                                 $0
          7        DO_ICALL                                         $1      
          8        ECHO                                                     $1
          9      > RETURN                                                   1

Function getbit:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HfVXV
function name:  getBIT
number of ops:  6
compiled vars:  !0 = $number, !1 = $position
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        SR                                               ~2      !0, !1
          3        BW_AND                                           ~3      ~2, 1
          4      > RETURN                                                   ~3
          5*     > RETURN                                                   null

End of function getbit

Function setbit:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 25
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 24
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 21
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 21
Branch analysis from position: 18
Branch analysis from position: 24
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 40
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 34
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 37
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 40
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
Branch analysis from position: 37
Branch analysis from position: 34
Branch analysis from position: 40
filename:       /in/HfVXV
function name:  setBIT
number of ops:  42
compiled vars:  !0 = $number, !1 = $position, !2 = $value, !3 = $color, !4 = $setBITcountR, !5 = $setBITcountG, !6 = $setBITcountB
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    7     3        INIT_FCALL                                               'getbit'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $7      
          7      > JMPZ                                                     $7, ->25
    8     8    >   BOOL_NOT                                         ~8      !2
          9      > JMPZ                                                     ~8, ->24
    9    10    >   INIT_FCALL                                               'pow'
         11        SEND_VAL                                                 2
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $9      
         14        ASSIGN_OP                                     2          !0, $9
   10    15        IS_EQUAL                                                 !3, 'r'
         16      > JMPZ                                                     ~11, ->18
   11    17    >   PRE_INC                                                  !4
   14    18    >   IS_EQUAL                                                 !3, 'g'
         19      > JMPZ                                                     ~13, ->21
   15    20    >   PRE_INC                                                  !5
   18    21    >   IS_EQUAL                                                 !3, 'b'
         22      > JMPZ                                                     ~15, ->24
   19    23    >   PRE_INC                                                  !6
         24    > > JMP                                                      ->40
   24    25    > > JMPZ                                                     !2, ->40
   25    26    >   INIT_FCALL                                               'pow'
         27        SEND_VAL                                                 2
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                         $17     
         30        ASSIGN_OP                                     1          !0, $17
   26    31        IS_EQUAL                                                 !3, 'r'
         32      > JMPZ                                                     ~19, ->34
   27    33    >   PRE_INC                                                  !4
   30    34    >   IS_EQUAL                                                 !3, 'g'
         35      > JMPZ                                                     ~21, ->37
   31    36    >   PRE_INC                                                  !5
   34    37    >   IS_EQUAL                                                 !3, 'b'
         38      > JMPZ                                                     ~23, ->40
   35    39    >   PRE_INC                                                  !6
   40    40    > > RETURN                                                   !0
   41    41*     > RETURN                                                   null

End of function setbit

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
200.32 ms | 1403 KiB | 19 Q