Created
September 17, 2025 16:54
-
-
Save dtolnay/9e3b27e4ba19571bcb80de37a241fb26 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #![no_std] | |
| #![feature(likely_unlikely)] | |
| use core::hint::{likely, unlikely}; | |
| unsafe extern "Rust" { | |
| safe fn next() -> isize; | |
| safe fn process(_: char); | |
| } | |
| pub fn f() { | |
| let mut id = next(); | |
| let mut first = true; | |
| 'control: loop { | |
| 'end: { | |
| 'd: { | |
| 'c: { | |
| 'b: { | |
| 'a: { | |
| if first { | |
| first = false; | |
| if likely(id == 1) { | |
| break 'a; | |
| } | |
| } | |
| match id { | |
| 1 => break 'a, | |
| 2 => break 'b, | |
| 3 => break 'c, | |
| 4 => break 'd, | |
| 5 => break 'end, | |
| _ => { | |
| id = next(); | |
| continue 'control; | |
| } | |
| } | |
| } | |
| process('A'); | |
| id = next(); | |
| if unlikely(id != 2) { | |
| continue 'control; | |
| } | |
| } | |
| process('B'); | |
| id = next(); | |
| if unlikely(id != 3) { | |
| continue 'control; | |
| } | |
| } | |
| process('C'); | |
| id = next(); | |
| if unlikely(id != 4) { | |
| continue 'control; | |
| } | |
| } | |
| process('D'); | |
| id = next(); | |
| if unlikely(id != 5) { | |
| continue 'control; | |
| } | |
| } | |
| process('.'); | |
| return; | |
| } | |
| } |
This file contains hidden or 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
| example::f::hd332a77f3ea30ba2: | |
| push rax | |
| .LBB0_1: | |
| call next | |
| .LBB0_2: | |
| cmp rax, 1 | |
| jne .LBB0_3 | |
| mov edi, 65 | |
| call process | |
| call next | |
| cmp rax, 2 | |
| jne .LBB0_2 | |
| .LBB0_6: | |
| mov edi, 66 | |
| call process | |
| call next | |
| cmp rax, 3 | |
| jne .LBB0_2 | |
| .LBB0_7: | |
| mov edi, 67 | |
| call process | |
| call next | |
| cmp rax, 4 | |
| jne .LBB0_2 | |
| .LBB0_8: | |
| mov edi, 68 | |
| call process | |
| call next | |
| cmp rax, 5 | |
| je .LBB0_9 | |
| jmp .LBB0_2 | |
| .LBB0_3: | |
| add rax, -2 | |
| cmp rax, 3 | |
| ja .LBB0_1 | |
| jmp qword ptr [8*rax + .LJTI0_0] | |
| .LBB0_9: | |
| mov edi, 46 | |
| pop rax | |
| jmp process | |
| .LJTI0_0: | |
| .quad .LBB0_6 | |
| .quad .LBB0_7 | |
| .quad .LBB0_8 | |
| .quad .LBB0_9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment