Rust刷題黑科技開源了

去年解決了Rust刷題的關鍵問題 Rust將取代C/C++成為刷題的首選 。後來一直懶的做題,於是代碼一直爛在那裡,直到有人提了個問題 有哪些支持rust的刷題在線網站,如hackerrank 想想還是開源吧。

結果更新rust版本後,發現了個問題,Cargo.toml 里 rpath = true 不知道為啥不起作用了。假如 linkbc 用不了 (linkbc主要用於強行lto),請自行 patchelf --set-rpath /path/to/nightly-xxx/lib linkbc 。

Rust部分在 bhuztez/porus

用於自動提交代碼的python庫 bhuztez/ix (內含自動壓縮全是彙編代碼C語言代碼的黑科技,以免代碼長度超過某些OJ的上限,在porus目錄下,看 python3 -mix generate solutions/HR/solve-me-first.rs 運行結果就知道了)

有任何問題或者建議直接開Issue好了

---------------

舉個簡單的例子,上面提到的運行結果長這樣

#define _ "
mov"
#define a "q %r"#define b "
p"
#define c "_ZN5porus"#define d "
."
#define e "write"#define f "p"a""#define h "
c"
#define g ""_"q "#define i "$u20$"#define l ""b"ushq %r"#define j ""_"l "#define n "
j"
#define m ""b"o"f""#define k ""h"allq "#define p ""c"4libc"#define o ""g"%r"#define v "porus"#define t "..io.."#define s "putStream"#define r "5"e"17h3"#define q ""c"2io"#define w "byte_str."#define x "terator"#define z ", %ed"#define y "(%rbx"#define D "ction"#define C "bx
"
#define B ".Lfunc_end"#define A "(%r14"#define K ""p r"b55a5ced4db5e9aE"#define J ", %rs"#define I "i"_""#define H "l %e"#define G "$LT$"v t"file.."#define F ""s i"as"i""#define E "",@p"#define M " .LBB"#define N "
add"
#define S ".LBB2_"#define R "cx
"
#define Q ""d"siz"#define P "(%rbp)"#define O "
.LBB"
#define V "bp
"
#define T "leaq "#define X "_ZN79_"G"In"F"core..iter..i"x"..I"x"$GT$4next17hb0827cc1511b4b25E"#define W "di"k""#define _a ""ax"E"rogbits"#define __ "@fun"D"
"
#define Z ""n"e "#define Y ""m"bx"m""#define _j ", %rdx
"
#define _i ""p"13"e"_u32_aux17h366c698be9270efbE"#define _h "
test"
#define _g "p)"J I""#define _f "2"z I"l $"#define _e ""k K"
"
#define _d ""q"6ignore17hc6c13d23693e5815E"#define _c ""q"8read_i3217h4abd6e4431743992E"#define _b ""q"16"e"_signed_aux17ha4dbab4dadb31f1cE"#define _t ""_a d"typ"#define _s ""H"ax, %e"#define _r "(%ri"_g"l $"#define _q "_ZN81_"G"Out"F v"..traits"t"Out"s"$GT$"r"061525c649ce923E"#define _p ", %ebp
"
#define _o "
"d"se"D" "
#define _n ""j"%eax, %"#define _m "
"d"typ"
#define _k "@object"d"section .rodata"#define _l ""a"E"rogbits
"
#define _B ""l"bx"l"ax"#define _A ""N"q $8"J"p"Y""#define _z ""_o".text."#define _y ":"l"bp"l"1"#define _x ""_"w %ax, "#define _w ""V"retq
"B""
#define _v ":
.ascii ""
#define _E "14"m"15"m""#define _D ""z"x"_e" "T""#define _C ""_n"e"R"shrl $8, %"#define _Q ""_j"sub"a"bp"_j"movl %r15d, %edi"#define _P ""h"m"f"bp, %rax"n""#define _O ""_r _f"1, %edx"_e" "#define _N ""j"$1024"z"i"k"malloc@PLT
"
#define _M ""o"bx, %r"W _d o"ax, %r"W _c""#define _K "8(%rsp), %r"C"mov"a""#define _J ""j"%ebp, %edi"o"14, %rsi
"
#define _I ""j"%esi"_p" mov"a""#define _H "3435973837, %e"C"imulq %r"#define _G ""C"shrq $35, %r"C""#define _F ""N"l %ebx, %e"C"leal (%rbx,%rbx,4), %eax
sub"_s""
__asm__(" .text
.file "solutions/HR/solve-me-first.s"
.se"D" .text."K","_a"
.type "K","__ K _y"5"l"14"_B _ a"dx, %r14"_ a"si, %rbx"_"l %edi, %r15d"_h a"14, %r14"Z".LBB0_4
xorl %ebp, %ebp
.LBB0_2:"_ a"14"_Q _ a"bx"J"i"k e"@PLT"_h a"ax, %rax"n"s .LBB0_5"N a"ax, %rbp"N a"ax, %rbx"h"m"f"14, %rbp"n"b .LBB0_2
.LBB0_4:"_A _E"bp
retq
.LBB0_5:"k"abort@PLT
"B"0:
.size "K", "B"0-"K"

.se"D" .text."_i","_t"e "_i","__ _i":"l"bp"_B _"l %edi, %ebp"_h"l %ebp, %ebp"Z".LBB1_2"_"l %ebp, %eax"_"l $"_H"ax, %r"_G"movl %ebx, %edi"k _i _F"bp
orb $48, %bpl
"T"7(%rs"_g"b %bpl, (%rsi)"_"l $"_f"1"z"x"_e".LBB1_2:"_A"bp
retq
"B"1:"Q"e "_i", "B"1-"_i _o"".text."X"","_t"e "X","__ X _y"5"l"14"l"12"l"bx"_ a"di, %r14"g A"), %rbp"g"8"A"), %rax"_P"ne"M"2_9"g"16"A"), %r12"h"m"f"12, %rbp"n"ne"M"2_9
xor"_s"ax"o"ax, 8"A")"_h a"12, %r12"_"l $0, %ebp
je "S"8"j"32"A"), %r15d"g"24"A"), %r"C"xor"H"bp"_p S"4:"o"12"_Q o"bx, %rsi"k"read@PLT
test"a"ax, %rax"n"s"M"2_13"Z S"7"N a"ax, %r"V"add"a"ax, %r"C"cm"f"12, %rbp"n"b "S"4
"S"7:"g"8"A"), %rax
"S"8:"o"bp, "A")
"S"9:"_P"ae "S"10"g"24"A"), %rcx"_"zbl (%rcx,%rax), %e"R"inc"a"ax"o"ax, 8"A")
shll $8, %e"R"movw $1, %ax"n"mp"M"2_12
"S"10:
xor"H"cx, %e"R"xor"H"ax, %eax
"S"12:"_"zwl %ax, %eax
or"H"cx, %eax"Y"12"m _E V"retq
"S"13:
"T w"3"_r _f"13"_D"str.1"_r _f"10, %edx"_e" "T w"4"_r _f"3"_D"str.0"_r _f"11"_D w"5"_O"movl $42"z"i"k _i"
"T w"6"_O"callq abort@PLT
"B"2:"Q"e "X", "B"2-"X _o"".text."_q"","_t"e "_q","__ _q":"l"bp"_B _I"di, %r"C"movq "y"), %rax"g"8"y")"_j"cm"f"dx, %rax"n"ne"M"3_2"j"24"y")"z I"q 16"y")"J"i"k K"
movq $0, "y")
xor"_s"ax"O"3_2:"g"16"y"), %r"R"movb %bpl, (%rcx,%rax)
incq "y")"_A _w"3:"Q"e "_q", "B"3-"_q _z"main,"_a d"globl main"d"type main,"__"main"_y"5"l"14"l"bx
subq $104"J"p"j"$1024, %r15d"_N T"8(%rsp), %rbp"o"15, "P o"15, 8"P o"15, 16"P o"ax, 24"P j"$0, 32"P o"bp, %r"W X g"32"P", %r"R T"4"_K"cx, 32"y")"_"ups (%rbp), %xmm0"_"ups 16"P", %xmm1"_"aps %xmm1, 16"y")"_"aps %xmm0, "y")"_x"40"y")"_N"mov"a"ax, %r14"j"$1, 24"P g"$0, "P o"15, 8"P o"14, 16"P _M _n"ebp"_M N"l %ebp, %eax"Z".LBB4_1"_n"esi
neg"H"si
cmovl"_s"si
shrl $31, %eax
"T _K"bx, %rdi"_n"edx"k _b g y")"_j"movq 8"y"), %rax"h"m"f"ax, %rdx"n"ne"M"4_3"j"32(%rsp)"_p" movq 24(%rsp), %r14"_J"movq %rax"_j"callq "K"
movq $0, 8(%rsp)
xor"H"dx"z"x"n"mp"M"4_5"O"4_1:"_"b $48, "A")"g"$1, 8(%rsp)"j"$1, %ebp"j"$1, %edx"n"mp"M"4_5"O"4_3:"_"q 24(%rsp), %r14"j"32(%rsp)"_p".LBB4_5:"_"b $10, "A",%rdx)
inc"a"dx"_J"callq "K"
mov"a"14, %r"W"free@PLT
movq 72(%rsp), %r"W"free@PLT
addq $104"J"p"Y _E V"retq
"B"4:"Q"e main, "B"4-main"_z _d","_t"e "_d","__ _d":"l"bp"_B o"di, %r"C"cmpb $0, 40"y")"Z".LBB5_5"_"b 41"y"), %cl"j"$8388639"_p".LBB5_3:"N"b $-9, %cl"h"mpb $23, %cl"n"a"M"5_5"_"zbl %cl, %eax
bt"_s V"jae .LBB5_5"_ a"bx, %rdi"k X _x"40"y")"_C"e"R"testb %al, %al"n"ne"M"5_3"O"5_5:"_ a"bx, %rax"_A _w"5:"Q"e "_d", "B"5-"_d _z _c","_t"e "_c","__ _c _y"4"l"bx"o"di, %r14"_"b 40"A"), %al"_"b 41"A"), %cl"j"$1, %ebp"_h"b %al, %al"Z".LBB6_3"h"mpb $45, %cl"n"ne"M"6_3"o"14, %r"W X _x"40"A")"_C"e"R"movl $-1, %ebp"O"6_3:
xor"H"bx, %ebx"n"mp"M"6_5"O"6_6:"N"b $-48, %cl"h"mpb $10, %cl"n"ae .LBB6_7
leal "y",%rbx,4), %eax"_"zbl %cl, %e"R"leal (%rcx,%rax,2), %e"C"movq %r14, %r"W X _x"40"A")"_C"ecx"O"6_5:"_h"b %al, %al"n"ne"M"6_6"O"6_7:
imul"H"bp, %ebx"j"%ebx, %eax"Y"14"m _w"6:
.size "_c", "B"6-"_c _z _b","_t"e "_b","__ _b":
push"a"bp"l"14"l"bx"_I"di, %r14"_h H"bp, %ebp"Z".LBB7_1"j"%ebp, %eax"j"$"_H"ax, %r"_G"movzbl %dl"z"x"o"14, %rdi"j"%ebx, %esi
callq "_b _F V"orb $48, %bpl"_"zbl %bpl, %esi
jmp"M"7_3"O"7_1:
testb %dl, %dl"Z".LBB7_4"j"$45, %esi"O"7_3:
movq %r14, %rdi"Y"14"m V"jmp "_q O"7_4:
po"f C"po"f"14"m _w"7:
.size "_b", "B"7-"_b _m"e str.0,"_k".str.0,"_l"str.0"_v"src/libc.rs""Q"e str.0, 11"_m"e str.1,"_k".str.1,"_l"str.1"_v"read error""Q"e str.1, 10"_m"e "w"3,"_k"."w"3,"_l w"3"_v"panicked at ""Q"e "w"3, 13"_m"e "w"4,"_k"."w"4,"_l w"4"_v", ""Q"e "w"4, 3"_m"e "w"5,"_k"."w"5,"_l w"5:
.byte 58"Q"e "w"5, 1"_m"e "w"6,"_k"."w"6,"_l w"6:
.byte 10"Q"e "w"6, 1

"d"section ".note.GNU-stack",""E"rogbits
");

推薦閱讀:

為什麼勃學家給自己的物種設定里有許多都是貓?
為什麼被遺忘者向阿爾薩斯復仇之後還要繼續活在世上?
失敗人士該如何買房?
作為曾老師的顏粉是怎樣一番體驗?

TAG:勃???学??? | Rust编程语言 |