malloc_:
pushq %rbp
movq %rsp, %rbp
mov %rdi, %rcx # store size
movl $9, %eax # system call 9: sys_mmap
movq $0, %rdi # start address
movq %rcx, %rsi # size
movl $3, %edx # page flags (PROT_READ | PROT_WRITE)
mov $34, %r10 # mem flags (MAP_PRIVATE | MAP_ANONYMOUS)
movl $-1, %r8d # file descriptor
movl $0, %r9d # offset
syscall
cmp $0, %rax
jg .L1.malloc_exit_ # jump if allocation was successful
mov $0, %rax # set return value to 0 if failed
.L1.malloc_exit_:
popq %rbp
retq
malloc_:
pushq %rbp
movq %rsp, %rbp
mov %rdi, %rcx # store size
movl $9, %eax # system call 9: sys_mmap
movq $0, %rdi # start address
movq %rcx, %rsi # size
movl $3, %edx # page flags (PROT_READ | PROT_WRITE)
mov $34, %r10 # mem flags (MAP_PRIVATE | MAP_ANONYMOUS)
movl $-1, %r8d # file descriptor
movl $0, %r9d # offset
syscall
cmp $0, %rax
jg .L1.malloc_exit_ # jump if allocation was successful
mov $0, %rax # set return value to 0 if failed
.L1.malloc_exit_:
popq %rbp
retq