ReleaseSemaphore:
    ADDQ.B  #1,295(A6)
    SUBQ    #1,14(A0)
    BNE.S   .LAB_0001
    CLR.L   40(A0)
    SUBQ    #1,44(A0)
    BGE.S   .LAB_0003
.LAB_0000:
    SUBQ.B  #1,295(A6)    ;<-   inlined routine
    BGE.S   .LB_0000
    TST.B   294(A6)
    BGE.S   .LB_0000
    TST 292(A6)
    BMI.S   .LB_0001
.LB_0000:
    RTS
 cnop 0,4
.LB_0001:
    MOVE.L  A5,-(A7)
    LEA .LB_0002(PC),A5
    JSR _LVOSupervisor(A6)
    MOVEA.L (A7)+,A5
    RTS
 cnop 0,4
.LB_0002:
    BTST    #5,(A7)
    BNE.S   .LB_0003
    bra Schedule
  cnop 0,4
.LB_0003:
    RTE                      ;<-
 cnop 0,4
.LAB_0001:
    BMI.S   .LAB_0002
    SUBQ    #1,44(A0)
    BRA.S   .LAB_0000
.LAB_0002:
    MOVEM.L  D7/A0,-(A7)
    MOVE.L  #$01000008,D7
    JSR _LVOAlert(A6)
    MOVE.L  (A7)+,D7
    MOVEA.L (A7),A0
    BSR InitSemaphore
    MOVEA.L (A7)+,A0
    BRA.S   .LAB_0000
.LAB_0003:
    MOVEM.L D0-D1/A0-A3,-(A7)
    MOVEA.L A0,A2
    LEA 16(A2),A0
    MOVEA.L (A0),A1
    MOVE.L  (A1),D0
    BEQ.S   .LAB_0005
    MOVE.L  D0,(A0)
    EXG D0,A1
    MOVE.L  A0,4(A1)
    MOVEA.L D0,A1
    MOVE.L  8(A1),D0
    BCLR    #0,D0
    BNE.W   .LAB_000A
    TST.L   D0
    BEQ.S   .LAB_0006
    MOVEA.L D0,A1
    MOVE.L  A1,40(A2)
.LAB_0004:
    ADDQ    #1,14(A2)
    MOVEQ   #16,D0
    bsr Signal
.LAB_0005:
    MOVEM.L (A7)+,D0-D1/A0-A3
    SUBQ.B  #1,295(A6)       ;<-   inlined routine
    BGE.S   .L_0000
    TST.B   294(A6)
    BGE.S   .L_0000
    TST 292(A6)
    BMI.S   .L_0001
.L_0000:
    RTS
 cnop 0,4
.L_0001:
    MOVE.L  A5,-(A7)
    LEA .L_0002(PC),A5
    JSR _LVOSupervisor(A6)
    MOVEA.L (A7)+,A5
    RTS
 cnop 0,4
.L_0002:
    BTST    #5,(A7)
    BNE.S   .L_0003
    bra Schedule
  cnop 0,4
.L_0003:
    RTE                    ;<-
 cnop 0,4
.LAB_0006:
    MOVE.L  20(A1),40(A2)
    MOVEA.L 16(A2),A3
.LAB_0007:
    MOVE.L  A2,20(A1)
    ADDQ    #1,14(A2)
    bsr ReplyMsg
    MOVE.L  40(A2),D1
.LAB_0008:
    MOVE.L  (A3),D0
    BEQ.S   .LAB_0005
    MOVEA.L A3,A1
    MOVEA.L D0,A3
    MOVE.L  8(A1),D0
    BEQ.S   .LAB_0009
    CMP.L   D0,D1
    BNE.S   .LAB_0008
    MOVEA.L 4(A1),A0
    MOVE.L  A3,(A0)
    MOVE.L  A0,4(A3)
    MOVEA.L D1,A1
    BRA.W   .LAB_0004
 cnop 0,4
.LAB_0009:
    CMP.L   20(A1),D1
    BNE.S   .LAB_0008
    MOVEA.L 4(A1),A0
    MOVE.L  A3,(A0)
    MOVE.L  A0,4(A3)
    ADDQ    #1,14(A2)
    BRA.S   .LAB_0007
 cnop 0,4
.LAB_000A:
    MOVEA.L 16(A2),A3
.LAB_000B:
    ADDQ    #1,14(A2)
    TST.L   D0
    BEQ.S   .LAB_000C
    MOVEA.L D0,A1
    MOVEQ   #16,D0
    bsr Signal
    BRA.S   .LAB_000D
 cnop 0,4
.LAB_000C:
    MOVE.L  A2,20(A1)
    MOVE.L  D0,8(A1)
    bsr ReplyMsg
.LAB_000D:
    MOVE.L  (A3),D0
    BEQ.W   .LAB_0005
    MOVEA.L A3,A1
    MOVEA.L D0,A3
    MOVE.L  8(A1),D0
    BCLR    #0,D0
    BEQ.S   .LAB_000D
    MOVEA.L 4(A1),A0
    MOVE.L  A3,(A0)
    MOVE.L  A0,4(A3)
    BRA.S   .LAB_000B
 cnop 0,4
