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 7708919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:44:04+00:00 2026-06-01T00:44:04+00:00

I use the Frama-C tool to generate the dependence graph of this program(main.c). #include<stdio.h>

  • 0

I use the Frama-C tool to generate the dependence graph of this program(main.c).

    #include<stdio.h>
    int main()
    {
        int n,i,m,j;
        while(scanf("%d",&n)!=EOF)
        { 
            m=n;
            for(i=n-1;i>=1;i--)
            {   
                m=m*i;
                while(m%10==0)
                {
                     m=m/10;
                }
                m=m%10000;
            }  
            m=m%10;
            printf("%5d -> %d\n",n,m);
        }
       return 0;
    }

The command is:

    frama-c -pdg -dot-pdg main main.c 
    dot -Tpdf main.main.dot -o main.pdf

The result is
enter image description here
My question is why the statments “m=m*i;”,”m=m%10000” do not map to nodes. The result does not seem right,because there are three loops in the code.

  • 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-06-01T00:44:05+00:00Added an answer on June 1, 2026 at 12:44 am

    A slicer for C programs only works in practice if its defined goal is
    to preserve defined executions, and the slicer is allowed to change undefined executions.

    Otherwise, the slicer would be unable to remove a statement such as x = *p; as soon as it is unable to determine that p is a valid pointer at that point, even if it knows that it does not need x, just because if the statement is removed, executions where p is NULL at that point are changed.

    Frama-C does not handle complex library functions such as scanf(). Because of this, it thinks that local variable n is used without being initialized.

    Type frama-c -val main.c
    You should get a warning like:

    main.c:10:[kernel] warning: accessing uninitialized left-value:
                   assert \initialized(&n);
    ...
    [value] Values for function main:
          NON TERMINATING FUNCTION
    

    The word assert means that Frama-C’s option -val is unable to determine that all executions are defined, and “NON TERMINATING FUNCTION” means that it is unable to find a single defined execution of the program to continue from.

    The undefined use of an uninitialized variable is the reason the PDG removes most statements. The PDG algorithm thinks it can remove them because they come after what it thinks is an undefined behavior, the first access to variable n.

    I modified your program slightly to replace the scanf() call with a simpler statement:

    #define EOF (-1)
    int unknown_int();
    
    int scan_unknown_int(int *p)
    {
      *p = unknown_int();
      return unknown_int();
    }
    
    int main()
    {
      int n,i,m,j;
      while(scan_unknown_int(&n) != EOF)
        { 
          m=n;
          for(i=n-1;i>=1;i--)
          {   
            m=m*i;
            while(m%10==0)
            {
              m=m/10;
            }
            m=m%10000;
          }  
          m=m%10;
          printf("%5d -> %d\n",n,m);
        }
      return 0;
    }
    

    and I got the PDG below. It looks complete as far as I can tell. If you know better layout programs than dot but that accept the dot format, this is a good chance to use them.

    Complex PDG
    Note that the condition of the outmost while became tmp != -1. The nodes of the graph are the statements of an internal normalized representation of the program. The condition tmp != -1 has a data dependency to the node for the statement tmp = unknown_int();. You can display the internal representation with frama-c -print main.c, and it will show that the outmost loop condition has been broken into:

      while (1) {
        int tmp;
        tmp = scan_unknown_int(& n);
        if (! (tmp != -1)) { break; }
    

    This helps, among other things, the slicing to remove only the parts of a complex statement that can be removed instead of having to keep the entire complex statement.

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

Sidebar

Related Questions

I use html frame on my webiste, it's been running for I while, usually
I know that I can't use this: myView.frame.origin.x = 25.0; and that I have
Why would I want to do this? typedef struct Frame_s { int x; int
I'm trying to use a frame-buster-buster, as discussed in this question: Frame Buster Buster
I'm attempting to wrap libpq for a program, and part of the FFI tool
I have a windows forms application in c# and I use ToolStripContainer Tool to
I want to download http://www.wordwebonline.com/search.pl?w=humane this webpage on UNIX. I tried to use wget
Trying to use virutalenv version 1.6.4 (the latest at writing this post) on 10.7,
I have a problem with JFrame and the key word this. When I use
When I run this program, the window blocks out the buttons in panel2 when

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.