<commit_before>/**
		System information:
		Architecture: 32 bit

		Note: 
			Stacks on x86 processors are always fourbyte aligned.
			Stacks on x64 processors are always eightbyte aligned.

		Stack representation:
		
		---------------------------------------------------------------------------------
		| buffer1 | ret     | Slack   | EBP     | RET     | int a   | int b   | int c   |
		| 5 bytes | 4 bytes | 8 bytes | 4 bytes | 4 bytes | 4 bytes | 4 bytes | 4 bytes |
		---------------------------------------------------------------------------------

		For more information on this look into Function Calling Sequence in the
		official ABI documentation. 
		http://www.sco.com/developers/devspecs/abi386-4.pdf
**/

#include <stdio.h>

#define NOP 0x90

void function(int a, int b, int c) {
	char buffer1[5];
	// Set buffer contents to NOP for reference sake
	memset(buffer1, NOP, sizeof(buffer1));
	int *ret;
	/** 
		From buffer1 we need to move the pointer to RET,
		so buffer1 + 5 + 4 + 8 + 4 points to RET
	**/
	ret = buffer1 + 21;
	/**
		We now need to increment the return address by the difference
		between the addresses of x = 1; and printf("%d\n", x);,
		so that it points to printf("%d\n", x); rather than
		x = 1;
		The difference is found to be 2
	**/
	(*ret) += 2;
}

int main(void) {
	int x;
	x = 0;
	function(1, 2, 3);
	x = 1;
	printf("%d\n", x);
	return 0;
}<commit_msg>revised example3.c<commit_after>/**
		System information:
		Architecture: 32 bit

		Note: 
			Stacks on x86 processors are always fourbyte aligned.
			Stacks on x64 processors are always eightbyte aligned.

		Stack representation:
		
		---------------------------------------------------------------------------------
		| buffer1 | ret     | Slack   | EBP     | RET     | int a   | int b   | int c   |
		| 5 bytes | 4 bytes | 8 bytes | 4 bytes | 4 bytes | 4 bytes | 4 bytes | 4 bytes |
		---------------------------------------------------------------------------------

		For more information on this look into Function Calling Sequence in the
		official ABI documentation. 
		http://www.sco.com/developers/devspecs/abi386-4.pdf
**/

#include <stdio.h>

#define NOP 0x90

void function(int a, int b, int c) {
	char buffer1[5];
	// Set buffer contents to NOP for reference sake
	memset(buffer1, NOP, sizeof(buffer1));
	int *ret;
	/** 
		From buffer1 we need to move the pointer to RET,
		so buffer1 + 5 + 4 + 8 + 4 points to RET
	**/
	ret = buffer1 + 21;
	/**
		We now need to increment the return address by the difference
		between the addresses of x = 1; and printf("%d\n", x);,
		so that it points to printf("%d\n", x); rather than
		x = 1;
		Increment the return address so that it skips the assigment x=1;
	**/
	(*ret) += 1;
}

int main(void) {
	int x;
	x = 0;
	function(1, 2, 3);
	x = 1;
	printf("%d\n", x);
	return 0;
}
{'fraction_non_alphanumeric': 0.21484375, 'fraction_numerical': 0.03231534090909091, 'mean_word_length': 1.8598984771573603, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6853938', 'n_tokens_mistral': 998, 'n_tokens_neox': 869, 'n_words': 349}