<commit_before>from unicorn.x86_const import *
import os
import sys

from usercorn import syscalls

SYSCALLS = {
    1: 'exit',
    2: 'fork',
    3: 'read',
    4: 'write',
    5: 'open',
    6: 'close',
    7: 'wait4',
    9: 'link',
    10: 'unlink',
    73: 'munmap',
    197: 'mmap',
    199: 'lseek',
}

def syscall(cls):
    num = cls.reg_read(UC_X86_REG_EAX)
    ret = syscalls.call(cls, SYSCALLS, num, syscalls.stack_args(cls))
    cls.reg_write(UC_X86_REG_EAX, ret)

def interrupt(cls, intno):
    if intno == 0x80:
        syscall(cls)
    else:
        raise NotImplementedError('unhandled interrupt %d' % intno)
<commit_msg>save/restore esp during x86/darwin syscall<commit_after>from unicorn.x86_const import *
import os
import sys

from usercorn import syscalls

SYSCALLS = {
    1: 'exit',
    2: 'fork',
    3: 'read',
    4: 'write',
    5: 'open',
    6: 'close',
    7: 'wait4',
    9: 'link',
    10: 'unlink',
    73: 'munmap',
    197: 'mmap',
    199: 'lseek',
}

def syscall(cls):
    esp = cls.reg_read(UC_X86_REG_ESP)
    num = cls.reg_read(UC_X86_REG_EAX)
    ret = syscalls.call(cls, SYSCALLS, num, syscalls.stack_args(cls))
    cls.reg_write(UC_X86_REG_EAX, ret)
    cls.reg_write(UC_X86_REG_ESP, esp)

def interrupt(cls, intno):
    if intno == 0x80:
        syscall(cls)
    else:
        raise NotImplementedError('unhandled interrupt %d' % intno)

{'fraction_non_alphanumeric': 0.14192614047791455, 'fraction_numerical': 0.04489500362056481, 'mean_word_length': 3.0174418604651163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4710770', 'n_tokens_mistral': 608, 'n_tokens_neox': 563, 'n_words': 128}