Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6736639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:09:14+00:00 2026-05-26T11:09:14+00:00

I have created this code: #include <stdio.h> typedef unsigned int uint; uint in[2]={1,2},out[2]={3,4}; int

  • 0

I have created this code:

#include <stdio.h>

typedef unsigned int uint;
uint in[2]={1,2},out[2]={3,4};

int main() {

    in[0]=out[0]/10;
}

and compiled it with GCC (v4.4.5,no optimizations) on Linux, the resulting assembly is:

0000000000400474 <main>:
400474:       55                      push   rbp
400475:       48 89 e5                mov    rbp,rsp
400478:       8b 05 ae 03 20 00       mov    eax,DWORD PTR [rip+0x2003ae]        # 0082c <out>
40047e:       89 45 fc                mov    DWORD PTR [rbp-0x4],eax
400481:       ba cd cc cc cc          mov    edx,0xcccccccd
400486:       8b 45 fc                mov    eax,DWORD PTR [rbp-0x4]
400489:       f7 e2                   mul    edx
40048b:       89 d0                   mov    eax,edx
40048d:       c1 e8 03                shr    eax,0x3
400490:       89 05 8e 03 20 00       mov    DWORD PTR [rip+0x20038e],eax        # 600824 <in>
400496:       c9                      leave
400497:       c3                      ret
400498:       90                      nop
400499:       90                      nop
40049a:       90                      nop
40049b:       90                      nop
40049c:       90                      nop
40049d:       90                      nop
40049e:       90                      nop
40049f:       90                      nop

Now, the question is: what is this code doing on line #5 ?

40047e:       89 45 fc                mov    DWORD PTR [rbp-0x4],eax

isn’t it storing the value it got from out[0] again in some place in memory? Why so? I didn’t tell it to read and write immediatly to some location.

Now, this temporal variable appears again at the address 400486 on line #7:

400486:       8b 45 fc                mov    eax,DWORD PTR [rbp-0x4]

It looks like in this example GCC is producing very inefficient code, and it will evict the cache line because of these temporal storages. Please confirm, maybe there is something I am not getting.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:09:15+00:00Added an answer on May 26, 2026 at 11:09 am

    GCC makes very inefficient code when compiling on -O0 – what you’re seeing is basically a raw translation of its internal representation of the program. This internal representation includes a number of temporary variables, and your load/store pair here is a value passing through such a temporary. On higher optimization levels these kinds of useless loads/stores will mostly be eliminated; however on -O0 even the simplest of analysis is disabled.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created this simple window with Visual Studio 2010: #include <stdio.h> #include <string.h>
I have created this code, and when I run it, don't get any errors
I have an array created with this code: var widthRange = new Array(); widthRange[46]
All, I am trying to code a Connect4 game. For this, I have created
So we have code like: #include cpptk.h #include <stdio.h> using namespace Tk; void hello()
c program compiler gcc I have 3 files. main.c stop_watch.h and stop_watch.c This program
I have this code to create an ATOM feed Dim xmlResult As New StringBuilder
I have this code which should create a splash image with either no animation
I have this code working in C#: var request = (HttpWebRequest)WebRequest.Create(https://x.com/service); request.Method = GET;
I have the this code that will create excel file and work sheet then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.