I think you'll find that the problem is one of
sign-extension, that is to say - if you've only declared mem to be an array of 4 shorts, they are
SIGNEDshorts. App1 works ok because the first short is 0x7E - or
0111 1110
The others fail, because they all begin with a 1 bit in the MSB (most significant bit) This means they are interpreted as signed (-ve, in fact), so to maintain that negativity when they are multiplied 0 which is what a left shift is, they have 1 bits inserted (in the more significat bits), rather than 0 bits - which are still added in the least significant bits.
To fix, declare mem as an array of UNsigned shorts. (This behaviour doesn't happen in ASM - it's the C compiler does it for (to?) you)
The following code produces the output:
int64 value is : 7effffffffffff7e
#include <stdio.h>
#include <stdlib.h>
unsigned short mem[4];
void outputint64(__int64 i)
{
__int64 app1 = (__int64)mem[i+3] << 48; __int64 app2 = (__int64)mem[i+2] << 32;
__int64 app3 = (__int64)mem[i+1] << 16;
__int64 app4 = (__int64)mem[i];
__int64 app = (__int64)app1 | (__int64)app2 | (__int64)app3 | (__int64)app4;
printf("int64 value is : %I64x", app);
}
int main()
{
FILE *fp;
fp = fopen("inputData.bin", "rb");
fread(mem, 2, 4, fp);
fclose(fp);
int offset = 0;
outputint64(offset);
}