3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s1 = bchexdec('44e1ff2dfd8102cf7a47c21d5c9fd5701610d04953c6836596b4fe9dd2f53e3e'); $s2 = bchexdec('9a5f1c75e461d7ceb1cf3cab9013eb2dc85b6d0da8c3c6e27e3a5a5b3faa5bab'); echo bcdechex(invmod($s1, -$s2)); function invmod($a,$b) { $n=$b; $x=0; $lx=1; $y=1; $ly=0; while ($b) { $t=$b; $q=bcdiv($a,$b,0); $b=bcmod($a,$b); $a=$t; $t=$x; $x=bcsub($lx,bcmod(bcmul($q,$x),$n)); $lx=$t; $t=$y; $y=bcsub($ly,bcmod(bcmul($q,$y),$n)); $ly=$t; } if (bccomp($lx,0) == -1) $lx=bcadd($lx,$n); return $lx; } function bchexdec($hex) { if(strlen($hex) == 1) { return hexdec($hex); } else { $remain = substr($hex, 0, -1); $last = substr($hex, -1); return bcadd(bcmul(16, bchexdec($remain)), hexdec($last)); } } function bcdechex($dec) { $last = bcmod($dec, 16); $remain = bcdiv(bcsub($dec, $last), 16); if($remain == 0) { return dechex($last); } else { return bcdechex($remain).dechex($last); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qqi85
function name:  (null)
number of ops:  18
compiled vars:  !0 = $s1, !1 = $s2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL_BY_NAME                                       'bchexdec'
          1        SEND_VAL_EX                                              '44e1ff2dfd8102cf7a47c21d5c9fd5701610d04953c6836596b4fe9dd2f53e3e'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
    3     4        INIT_FCALL_BY_NAME                                       'bchexdec'
          5        SEND_VAL_EX                                              '9a5f1c75e461d7ceb1cf3cab9013eb2dc85b6d0da8c3c6e27e3a5a5b3faa5bab'
          6        DO_FCALL                                      0  $4      
          7        ASSIGN                                                   !1, $4
    5     8        INIT_FCALL_BY_NAME                                       'bcdechex'
          9        INIT_FCALL_BY_NAME                                       'invmod'
         10        SEND_VAR_EX                                              !0
         11        MUL                                              ~6      !1, -1
         12        SEND_VAL_EX                                              ~6
         13        DO_FCALL                                      0  $7      
         14        SEND_VAR_NO_REF_EX                                       $7
         15        DO_FCALL                                      0  $8      
         16        ECHO                                                     $8
   42    17      > RETURN                                                   1

Function invmod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 8
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 63
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 8
Branch analysis from position: 52
Branch analysis from position: 8
filename:       /in/qqi85
function name:  invmod
number of ops:  65
compiled vars:  !0 = $a, !1 = $b, !2 = $n, !3 = $x, !4 = $lx, !5 = $y, !6 = $ly, !7 = $t, !8 = $q
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        ASSIGN                                                   !2, !1
    9     3        ASSIGN                                                   !3, 0
          4        ASSIGN                                                   !4, 1
          5        ASSIGN                                                   !5, 1
          6        ASSIGN                                                   !6, 0
   10     7      > JMP                                                      ->51
   11     8    >   ASSIGN                                                   !7, !1
   12     9        INIT_FCALL_BY_NAME                                       'bcdiv'
         10        SEND_VAR_EX                                              !0
         11        SEND_VAR_EX                                              !1
         12        SEND_VAL_EX                                              0
         13        DO_FCALL                                      0  $15     
         14        ASSIGN                                                   !8, $15
   13    15        INIT_FCALL_BY_NAME                                       'bcmod'
         16        SEND_VAR_EX                                              !0
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0  $17     
         19        ASSIGN                                                   !1, $17
   14    20        ASSIGN                                                   !0, !7
   15    21        ASSIGN                                                   !7, !3
         22        INIT_FCALL_BY_NAME                                       'bcsub'
         23        SEND_VAR_EX                                              !4
         24        INIT_FCALL_BY_NAME                                       'bcmod'
         25        INIT_FCALL_BY_NAME                                       'bcmul'
         26        SEND_VAR_EX                                              !8
         27        SEND_VAR_EX                                              !3
         28        DO_FCALL                                      0  $21     
         29        SEND_VAR_NO_REF_EX                                       $21
         30        SEND_VAR_EX                                              !2
         31        DO_FCALL                                      0  $22     
         32        SEND_VAR_NO_REF_EX                                       $22
         33        DO_FCALL                                      0  $23     
         34        ASSIGN                                                   !3, $23
         35        ASSIGN                                                   !4, !7
   16    36        ASSIGN                                                   !7, !5
         37        INIT_FCALL_BY_NAME                                       'bcsub'
         38        SEND_VAR_EX                                              !6
         39        INIT_FCALL_BY_NAME                                       'bcmod'
         40        INIT_FCALL_BY_NAME                                       'bcmul'
         41        SEND_VAR_EX                                              !8
         42        SEND_VAR_EX                                              !5
         43        DO_FCALL                                      0  $27     
         44        SEND_VAR_NO_REF_EX                                       $27
         45        SEND_VAR_EX                                              !2
         46        DO_FCALL                                      0  $28     
         47        SEND_VAR_NO_REF_EX                                       $28
         48        DO_FCALL                                      0  $29     
         49        ASSIGN                                                   !5, $29
         50        ASSIGN                                                   !6, !7
   10    51    > > JMPNZ                                                    !1, ->8
   18    52    >   INIT_FCALL_BY_NAME                                       'bccomp'
         53        SEND_VAR_EX                                              !4
         54        SEND_VAL_EX                                              0
         55        DO_FCALL                                      0  $32     
         56        IS_EQUAL                                                 $32, -1
         57      > JMPZ                                                     ~33, ->63
   19    58    >   INIT_FCALL_BY_NAME                                       'bcadd'
         59        SEND_VAR_EX                                              !4
         60        SEND_VAR_EX                                              !2
         61        DO_FCALL                                      0  $34     
         62        ASSIGN                                                   !4, $34
   20    63    > > RETURN                                                   !4
   21    64*     > RETURN                                                   null

End of function invmod

Function bchexdec:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qqi85
function name:  bchexdec
number of ops:  36
compiled vars:  !0 = $hex, !1 = $remain, !2 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   24     1        STRLEN                                           ~3      !0
          2        IS_EQUAL                                                 ~3, 1
          3      > JMPZ                                                     ~4, ->9
   25     4    >   INIT_FCALL                                               'hexdec'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $5      
          7      > RETURN                                                   $5
          8*       JMP                                                      ->35
   27     9    >   INIT_FCALL                                               'substr'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 0
         12        SEND_VAL                                                 -1
         13        DO_ICALL                                         $6      
         14        ASSIGN                                                   !1, $6
   28    15        INIT_FCALL                                               'substr'
         16        SEND_VAR                                                 !0
         17        SEND_VAL                                                 -1
         18        DO_ICALL                                         $8      
         19        ASSIGN                                                   !2, $8
   29    20        INIT_FCALL_BY_NAME                                       'bcadd'
         21        INIT_FCALL_BY_NAME                                       'bcmul'
         22        SEND_VAL_EX                                              16
         23        INIT_FCALL_BY_NAME                                       'bchexdec'
         24        SEND_VAR_EX                                              !1
         25        DO_FCALL                                      0  $10     
         26        SEND_VAR_NO_REF_EX                                       $10
         27        DO_FCALL                                      0  $11     
         28        SEND_VAR_NO_REF_EX                                       $11
         29        INIT_FCALL                                               'hexdec'
         30        SEND_VAR                                                 !2
         31        DO_ICALL                                         $12     
         32        SEND_VAR_NO_REF_EX                                       $12
         33        DO_FCALL                                      0  $13     
         34      > RETURN                                                   $13
   31    35*     > RETURN                                                   null

End of function bchexdec

Function bcdechex:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 22
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qqi85
function name:  bcdechex
number of ops:  31
compiled vars:  !0 = $dec, !1 = $last, !2 = $remain
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   34     1        INIT_FCALL_BY_NAME                                       'bcmod'
          2        SEND_VAR_EX                                              !0
          3        SEND_VAL_EX                                              16
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   35     6        INIT_FCALL_BY_NAME                                       'bcdiv'
          7        INIT_FCALL_BY_NAME                                       'bcsub'
          8        SEND_VAR_EX                                              !0
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0  $5      
         11        SEND_VAR_NO_REF_EX                                       $5
         12        SEND_VAL_EX                                              16
         13        DO_FCALL                                      0  $6      
         14        ASSIGN                                                   !2, $6
   37    15        IS_EQUAL                                                 !2, 0
         16      > JMPZ                                                     ~8, ->22
   38    17    >   INIT_FCALL                                               'dechex'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $9      
         20      > RETURN                                                   $9
         21*       JMP                                                      ->30
   40    22    >   INIT_FCALL_BY_NAME                                       'bcdechex'
         23        SEND_VAR_EX                                              !2
         24        DO_FCALL                                      0  $10     
         25        INIT_FCALL                                               'dechex'
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                         $11     
         28        CONCAT                                           ~12     $10, $11
         29      > RETURN                                                   ~12
   42    30*     > RETURN                                                   null

End of function bcdechex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.36 ms | 1400 KiB | 19 Q