@@ -8,8 +8,11 @@ extern int optind;
88#define __CPROVER_STRING_H_INCLUDED
99#endif
1010
11- inline int getopt (int argc , char * const argv [],
12- const char * optstring )
11+ __CPROVER_bool __VERIFIER_nondet___CPROVER_bool ();
12+ size_t __VERIFIER_nondet_size_t ();
13+
14+ inline int getopt (
15+ int argc , char * const argv [], const char * optstring )
1316{
1417 __CPROVER_HIDE :;
1518 int result = -1 ;
@@ -20,25 +23,26 @@ inline int getopt(int argc, char * const argv[],
2023 if (optind >=argc || argv [optind ][0 ]!= '-' )
2124 return -1 ;
2225
23- size_t result_index ;
26+ size_t result_index = __VERIFIER_nondet_size_t () ;
2427 __CPROVER_assume (
2528 result_index < strlen (optstring ) && optstring [result_index ]!= ':' );
2629 #ifdef __CPROVER_STRING_ABSTRACTION
2730 __CPROVER_assert (__CPROVER_is_zero_string (optstring ),
2831 "getopt zero-termination of 3rd argument" );
2932 #endif
3033
31- _Bool found ;
34+ __CPROVER_bool found = __VERIFIER_nondet___CPROVER_bool () ;
3235 if (found )
3336 {
3437 result = optstring [result_index ];
38+ __CPROVER_bool skipped = __VERIFIER_nondet___CPROVER_bool ();
3539 if (skipped )
3640 ++ optind ;
3741 }
3842
3943 if (result != -1 && optind < argc && optstring [result_index + 1 ]== ':' )
4044 {
41- _Bool has_no_arg ;
45+ __CPROVER_bool has_no_arg = __VERIFIER_nondet___CPROVER_bool () ;
4246 if (has_no_arg )
4347 {
4448 optarg = argv [optind ];
@@ -53,10 +57,17 @@ inline int getopt(int argc, char * const argv[],
5357
5458/* FUNCTION: getopt_long */
5559
56- int getopt (int argc , char * const argv [], const char * optstring );
60+ #ifndef __CPROVER_GETOPT_H_INCLUDED
61+ #include <getopt.h>
62+ #define __CPROVER_GETOPT_H_INCLUDED
63+ #endif
5764
58- inline int getopt_long (int argc , char * const argv [], const char * optstring ,
59- const struct option * longopts , int * longindex )
65+ inline int getopt_long (
66+ int argc ,
67+ char * const argv [],
68+ const char * optstring ,
69+ const struct option * longopts ,
70+ int * longindex )
6071{
6172 // trigger valid-pointer checks (if enabled), even though we don't
6273 // use the parameter in this model
0 commit comments