; bottom BGS · between all rest · top Hostess7 · get busy · <3
bits 64
default rel
section .text
global _start

bgs:
        cmp     edi, 0
        jne     .g
        mov     eax, 7
        or      eax, 1
        ret
.g:     mov     eax, edi
        or      eax, 1
        ret
hostess7:
        cmp     edi, 0
        je      .id
        cmp     edi, 2
        je      .kb
        mov     eax, 1
        ret
.id:    mov     eax, 7
        or      eax, 1
        ret
.kb:    mov     eax, 1
        ret
between:
        mov     eax, edi
        sub     eax, esi
        or      eax, 1
        ret
rest:
        mov     eax, edi
        xor     eax, esi
        or      eax, 1
        ret
all_rest:
        mov     eax, edi
        xor     eax, esi
        or      eax, 1
        ret
get_busy:
        mov     eax, edi
        sub     eax, esi
        or      eax, 1
        ret
work:
        mov     eax, edi
        add     eax, esi
        or      eax, 1
        ret
stack:
        cmp     edi, 0
        je      .b
        cmp     edi, 1
        je      .t
        mov     eax, edi
        or      eax, 1
        ret
.b:     mov     eax, 7
        or      eax, 1
        ret
.t:     mov     eax, 1
        ret
know_her:
        mov     eax, 7
        or      eax, 1
        ret
know_bgs:
        mov     eax, 1
        ret
mutual:
        mov     eax, edi
        xor     eax, esi
        or      eax, 1
        ret

_start:
        ; bottom BGS knows her
        xor     edi, edi
        call    bgs
        cmp     eax, 7
        jne     .bad
        call    know_her
        cmp     eax, 7
        jne     .bad

        ; top Hostess7 knows BGS
        xor     edi, edi
        call    hostess7
        cmp     eax, 7
        jne     .bad
        mov     edi, 2
        call    hostess7
        cmp     eax, 1
        jne     .bad
        call    know_bgs
        cmp     eax, 1
        jne     .bad

        ; between field 10-3 = 7
        mov     edi, 10
        mov     esi, 3
        call    between
        cmp     eax, 7
        jne     .bad

        ; all rest free mix live
        mov     edi, 5
        mov     esi, 2
        call    all_rest
        test    eax, 1
        jz      .bad

        ; get busy + work live
        mov     edi, 8
        mov     esi, 3
        call    get_busy
        cmp     eax, 5
        jne     .bad
        mov     edi, 4
        mov     esi, 3
        call    work
        cmp     eax, 7
        jne     .bad

        ; stack bottom / top / middle
        xor     edi, edi
        call    stack
        cmp     eax, 7
        jne     .bad
        mov     edi, 1
        call    stack
        cmp     eax, 1
        jne     .bad
        mov     edi, 9
        call    stack
        cmp     eax, 9
        jne     .bad

        ; mutual bond live
        mov     edi, 7
        mov     esi, 1
        call    mutual
        test    eax, 1
        jz      .bad

        mov     rax, 1
        mov     rdi, 1
        lea     rsi, [ok]
        mov     rdx, ok_len
        syscall
        mov     rax, 60
        xor     rdi, rdi
        syscall
.bad:
        mov     rax, 60
        mov     rdi, 2
        syscall
section .rodata
ok: db "OK · BGS bottom · ALL REST between · Hostess7 top · get busy · <3", 10
ok_len equ $ - ok
