570 lines
8.0 KiB
ArmAsm
570 lines
8.0 KiB
ArmAsm
.text
|
|
.attribute 4, 16
|
|
.attribute 5, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
|
|
.file "18_prim.sy"
|
|
.globl quick_read
|
|
.p2align 1
|
|
.type quick_read,@function
|
|
quick_read:
|
|
addi sp, sp, -48
|
|
sd ra, 40(sp)
|
|
sd s0, 32(sp)
|
|
sd s1, 24(sp)
|
|
sd s2, 16(sp)
|
|
sd s3, 8(sp)
|
|
call getch
|
|
addiw a1, a0, -58
|
|
li a2, -11
|
|
bltu a2, a1, .LBB0_5
|
|
li a1, 0
|
|
li s2, 45
|
|
li s0, -10
|
|
j .LBB0_3
|
|
.LBB0_2:
|
|
call getch
|
|
addiw a2, a0, -58
|
|
mv a1, s3
|
|
bgeu a2, s0, .LBB0_6
|
|
.LBB0_3:
|
|
sext.w a0, a0
|
|
li s3, 1
|
|
beq a0, s2, .LBB0_2
|
|
mv s3, a1
|
|
j .LBB0_2
|
|
.LBB0_5:
|
|
li s3, 0
|
|
.LBB0_6:
|
|
li s0, 0
|
|
li s1, 10
|
|
.LBB0_7:
|
|
mulw a1, s0, s1
|
|
addw a0, a0, a1
|
|
addiw s0, a0, -48
|
|
call getch
|
|
addiw a1, a0, -48
|
|
bltu a1, s1, .LBB0_7
|
|
beqz s3, .LBB0_10
|
|
negw s0, s0
|
|
.LBB0_10:
|
|
mv a0, s0
|
|
ld ra, 40(sp)
|
|
ld s0, 32(sp)
|
|
ld s1, 24(sp)
|
|
ld s2, 16(sp)
|
|
ld s3, 8(sp)
|
|
addi sp, sp, 48
|
|
ret
|
|
.Lfunc_end0:
|
|
.size quick_read, .Lfunc_end0-quick_read
|
|
|
|
.globl find
|
|
.p2align 1
|
|
.type find,@function
|
|
find:
|
|
addi sp, sp, -16
|
|
sd ra, 8(sp)
|
|
sd s0, 0(sp)
|
|
lui a1, %hi(fa)
|
|
addi a1, a1, %lo(fa)
|
|
slli a2, a0, 2
|
|
add s0, a2, a1
|
|
lw a1, 0(s0)
|
|
beq a1, a0, .LBB1_2
|
|
mv a0, a1
|
|
call find
|
|
sw a0, 0(s0)
|
|
.LBB1_2:
|
|
ld ra, 8(sp)
|
|
ld s0, 0(sp)
|
|
addi sp, sp, 16
|
|
ret
|
|
.Lfunc_end1:
|
|
.size find, .Lfunc_end1-find
|
|
|
|
.globl same
|
|
.p2align 1
|
|
.type same,@function
|
|
same:
|
|
addi sp, sp, -32
|
|
sd ra, 24(sp)
|
|
sd s0, 16(sp)
|
|
sd s1, 8(sp)
|
|
mv s0, a1
|
|
call find
|
|
mv s1, a0
|
|
mv a0, s0
|
|
call find
|
|
xor a0, a0, s1
|
|
seqz a0, a0
|
|
ld ra, 24(sp)
|
|
ld s0, 16(sp)
|
|
ld s1, 8(sp)
|
|
addi sp, sp, 32
|
|
ret
|
|
.Lfunc_end2:
|
|
.size same, .Lfunc_end2-same
|
|
|
|
.globl prim
|
|
.p2align 1
|
|
.type prim,@function
|
|
prim:
|
|
addi sp, sp, -112
|
|
sd ra, 104(sp)
|
|
sd s0, 96(sp)
|
|
sd s1, 88(sp)
|
|
sd s2, 80(sp)
|
|
sd s3, 72(sp)
|
|
sd s4, 64(sp)
|
|
sd s5, 56(sp)
|
|
sd s6, 48(sp)
|
|
sd s7, 40(sp)
|
|
sd s8, 32(sp)
|
|
sd s9, 24(sp)
|
|
sd s10, 16(sp)
|
|
sd s11, 8(sp)
|
|
lui a0, %hi(m)
|
|
lw a0, %lo(m)(a0)
|
|
blez a0, .LBB3_8
|
|
li t2, 0
|
|
slli a0, a0, 32
|
|
srli t1, a0, 32
|
|
li t6, 1
|
|
lui a0, %hi(v)
|
|
addi a6, a0, %lo(v)
|
|
addi t3, a6, 4
|
|
lui a0, %hi(u)
|
|
addi a7, a0, %lo(u)
|
|
addi t4, a7, 4
|
|
lui a0, %hi(c)
|
|
addi t0, a0, %lo(c)
|
|
addi t5, t0, 4
|
|
j .LBB3_3
|
|
.LBB3_2:
|
|
addi t6, t6, 1
|
|
addi t3, t3, 4
|
|
addi t4, t4, 4
|
|
addi t5, t5, 4
|
|
beq t2, t1, .LBB3_8
|
|
.LBB3_3:
|
|
mv a0, t2
|
|
addi t2, t2, 1
|
|
bgeu t2, t1, .LBB3_2
|
|
slli a0, a0, 2
|
|
add s4, a0, t0
|
|
add s2, a0, a7
|
|
add s3, a0, a6
|
|
mv s1, t1
|
|
mv a2, t5
|
|
mv a5, t4
|
|
mv a3, t3
|
|
j .LBB3_6
|
|
.LBB3_5:
|
|
addi a3, a3, 4
|
|
addi a5, a5, 4
|
|
addi s1, s1, -1
|
|
addi a2, a2, 4
|
|
beq t6, s1, .LBB3_2
|
|
.LBB3_6:
|
|
lw a1, 0(s4)
|
|
lw s0, 0(a2)
|
|
bge s0, a1, .LBB3_5
|
|
lw s5, 0(a5)
|
|
lw s6, 0(s2)
|
|
lw a0, 0(a3)
|
|
lw a4, 0(s3)
|
|
sw s5, 0(s2)
|
|
sw s6, 0(a5)
|
|
sw a0, 0(s3)
|
|
sw a4, 0(a3)
|
|
sw s0, 0(s4)
|
|
sw a1, 0(a2)
|
|
j .LBB3_5
|
|
.LBB3_8:
|
|
lui a0, %hi(n)
|
|
lw a0, %lo(n)(a0)
|
|
blez a0, .LBB3_11
|
|
addiw a0, a0, 1
|
|
slli a0, a0, 32
|
|
srli a0, a0, 32
|
|
li a1, 1
|
|
lui a2, %hi(fa+4)
|
|
addi a2, a2, %lo(fa+4)
|
|
.LBB3_10:
|
|
sw a1, 0(a2)
|
|
addi a1, a1, 1
|
|
addi a2, a2, 4
|
|
bne a0, a1, .LBB3_10
|
|
.LBB3_11:
|
|
li s3, 0
|
|
li s2, 0
|
|
lui a0, %hi(u)
|
|
addi s4, a0, %lo(u)
|
|
lui a0, %hi(v)
|
|
addi s5, a0, %lo(v)
|
|
lui s6, %hi(m)
|
|
lui a0, %hi(c)
|
|
addi s7, a0, %lo(c)
|
|
lui a0, %hi(fa)
|
|
addi s8, a0, %lo(fa)
|
|
.LBB3_12:
|
|
slli s11, s3, 2
|
|
add s9, s11, s4
|
|
add s10, s11, s5
|
|
.LBB3_13:
|
|
lw a0, %lo(m)(s6)
|
|
bge s3, a0, .LBB3_16
|
|
lw a0, 0(s9)
|
|
lw s1, 0(s10)
|
|
call find
|
|
mv s0, a0
|
|
mv a0, s1
|
|
call find
|
|
beq s0, a0, .LBB3_13
|
|
add a0, s11, s7
|
|
lw a1, 0(a0)
|
|
lw s0, 0(s10)
|
|
lw a0, 0(s9)
|
|
addw s2, a1, s2
|
|
call find
|
|
slli a0, a0, 2
|
|
add a0, a0, s8
|
|
sw s0, 0(a0)
|
|
addi s3, s3, 1
|
|
j .LBB3_12
|
|
.LBB3_16:
|
|
mv a0, s2
|
|
ld ra, 104(sp)
|
|
ld s0, 96(sp)
|
|
ld s1, 88(sp)
|
|
ld s2, 80(sp)
|
|
ld s3, 72(sp)
|
|
ld s4, 64(sp)
|
|
ld s5, 56(sp)
|
|
ld s6, 48(sp)
|
|
ld s7, 40(sp)
|
|
ld s8, 32(sp)
|
|
ld s9, 24(sp)
|
|
ld s10, 16(sp)
|
|
ld s11, 8(sp)
|
|
addi sp, sp, 112
|
|
ret
|
|
.Lfunc_end3:
|
|
.size prim, .Lfunc_end3-prim
|
|
|
|
.globl main
|
|
.p2align 1
|
|
.type main,@function
|
|
main:
|
|
addi sp, sp, -112
|
|
sd ra, 104(sp)
|
|
sd s0, 96(sp)
|
|
sd s1, 88(sp)
|
|
sd s2, 80(sp)
|
|
sd s3, 72(sp)
|
|
sd s4, 64(sp)
|
|
sd s5, 56(sp)
|
|
sd s6, 48(sp)
|
|
sd s7, 40(sp)
|
|
sd s8, 32(sp)
|
|
sd s9, 24(sp)
|
|
sd s10, 16(sp)
|
|
sd s11, 8(sp)
|
|
call getch
|
|
addiw a0, a0, -58
|
|
li a1, -11
|
|
bltu a1, a0, .LBB4_3
|
|
li s0, -10
|
|
.LBB4_2:
|
|
call getch
|
|
addiw a0, a0, -58
|
|
bltu a0, s0, .LBB4_2
|
|
.LBB4_3:
|
|
li s0, 10
|
|
.LBB4_4:
|
|
call getch
|
|
addiw a0, a0, -48
|
|
bltu a0, s0, .LBB4_4
|
|
call getch
|
|
addiw a1, a0, -58
|
|
li a2, -11
|
|
bltu a2, a1, .LBB4_10
|
|
li a1, 0
|
|
li s2, 45
|
|
li s1, -10
|
|
j .LBB4_8
|
|
.LBB4_7:
|
|
call getch
|
|
addiw a2, a0, -58
|
|
mv a1, s3
|
|
bgeu a2, s1, .LBB4_11
|
|
.LBB4_8:
|
|
sext.w a0, a0
|
|
li s3, 1
|
|
beq a0, s2, .LBB4_7
|
|
mv s3, a1
|
|
j .LBB4_7
|
|
.LBB4_10:
|
|
li s3, 0
|
|
.LBB4_11:
|
|
li s1, 0
|
|
li s0, 10
|
|
.LBB4_12:
|
|
mulw a1, s1, s0
|
|
addw a0, a0, a1
|
|
addiw s1, a0, -48
|
|
call getch
|
|
addiw a1, a0, -48
|
|
bltu a1, s0, .LBB4_12
|
|
beqz s3, .LBB4_15
|
|
negw s1, s1
|
|
.LBB4_15:
|
|
blez s1, .LBB4_48
|
|
li s4, 0
|
|
slli a0, s1, 32
|
|
srli s2, a0, 32
|
|
li s3, -11
|
|
li s5, 45
|
|
li s10, -10
|
|
li s11, 10
|
|
lui a0, %hi(u)
|
|
addi s6, a0, %lo(u)
|
|
lui a0, %hi(v)
|
|
addi s7, a0, %lo(v)
|
|
lui a0, %hi(c)
|
|
addi s8, a0, %lo(c)
|
|
j .LBB4_18
|
|
.LBB4_17:
|
|
add a0, s9, s8
|
|
addi s4, s4, 1
|
|
sw s1, 0(a0)
|
|
beq s4, s2, .LBB4_48
|
|
.LBB4_18:
|
|
call getch
|
|
addiw a1, a0, -58
|
|
bltu s3, a1, .LBB4_23
|
|
li a1, 0
|
|
j .LBB4_21
|
|
.LBB4_20:
|
|
call getch
|
|
addiw a2, a0, -58
|
|
mv a1, s0
|
|
bgeu a2, s10, .LBB4_24
|
|
.LBB4_21:
|
|
sext.w a0, a0
|
|
li s0, 1
|
|
beq a0, s5, .LBB4_20
|
|
mv s0, a1
|
|
j .LBB4_20
|
|
.LBB4_23:
|
|
li s0, 0
|
|
.LBB4_24:
|
|
li s1, 0
|
|
.LBB4_25:
|
|
mulw a1, s1, s11
|
|
addw a0, a0, a1
|
|
addiw s1, a0, -48
|
|
call getch
|
|
addiw a1, a0, -48
|
|
bltu a1, s11, .LBB4_25
|
|
beqz s0, .LBB4_28
|
|
neg s1, s1
|
|
.LBB4_28:
|
|
slli s9, s4, 2
|
|
add a0, s9, s6
|
|
sw s1, 0(a0)
|
|
call getch
|
|
addiw a1, a0, -58
|
|
bltu s3, a1, .LBB4_33
|
|
li a1, 0
|
|
j .LBB4_31
|
|
.LBB4_30:
|
|
call getch
|
|
addiw a2, a0, -58
|
|
mv a1, s0
|
|
bgeu a2, s10, .LBB4_34
|
|
.LBB4_31:
|
|
sext.w a0, a0
|
|
li s0, 1
|
|
beq a0, s5, .LBB4_30
|
|
mv s0, a1
|
|
j .LBB4_30
|
|
.LBB4_33:
|
|
li s0, 0
|
|
.LBB4_34:
|
|
li s1, 0
|
|
.LBB4_35:
|
|
mulw a1, s1, s11
|
|
addw a0, a0, a1
|
|
addiw s1, a0, -48
|
|
call getch
|
|
addiw a1, a0, -48
|
|
bltu a1, s11, .LBB4_35
|
|
beqz s0, .LBB4_38
|
|
neg s1, s1
|
|
.LBB4_38:
|
|
add a0, s9, s7
|
|
sw s1, 0(a0)
|
|
call getch
|
|
addiw a1, a0, -58
|
|
bltu s3, a1, .LBB4_43
|
|
li a1, 0
|
|
j .LBB4_41
|
|
.LBB4_40:
|
|
call getch
|
|
addiw a2, a0, -58
|
|
mv a1, s0
|
|
bgeu a2, s10, .LBB4_44
|
|
.LBB4_41:
|
|
sext.w a0, a0
|
|
li s0, 1
|
|
beq a0, s5, .LBB4_40
|
|
mv s0, a1
|
|
j .LBB4_40
|
|
.LBB4_43:
|
|
li s0, 0
|
|
.LBB4_44:
|
|
li s1, 0
|
|
.LBB4_45:
|
|
mulw a1, s1, s11
|
|
addw a0, a0, a1
|
|
addiw s1, a0, -48
|
|
call getch
|
|
addiw a1, a0, -48
|
|
bltu a1, s11, .LBB4_45
|
|
beqz s0, .LBB4_17
|
|
neg s1, s1
|
|
j .LBB4_17
|
|
.LBB4_48:
|
|
ld ra, 104(sp)
|
|
ld s0, 96(sp)
|
|
ld s1, 88(sp)
|
|
ld s2, 80(sp)
|
|
ld s3, 72(sp)
|
|
ld s4, 64(sp)
|
|
ld s5, 56(sp)
|
|
ld s6, 48(sp)
|
|
ld s7, 40(sp)
|
|
ld s8, 32(sp)
|
|
ld s9, 24(sp)
|
|
ld s10, 16(sp)
|
|
ld s11, 8(sp)
|
|
addi sp, sp, 112
|
|
tail prim
|
|
.Lfunc_end4:
|
|
.size main, .Lfunc_end4-main
|
|
|
|
.type fa,@object
|
|
.bss
|
|
.globl fa
|
|
.p2align 2
|
|
fa:
|
|
.zero 4020
|
|
.size fa, 4020
|
|
|
|
.type m,@object
|
|
.section .sbss,"aw",@nobits
|
|
.globl m
|
|
.p2align 2
|
|
m:
|
|
.word 0
|
|
.size m, 4
|
|
|
|
.type c,@object
|
|
.bss
|
|
.globl c
|
|
.p2align 2
|
|
c:
|
|
.zero 4020
|
|
.size c, 4020
|
|
|
|
.type u,@object
|
|
.globl u
|
|
.p2align 2
|
|
u:
|
|
.zero 4020
|
|
.size u, 4020
|
|
|
|
.type v,@object
|
|
.globl v
|
|
.p2align 2
|
|
v:
|
|
.zero 4020
|
|
.size v, 4020
|
|
|
|
.type n,@object
|
|
.section .sbss,"aw",@nobits
|
|
.globl n
|
|
.p2align 2
|
|
n:
|
|
.word 0
|
|
.size n, 4
|
|
|
|
.type _sysy_start,@object
|
|
.bss
|
|
.globl _sysy_start
|
|
.p2align 3
|
|
_sysy_start:
|
|
.zero 16
|
|
.size _sysy_start, 16
|
|
|
|
.type _sysy_end,@object
|
|
.globl _sysy_end
|
|
.p2align 3
|
|
_sysy_end:
|
|
.zero 16
|
|
.size _sysy_end, 16
|
|
|
|
.type _sysy_l1,@object
|
|
.globl _sysy_l1
|
|
.p2align 2
|
|
_sysy_l1:
|
|
.zero 4096
|
|
.size _sysy_l1, 4096
|
|
|
|
.type _sysy_l2,@object
|
|
.globl _sysy_l2
|
|
.p2align 2
|
|
_sysy_l2:
|
|
.zero 4096
|
|
.size _sysy_l2, 4096
|
|
|
|
.type _sysy_h,@object
|
|
.globl _sysy_h
|
|
.p2align 2
|
|
_sysy_h:
|
|
.zero 4096
|
|
.size _sysy_h, 4096
|
|
|
|
.type _sysy_m,@object
|
|
.globl _sysy_m
|
|
.p2align 2
|
|
_sysy_m:
|
|
.zero 4096
|
|
.size _sysy_m, 4096
|
|
|
|
.type _sysy_s,@object
|
|
.globl _sysy_s
|
|
.p2align 2
|
|
_sysy_s:
|
|
.zero 4096
|
|
.size _sysy_s, 4096
|
|
|
|
.type _sysy_us,@object
|
|
.globl _sysy_us
|
|
.p2align 2
|
|
_sysy_us:
|
|
.zero 4096
|
|
.size _sysy_us, 4096
|
|
|
|
.type _sysy_idx,@object
|
|
.section .sbss,"aw",@nobits
|
|
.globl _sysy_idx
|
|
.p2align 2
|
|
_sysy_idx:
|
|
.word 0
|
|
.size _sysy_idx, 4
|
|
|
|
.ident "Debian clang version 14.0.6"
|
|
.section ".note.GNU-stack","",@progbits
|
|
.addrsig
|