.section .text

	.global @SUBSTITUTE_ENTRY_NAME

_my_exit:
	EXIT_ # sys_exit

_read_char:
        GETCHAR
        ret

_write_char:
        sub   $4, %rdi
        PUTCHAR
        ret

my_mul:
        sub    $4, %rdi
        mov    (%rdi), %eax
        mov    %rdi, %rcx
        sub    $4, %rcx
        mov    (%rcx), %ebx
        imul   %ebx
        mov    %eax, (%rcx)
        ret

my_div:
        sub    $4, %rdi
        mov    (%rdi), %eax
        cdq # sign extends edx if eax is negative
        mov    %rdi, %rcx
        sub    $4, %rcx
        mov    (%rcx), %ebx
        idiv   %ebx
        mov    %eax, (%rcx)
        ret

my_mod:
        sub    $4, %rdi
        mov    (%rdi), %eax
        cdq # sign extends edx if eax is negative
        mov    %rdi, %rcx
        sub    $4, %rcx
        mov    (%rcx), %ebx
        idiv   %ebx
        mov    %edx, (%rcx)
        ret

my_abs:
        mov    %rdi, %rcx
        sub    $4, %rcx
        mov    (%rcx), %eax
        test   %eax, %eax
        jg     L11
        neg    %eax
        mov    %eax, (%rcx)
L11:
        ret

@SUBSTITUTE_ENTRY_NAME:

        mov    $88000000, %edi
        call   malloc # returns pointer in rax

