sysy-data/functional_c/asm/75_max_flow.s

427 lines
6.1 KiB
ArmAsm
Raw Normal View History

2024-06-14 13:34:46 +08:00
.text
.attribute 4, 16
.attribute 5, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
.file "75_max_flow.sy"
.globl my_memset
.p2align 1
.type my_memset,@function
my_memset:
blez a2, .LBB0_3
slli a2, a2, 32
srli a2, a2, 32
.LBB0_2:
sw a1, 0(a0)
addi a2, a2, -1
addi a0, a0, 4
bnez a2, .LBB0_2
.LBB0_3:
ret
.Lfunc_end0:
.size my_memset, .Lfunc_end0-my_memset
.globl add_node
.p2align 1
.type add_node,@function
add_node:
lui a3, %hi(size)
addi t3, a3, %lo(size)
slli a4, a0, 2
add a7, a4, t3
lw t0, 0(a7)
li a6, 40
mul t1, a0, a6
slli a5, t0, 2
lui a4, %hi(to)
addi t2, a4, %lo(to)
add a5, a5, t1
add a4, a5, t2
sw a1, 0(a4)
lui a4, %hi(cap)
addi t1, a4, %lo(cap)
add a3, a5, t1
sw a2, 0(a3)
slli a2, a1, 2
add a2, a2, t3
lw a3, 0(a2)
lui a4, %hi(rev)
addi a4, a4, %lo(rev)
add a5, a5, a4
sw a3, 0(a5)
mul a1, a1, a6
slli a3, a3, 2
add a1, a1, a3
add a3, a1, t2
sw a0, 0(a3)
add a0, a1, t1
addiw a3, t0, 1
sw a3, 0(a7)
lw a3, 0(a2)
sw zero, 0(a0)
add a0, a1, a4
sw t0, 0(a0)
addiw a0, a3, 1
sw a0, 0(a2)
ret
.Lfunc_end1:
.size add_node, .Lfunc_end1-add_node
.globl dfs
.p2align 1
.type dfs,@function
dfs:
addi sp, sp, -80
sd ra, 72(sp)
sd s0, 64(sp)
sd s1, 56(sp)
sd s2, 48(sp)
sd s3, 40(sp)
sd s4, 32(sp)
sd s5, 24(sp)
sd s6, 16(sp)
sd s7, 8(sp)
mv s4, a2
beq a0, a1, .LBB2_11
mv s3, a1
lui a2, %hi(used)
slli a3, a0, 2
lui a1, %hi(size)
addi a1, a1, %lo(size)
add s2, a3, a1
lw a1, 0(s2)
addi s5, a2, %lo(used)
add a2, a3, s5
li a3, 1
sw a3, 0(a2)
blez a1, .LBB2_10
li s0, 0
li a2, 40
mul a0, a0, a2
lui a2, %hi(rev)
addi a2, a2, %lo(rev)
add s6, a0, a2
lui a2, %hi(cap)
addi a2, a2, %lo(cap)
add s7, a0, a2
lui a2, %hi(to)
addi a2, a2, %lo(to)
add s1, a0, a2
j .LBB2_4
.LBB2_3:
addi s0, s0, 1
addi s6, s6, 4
addi s7, s7, 4
addi s1, s1, 4
bge s0, a1, .LBB2_10
.LBB2_4:
lw a0, 0(s1)
slli a2, a0, 2
add a2, a2, s5
lw a2, 0(a2)
bnez a2, .LBB2_3
lw a3, 0(s7)
blez a3, .LBB2_3
mv a2, s4
blt s4, a3, .LBB2_8
mv a2, a3
.LBB2_8:
mv a1, s3
call dfs
bgtz a0, .LBB2_12
lw a1, 0(s2)
j .LBB2_3
.LBB2_10:
li s4, 0
.LBB2_11:
mv a0, s4
ld ra, 72(sp)
ld s0, 64(sp)
ld s1, 56(sp)
ld s2, 48(sp)
ld s3, 40(sp)
ld s4, 32(sp)
ld s5, 24(sp)
ld s6, 16(sp)
ld s7, 8(sp)
addi sp, sp, 80
ret
.LBB2_12:
lw a1, 0(s7)
subw a1, a1, a0
lw a2, 0(s1)
lw a3, 0(s6)
sw a1, 0(s7)
li a1, 40
mul a1, a2, a1
slli a2, a3, 2
add a1, a1, a2
lui a2, %hi(cap)
addi a2, a2, %lo(cap)
add a1, a1, a2
lw a2, 0(a1)
addw a2, a2, a0
sw a2, 0(a1)
mv s4, a0
j .LBB2_11
.Lfunc_end2:
.size dfs, .Lfunc_end2-dfs
.globl max_flow
.p2align 1
.type max_flow,@function
max_flow:
addi sp, sp, -48
sd ra, 40(sp)
sd s0, 32(sp)
sd s1, 24(sp)
sd s2, 16(sp)
sd s3, 8(sp)
mv s2, a1
mv s3, a0
li a1, 0
lui a0, %hi(used)
addi s0, a0, %lo(used)
.LBB3_1:
mv s1, a1
li a2, 40
mv a0, s0
li a1, 0
call memset@plt
lui a2, 458752
mv a0, s3
mv a1, s2
call dfs
addw a1, a0, s1
bnez a0, .LBB3_1
mv a0, s1
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_end3:
.size max_flow, .Lfunc_end3-max_flow
.globl main
.p2align 1
.type main,@function
main:
addi sp, sp, -96
sd ra, 88(sp)
sd s0, 80(sp)
sd s1, 72(sp)
sd s2, 64(sp)
sd s3, 56(sp)
sd s4, 48(sp)
sd s5, 40(sp)
sd s6, 32(sp)
sd s7, 24(sp)
sd s8, 16(sp)
sd s9, 8(sp)
call getint
mv s2, a0
call getint
mv s4, a0
lui a0, %hi(size)
addi s3, a0, %lo(size)
li a2, 40
li s5, 40
mv a0, s3
li a1, 0
call memset@plt
blez s4, .LBB4_3
lui a0, %hi(to)
addi s6, a0, %lo(to)
lui a0, %hi(cap)
addi s7, a0, %lo(cap)
lui a0, %hi(rev)
addi s8, a0, %lo(rev)
li s9, 1
.LBB4_2:
call getint
mv s0, a0
call getint
mv s1, a0
call getint
slli a1, s0, 2
add a1, a1, s3
lw a2, 0(a1)
mul a3, s0, s5
slli a4, a2, 2
add a3, a3, a4
add a4, a3, s7
sw a0, 0(a4)
slli a0, s1, 2
add a0, a0, s3
lw a4, 0(a0)
add a5, a3, s6
sw s1, 0(a5)
add a3, a3, s8
sw a4, 0(a3)
mul a3, s1, s5
slli a4, a4, 2
add a3, a3, a4
add a4, a3, s6
sw s0, 0(a4)
add a4, a3, s7
addiw a5, a2, 1
sw a5, 0(a1)
lw a1, 0(a0)
sw zero, 0(a4)
add a3, a3, s8
sw a2, 0(a3)
addiw a1, a1, 1
sext.w a2, s4
addiw s4, s4, -1
sw a1, 0(a0)
bltu s9, a2, .LBB4_2
.LBB4_3:
li a1, 0
lui a0, %hi(used)
addi s1, a0, %lo(used)
.LBB4_4:
mv s0, a1
li a2, 40
mv a0, s1
li a1, 0
call memset@plt
li a0, 1
lui a2, 458752
mv a1, s2
call dfs
addw a1, a0, s0
bnez a0, .LBB4_4
mv a0, s0
call putint
li a0, 10
call putch
li a0, 0
ld ra, 88(sp)
ld s0, 80(sp)
ld s1, 72(sp)
ld s2, 64(sp)
ld s3, 56(sp)
ld s4, 48(sp)
ld s5, 40(sp)
ld s6, 32(sp)
ld s7, 24(sp)
ld s8, 16(sp)
ld s9, 8(sp)
addi sp, sp, 96
ret
.Lfunc_end4:
.size main, .Lfunc_end4-main
.type INF,@object
.section .rodata,"a",@progbits
.globl INF
.p2align 2
INF:
.word 1879048192
.size INF, 4
.type to,@object
.bss
.globl to
.p2align 2
to:
.zero 400
.size to, 400
.type size,@object
.globl size
.p2align 2
size:
.zero 40
.size size, 40
.type cap,@object
.globl cap
.p2align 2
cap:
.zero 400
.size cap, 400
.type rev,@object
.globl rev
.p2align 2
rev:
.zero 400
.size rev, 400
.type used,@object
.globl used
.p2align 2
used:
.zero 40
.size used, 40
.type _sysy_start,@object
.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