<commit_before>#include <stdlib.h>
#include <assert.h>
#include "mimick.h"

#define JUNK_PTR ((void *) 0x4242424242424242L)

void *malloc_mock (size_t size)
{
    (void) size;
    return JUNK_PTR;
}

int main (void)
{
    mmk_init ();

    assert (malloc (4) != JUNK_PTR);

    mmk_mock m = mmk_mock_create ("malloc", NULL, (mmk_fn) malloc_mock);

    assert (malloc (4) == JUNK_PTR);

    mmk_mock_destroy (m);

    assert (malloc (4) != JUNK_PTR);

    return 0;
}<commit_msg>Fixed malloc sample being aggressively optimized<commit_after>#undef NDEBUG
#include <stdlib.h>
#include <assert.h>
#include "mimick.h"

#define JUNK_PTR ((void *) 0x4242424242424242L)

void *malloc_mock (size_t size)
{
    (void) size;
    return JUNK_PTR;
}

int main (void)
{
    mmk_init ();

    assert (malloc (4) != JUNK_PTR);

    mmk_mock m = mmk_mock_create ("malloc", NULL, (mmk_fn) malloc_mock);

    /* We need volatile here because GCC aggressively optimises the code
       to always fail, since it isn't expected for malloc to return a
       fixed value like JUNK_PTR */
    void *volatile ptr = malloc (4);
    assert (ptr == JUNK_PTR);

    mmk_mock_destroy (m);

    assert (malloc (4) != JUNK_PTR);

    return 0;
}
{'fraction_non_alphanumeric': 0.12685337726523888, 'fraction_numerical': 0.03459637561779242, 'mean_word_length': 3.516728624535316, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6291833', 'n_tokens_mistral': 490, 'n_tokens_neox': 452, 'n_words': 127}