-
-
Save ircmaxell/69fb22e9e005bedd3ac7 to your computer and use it in GitHub Desktop.
Transforming
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @param int $n | |
* @return int | |
*/ | |
function foo($n) { | |
for ($i = 0; $i < 10; $i++) { | |
if ($i % 2) { | |
return $i; | |
} | |
} | |
return $n; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @param int $n | |
* @return int | |
*/ | |
function foo( $n) | |
{ | |
$i = 0; | |
compiled_label_2: | |
if (!($i < 10)) { | |
goto compiled_label_1; | |
} | |
if ($i % 2) { | |
return $i; | |
} | |
compiled_label_0: | |
$i++; | |
goto compiled_label_2; | |
compiled_label_1: | |
return $n; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foo(l1 : long) : long | |
incoming_reg(l1, rdi) | |
.L: | |
l4 = 0 | |
.L0: | |
i6 = l4 >= 10 | |
if l4 < 10 then goto .L1 | |
.L: | |
goto .L2 | |
ends_in_dead | |
.L: | |
goto .L3 | |
ends_in_dead | |
.L3: .L1: | |
l8 = l4 % 2 | |
if lfalse(l8) then goto .L4 | |
.L: | |
return_long(l4) | |
ends_in_dead | |
.L: | |
goto .L5 | |
ends_in_dead | |
.L6: .L5: .L4: | |
l9 = l4 | |
l11 = l4 + 1 | |
l4 = l11 | |
goto .L0 | |
ends_in_dead | |
.L2: | |
return_long(l1) | |
ends_in_dead | |
.L: | |
.L: | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
push %rbp | |
mov %rsp, %rbp | |
sub $0x10, %rsp | |
mov %r15, (%rsp) | |
mov %rdi, -0x8(%rbp) | |
xor %r15d, %r15d | |
mov $0xa, %eax | |
JMPLOC5: | |
cmp %rax, %r15 | |
jl JMPLOC1 | |
jmpq JMPLOC2 | |
JMPLOC1: | |
mov %r15, %rax | |
mov $0x2, %rcx | |
cqto | |
idiv %rcx | |
test %rdx, %rdx | |
je JMPLOC4 | |
mov %r15, %rax | |
jmpq JMPLOC3 | |
JMPLOC4: | |
mov $0x1, %eax | |
add %rax, %r15 | |
jmp JMPLOC5 | |
JMPLOC2: | |
mov -0x8(%rbp), %rax | |
JMPLOC3: | |
mov (%rsp), %r15 | |
mov %rbp, %rsp | |
pop %rbp | |
retq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment