you may either need to use the local variables or compile with optimisations disasble
I assume you are using msvc on windows ?? shown below is a snippet that was compiled on x64 for x64 in win 10 where you can clearlu seethe local vars being initialized and used
F:\src\local>f:\git\usr\bin\ls -lg
total 1
-rw-r--r-- 1 197121 61 Sep 25 15:24 local.cpp
F:\src\local>f:\git\usr\bin\cat *
int main (void)
{
int x = 1;
int y = 2;
return x+y;
}
F:\src\local>cl /Zi /W4 -GS /analyze /Od /nologo local.cpp /link /release /ENTRY:main /SUBSYSTEM:windows /FIXED
local.cpp
F:\src\local>f:\git\usr\bin\ls -lg *.exe
-rwxr-xr-x 1 197121 2560 Sep 25 15:32 local.exe
opening the exe in ghidra and the function main copied as is
//
// .text
// ram: 140001000-140001022
//
**************************************************************
* FUNCTION *
**************************************************************
int __fastcall main(int _Argc, char * * _Argv, char * *
int EAX:4 <RETURN>
int ECX:4 _Argc
char * * RDX:8 _Argv
char * * R8:8 _Env
undefined4 Stack[-0x14]:4 local_14 XREF[2]: 140001004(W),
140001016(R)
undefined4 Stack[-0x18]:4 local_18 XREF[2]: 14000100c(*),
140001013(*)
|||||||||||||||||||| FUNCTION |||||||||||||||||||||||||||||||
Symbol Ref: main
entry XREF[4]: Entry Point(*), 1400000e0(*),
.text$mn 1400000e4(*), [more]
main
140001000 48 83 ec 18 SUB RSP,0x18
140001004 c7 44 24 MOV dword ptr [RSP + local_14],0x1
04 01 00
00 00
14000100c c7 04 24 MOV dword ptr [RSP]=>local_18,0x2
02 00 00 00
140001013 8b 04 24 MOV EAX,dword ptr [RSP]=>local_18
140001016 8b 4c 24 04 MOV _Argc,dword ptr [RSP + local_14]
14000101a 03 c8 ADD _Argc,EAX
14000101c 8b c1 MOV EAX,_Argc
14000101e 48 83 c4 18 ADD RSP,0x18
140001022 c3 RET
********** main Exit **********