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

  • SEARCH
  • Home
  • 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 7516371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:06:32+00:00 2026-05-30T01:06:32+00:00

I have the following code in file main.c: int main() { int i; for

  • 0

I have the following code in file main.c:

int main() {
    int i;
    for (i = 0; i < 5; i++) {
    }

    return 0;
}

When I compile this with gcc -x c -m32 -S -O0 -o main.s main.c (under Fedora 16 64-bit) I get this output:

    .file   "main.c"
    .text
    .globl  main
    .type   main, @function
main:
.LFB0:
    .cfi_startproc
    pushl   %ebp
    .cfi_def_cfa_offset 8
    .cfi_offset 5, -8
    movl    %esp, %ebp
    .cfi_def_cfa_register 5
    subl    $16, %esp
    movl    $0, -4(%ebp)
    jmp .L2
.L3:
    addl    $1, -4(%ebp)
.L2:
    cmpl    $4, -4(%ebp)
    jle .L3
    movl    $0, %eax
    leave
    .cfi_restore 5
    .cfi_def_cfa 4, 4
    ret
    .cfi_endproc
.LFE0:
    .size   main, .-main
    .ident  "GCC: (GNU) 4.6.2 20111027 (Red Hat 4.6.2-1)"
    .section    .note.GNU-stack,"",@progbits

However, when I use gcc -x c++ -m32 -S -O0 -o main.s main.c I get the same output except for these lines:

.L2:
    cmpl    $4, -4(%ebp)
    setle   %al
    testb   %al, %al
    jne .L3

My question is: why does it use setle and testb instead of jle in C++ code? Is it more effective?

P.S. Also, is there a way to get rid of these .cfi_* directives in an assembly output?

  • 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-30T01:06:34+00:00Added an answer on May 30, 2026 at 1:06 am

    Well, you’re using a different compiler, so it’s not really that surprising that you get different output. clang does happen to give exactly the same results when compiling your program as C or C++, if that’s of interest to you:

    $ cp example.c example.cpp
    $ clang -o exampleC example.c
    $ clang++ -o exampleC++ example.cpp
    $ otool -tV exampleC > C
    $ otool -tV exampleC++ > C++
    $ diff C C++
    1c1
    < exampleC:
    ---
    > exampleC++:
    $
    

    I get the same results from gcc and g++ on my machine as well, so it looks like it’s just a quirk of your particular compiler version.

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

Sidebar

Related Questions

I have the following code: if (System.IO.File.Exists(htmlLocation)) { vEarthBrowser.ObjectForScripting = this; vEarthBrowser.Url = new
I have the following code: if (include_once(dirname(__FILE__).'/file.php') || include_once(dirname(__FILE__).'/local/file.php') ) { This causes an
I have the following code in a header included in main.mm: 1. virtual int
I have the following source code in main.cpp: #include <iostream> #include <iomanip> int main()
I have the following json code file named: sections.json { section1: { priority: 1,
Very simply put, I have the following code snippet: FILE* test = fopen(C:\\core.u, w);
I have the following code in my file to load a div with HTML
When I using the following code to read file: lines=file(data.txt).read().split(\n) I have the following
I have the following code in a web.config file of the default IIS site.
I have the following code which reads in the follow file, append a \r\n

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.