-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.rs
79 lines (74 loc) · 2.57 KB
/
code.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use std::ptr;
extern "C" {
pub fn print_var(v: u8);
}
#[cfg(pure_rust)]
mod impl_ {
#[no_mangle]
pub extern "C" fn print_var(v: u8) {
println!("{v}");
}
}
#[no_mangle]
pub unsafe extern "C" fn fn12_rs() {
let mut bool_storage: bool = false;
let mut v9: usize = 0;
'l0: loop {
let mut v20 = [197_u8; 8];
let v20_ptr = ptr::addr_of_mut!(v20);
let mut v12: *mut u8 = v20_ptr.cast::<u8>().add(v9);
v9 = 2_usize; // unused but necessary write
loop {
// only runs once, but necessary
match *v12 {
197 => {
let mut match_condition: u64 = 0;
let mut v33: *mut bool = core::ptr::addr_of_mut!(bool_storage);
let mut key_read: (bool, u8) = (false, 0);
let mut v39: (usize, [u32; 6]) = (0, [0; 6]);
// Taken
'l2: loop {
(*v20_ptr) = [11_u8; 8]; // What LLVM with low mir-opt prints
(*v12) = 22; // What Miri prints
loop {
let v21 = *v20_ptr;
match match_condition {
0 => {
// Taken
v39.1 = [1; 6];
match_condition = 2;
v39.0 = 6;
let v17 = v33;
v33 = core::ptr::addr_of_mut!(key_read.0);
key_read.1 = *v12;
(*v17) = true;
(*v20_ptr) = v21;
match v39.0 {
6 => {
// Taken
print_var(key_read.1);
}
0 => continue 'l2,
_ => return,
}
}
2 => return,
_ => continue 'l0,
}
}
}
}
_ => {
// Dead code but necessary
v12 = (*v20_ptr).as_mut_ptr().add(2);
}
}
}
}
}
#[cfg(pure_rust)]
fn main() {
unsafe {
fn12_rs();
}
}