Sum of Absolute Differences algorithm implementation
A more generic SAD function
Currently, your SAD function is hardcoded to work on a 3x3 area.  Also, because it takes 3x3 arrays as inputs, you need to use a temporary array tempImage in order to copy a 3x3 area of the original image so that you can pass it to your function.
If you modified your function a bit, you could pass the original image into the function without making a copy.  Here is how I would rewrite your function:
/**
 * Calculates sum of absolute differences between a pattern and an image.
 * The area of the image to be matched is at (imgX, imgY).
 */
int calSad(const int *pattern, int patWidth, int patHeight,
        const int *img, int imgX, int imgY, int imgWidth)
{
    int ret = 0;
    int x   = 0;
    int y   = 0;

    // Set img to point at &amp;img[imgY][imgX].
    img = img + (imgWidth * imgY) + imgX;
    for (y = 0; y &lt; patHeight; y++) {
        for (x = 0; x &lt; patWidth; x++)
            ret += abs(pattern[x] - img[x]);
        pattern += patWidth;
        img     += imgWidth;
    }
    return ret;
}

Note that I used y to indicate row and x to indicate column, which is reverse of how you named your variables.
Your loop in main() would simplify to this:
for (x = 0; x &lt;= originalImage_row_length - tempImage_row_length; x++) {
    for (z = 0; z &lt;= originalImage_col_length - tempImage_col_length; z++) {
        tempSad = calSad(&amp;tem[0][0], LEN(tem), LEN(tem[0]),
                        &amp;originalImage[0][0], z, x, LEN(originalImage[0]));
        if (tempSad &lt; sad) {
            sad = tempSad;
            Xcoordinate = x;
            Ycoordinate = z;
        }
    }
}