3v4l.org

run code in 300+ PHP versions simultaneously
<?php function atoi($s){ $s = trim($s); $sign = '+'; if($s[0]=='+'||$s[0]=='-'){ $sign = $s[0]; } if(!ctype_digit($s[1])) { return 0; } $s = preg_replace('/[^0-9]/','',$s); if($s) { if($sign=='-') { $s = -$s; } } else { $s = 0; } return $s; } var_dump(atoi("303819")); var_dump(atoi('-303')); var_dump(atoi('293kurwa')); var_dump(atoi('kurwa 552')); var_dump(atoi('+29')); var_dump(atoi('- 69')); var_dump(atoi('ja pierdole')); // :( var_dump(atoi('3fail3'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/seTuI
function name:  (null)
number of ops:  49
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'atoi'
          2        SEND_VAL                                                 '303819'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   23     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'atoi'
          8        SEND_VAL                                                 '-303'
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
   24    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'atoi'
         14        SEND_VAL                                                 '293kurwa'
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                                 
   25    18        INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'atoi'
         20        SEND_VAL                                                 'kurwa+552'
         21        DO_FCALL                                      0  $6      
         22        SEND_VAR                                                 $6
         23        DO_ICALL                                                 
   26    24        INIT_FCALL                                               'var_dump'
         25        INIT_FCALL                                               'atoi'
         26        SEND_VAL                                                 '%2B29'
         27        DO_FCALL                                      0  $8      
         28        SEND_VAR                                                 $8
         29        DO_ICALL                                                 
   27    30        INIT_FCALL                                               'var_dump'
         31        INIT_FCALL                                               'atoi'
         32        SEND_VAL                                                 '-+69'
         33        DO_FCALL                                      0  $10     
         34        SEND_VAR                                                 $10
         35        DO_ICALL                                                 
   28    36        INIT_FCALL                                               'var_dump'
         37        INIT_FCALL                                               'atoi'
         38        SEND_VAL                                                 'ja+pierdole'
         39        DO_FCALL                                      0  $12     
         40        SEND_VAR                                                 $12
         41        DO_ICALL                                                 
   30    42        INIT_FCALL                                               'var_dump'
         43        INIT_FCALL                                               'atoi'
         44        SEND_VAL                                                 '3fail3'
         45        DO_FCALL                                      0  $14     
         46        SEND_VAR                                                 $14
         47        DO_ICALL                                                 
         48      > RETURN                                                   1

Function atoi:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
Branch analysis from position: 12
filename:       /in/seTuI
function name:  atoi
number of ops:  37
compiled vars:  !0 = $s, !1 = $sign
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'trim'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
    4     5        ASSIGN                                                   !1, '%2B'
    5     6        FETCH_DIM_R                                      ~5      !0, 0
          7        IS_EQUAL                                         ~6      ~5, '%2B'
          8      > JMPNZ_EX                                         ~6      ~6, ->12
          9    >   FETCH_DIM_R                                      ~7      !0, 0
         10        IS_EQUAL                                         ~8      ~7, '-'
         11        BOOL                                             ~6      ~8
         12    > > JMPZ                                                     ~6, ->15
    6    13    >   FETCH_DIM_R                                      ~9      !0, 0
         14        ASSIGN                                                   !1, ~9
    8    15    >   INIT_FCALL                                               'ctype_digit'
         16        FETCH_DIM_R                                      ~11     !0, 1
         17        SEND_VAL                                                 ~11
         18        DO_ICALL                                         $12     
         19        BOOL_NOT                                         ~13     $12
         20      > JMPZ                                                     ~13, ->22
         21    > > RETURN                                                   0
    9    22    >   INIT_FCALL                                               'preg_replace'
         23        SEND_VAL                                                 '%2F%5B%5E0-9%5D%2F'
         24        SEND_VAL                                                 ''
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                         $14     
         27        ASSIGN                                                   !0, $14
   10    28      > JMPZ                                                     !0, ->34
   11    29    >   IS_EQUAL                                                 !1, '-'
         30      > JMPZ                                                     ~16, ->33
   12    31    >   MUL                                              ~17     !0, -1
         32        ASSIGN                                                   !0, ~17
         33    > > JMP                                                      ->35
   15    34    >   ASSIGN                                                   !0, 0
   18    35    > > RETURN                                                   !0
   19    36*     > RETURN                                                   null

End of function atoi

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.52 ms | 1407 KiB | 29 Q