1extern int __VERIFIER_nondet_int();
2typedef unsigned char __u_char;
3typedef unsigned short int __u_short;
4typedef unsigned int __u_int;
5typedef unsigned long int __u_long;
6typedef signed char __int8_t;
7typedef unsigned char __uint8_t;
8typedef signed short int __int16_t;
9typedef unsigned short int __uint16_t;
10typedef signed int __int32_t;
11typedef unsigned int __uint32_t;
12typedef signed long int __int64_t;
13typedef unsigned long int __uint64_t;
14typedef long int __quad_t;
15typedef unsigned long int __u_quad_t;
16typedef unsigned long int __dev_t;
17typedef unsigned int __uid_t;
18typedef unsigned int __gid_t;
19typedef unsigned long int __ino_t;
20typedef unsigned long int __ino64_t;
21typedef unsigned int __mode_t;
22typedef unsigned long int __nlink_t;
23typedef long int __off_t;
24typedef long int __off64_t;
25typedef int __pid_t;
26typedef struct { int __val[2]; } __fsid_t;
27typedef long int __clock_t;
28typedef unsigned long int __rlim_t;
29typedef unsigned long int __rlim64_t;
30typedef unsigned int __id_t;
31typedef long int __time_t;
32typedef unsigned int __useconds_t;
33typedef long int __suseconds_t;
34typedef int __daddr_t;
35typedef long int __swblk_t;
36typedef int __key_t;
37typedef int __clockid_t;
38typedef void * __timer_t;
39typedef long int __blksize_t;
40typedef long int __blkcnt_t;
41typedef long int __blkcnt64_t;
42typedef unsigned long int __fsblkcnt_t;
43typedef unsigned long int __fsblkcnt64_t;
44typedef unsigned long int __fsfilcnt_t;
45typedef unsigned long int __fsfilcnt64_t;
46typedef long int __ssize_t;
47typedef __off64_t __loff_t;
48typedef __quad_t *__qaddr_t;
49typedef char *__caddr_t;
50typedef long int __intptr_t;
51typedef unsigned int __socklen_t;
52typedef long unsigned int size_t;
53
54typedef __time_t time_t;
55
56
57struct timespec
58 {
59 __time_t tv_sec;
60 long int tv_nsec;
61 };
62typedef __pid_t pid_t;
63struct sched_param
64 {
65 int __sched_priority;
66 };
67
68
69struct __sched_param
70 {
71 int __sched_priority;
72 };
73typedef unsigned long int __cpu_mask;
74typedef struct
75{
76 __cpu_mask __bits[1024 / (8 * sizeof (__cpu_mask))];
77} cpu_set_t;
78
79extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp)
80 __attribute__ ((__nothrow__ , __leaf__));
81extern cpu_set_t *__sched_cpualloc (size_t __count) __attribute__ ((__nothrow__ , __leaf__)) ;
82extern void __sched_cpufree (cpu_set_t *__set) __attribute__ ((__nothrow__ , __leaf__));
83
84
85extern int sched_setparam (__pid_t __pid, __const struct sched_param *__param)
86 __attribute__ ((__nothrow__ , __leaf__));
87extern int sched_getparam (__pid_t __pid, struct sched_param *__param) __attribute__ ((__nothrow__ , __leaf__));
88extern int sched_setscheduler (__pid_t __pid, int __policy,
89 __const struct sched_param *__param) __attribute__ ((__nothrow__ , __leaf__));
90extern int sched_getscheduler (__pid_t __pid) __attribute__ ((__nothrow__ , __leaf__));
91extern int sched_yield (void) __attribute__ ((__nothrow__ , __leaf__));
92extern int sched_get_priority_max (int __algorithm) __attribute__ ((__nothrow__ , __leaf__));
93extern int sched_get_priority_min (int __algorithm) __attribute__ ((__nothrow__ , __leaf__));
94extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __attribute__ ((__nothrow__ , __leaf__));
95
96
97
98typedef __clock_t clock_t;
99
100
101typedef __clockid_t clockid_t;
102
103
104typedef __timer_t timer_t;
105
106struct tm
107{
108 int tm_sec;
109 int tm_min;
110 int tm_hour;
111 int tm_mday;
112 int tm_mon;
113 int tm_year;
114 int tm_wday;
115 int tm_yday;
116 int tm_isdst;
117 long int tm_gmtoff;
118 __const char *tm_zone;
119};
120
121
122struct itimerspec
123 {
124 struct timespec it_interval;
125 struct timespec it_value;
126 };
127struct sigevent;
128
129extern clock_t clock (void) __attribute__ ((__nothrow__ , __leaf__));
130extern time_t time (time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));
131extern double difftime (time_t __time1, time_t __time0)
132 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
133extern time_t mktime (struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));
134extern size_t strftime (char *__restrict __s, size_t __maxsize,
135 __const char *__restrict __format,
136 __const struct tm *__restrict __tp) __attribute__ ((__nothrow__ , __leaf__));
137
138typedef struct __locale_struct
139{
140 struct __locale_data *__locales[13];
141 const unsigned short int *__ctype_b;
142 const int *__ctype_tolower;
143 const int *__ctype_toupper;
144 const char *__names[13];
145} *__locale_t;
146typedef __locale_t locale_t;
147extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
148 __const char *__restrict __format,
149 __const struct tm *__restrict __tp,
150 __locale_t __loc) __attribute__ ((__nothrow__ , __leaf__));
151
152extern struct tm *gmtime (__const time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));
153extern struct tm *localtime (__const time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));
154
155extern struct tm *gmtime_r (__const time_t *__restrict __timer,
156 struct tm *__restrict __tp) __attribute__ ((__nothrow__ , __leaf__));
157extern struct tm *localtime_r (__const time_t *__restrict __timer,
158 struct tm *__restrict __tp) __attribute__ ((__nothrow__ , __leaf__));
159
160extern char *asctime (__const struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));
161extern char *ctime (__const time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));
162
163extern char *asctime_r (__const struct tm *__restrict __tp,
164 char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));
165extern char *ctime_r (__const time_t *__restrict __timer,
166 char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));
167extern char *__tzname[2];
168extern int __daylight;
169extern long int __timezone;
170extern char *tzname[2];
171extern void tzset (void) __attribute__ ((__nothrow__ , __leaf__));
172extern int daylight;
173extern long int timezone;
174extern int stime (__const time_t *__when) __attribute__ ((__nothrow__ , __leaf__));
175extern time_t timegm (struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));
176extern time_t timelocal (struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));
177extern int dysize (int __year) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
178extern int nanosleep (__const struct timespec *__requested_time,
179 struct timespec *__remaining);
180extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __attribute__ ((__nothrow__ , __leaf__));
181extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __attribute__ ((__nothrow__ , __leaf__));
182extern int clock_settime (clockid_t __clock_id, __const struct timespec *__tp)
183 __attribute__ ((__nothrow__ , __leaf__));
184extern int clock_nanosleep (clockid_t __clock_id, int __flags,
185 __const struct timespec *__req,
186 struct timespec *__rem);
187extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __attribute__ ((__nothrow__ , __leaf__));
188extern int timer_create (clockid_t __clock_id,
189 struct sigevent *__restrict __evp,
190 timer_t *__restrict __timerid) __attribute__ ((__nothrow__ , __leaf__));
191extern int timer_delete (timer_t __timerid) __attribute__ ((__nothrow__ , __leaf__));
192extern int timer_settime (timer_t __timerid, int __flags,
193 __const struct itimerspec *__restrict __value,
194 struct itimerspec *__restrict __ovalue) __attribute__ ((__nothrow__ , __leaf__));
195extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
196 __attribute__ ((__nothrow__ , __leaf__));
197extern int timer_getoverrun (timer_t __timerid) __attribute__ ((__nothrow__ , __leaf__));
198
199typedef unsigned long int pthread_t;
200typedef union
201{
202 char __size[56];
203 long int __align;
204} pthread_attr_t;
205typedef struct __pthread_internal_list
206{
207 struct __pthread_internal_list *__prev;
208 struct __pthread_internal_list *__next;
209} __pthread_list_t;
210typedef union
211{
212 struct __pthread_mutex_s
213 {
214 int __lock;
215 unsigned int __count;
216 int __owner;
217 unsigned int __nusers;
218 int __kind;
219 int __spins;
220 __pthread_list_t __list;
221 } __data;
222 char __size[40];
223 long int __align;
224} pthread_mutex_t;
225typedef union
226{
227 char __size[4];
228 int __align;
229} pthread_mutexattr_t;
230typedef union
231{
232 struct
233 {
234 int __lock;
235 unsigned int __futex;
236 __extension__ unsigned long long int __total_seq;
237 __extension__ unsigned long long int __wakeup_seq;
238 __extension__ unsigned long long int __woken_seq;
239 void *__mutex;
240 unsigned int __nwaiters;
241 unsigned int __broadcast_seq;
242 } __data;
243 char __size[48];
244 __extension__ long long int __align;
245} pthread_cond_t;
246typedef union
247{
248 char __size[4];
249 int __align;
250} pthread_condattr_t;
251typedef unsigned int pthread_key_t;
252typedef int pthread_once_t;
253typedef union
254{
255 struct
256 {
257 int __lock;
258 unsigned int __nr_readers;
259 unsigned int __readers_wakeup;
260 unsigned int __writer_wakeup;
261 unsigned int __nr_readers_queued;
262 unsigned int __nr_writers_queued;
263 int __writer;
264 int __shared;
265 unsigned long int __pad1;
266 unsigned long int __pad2;
267 unsigned int __flags;
268 } __data;
269 char __size[56];
270 long int __align;
271} pthread_rwlock_t;
272typedef union
273{
274 char __size[8];
275 long int __align;
276} pthread_rwlockattr_t;
277typedef volatile int pthread_spinlock_t;
278typedef union
279{
280 char __size[32];
281 long int __align;
282} pthread_barrier_t;
283typedef union
284{
285 char __size[4];
286 int __align;
287} pthread_barrierattr_t;
288typedef long int __jmp_buf[8];
289enum
290{
291 PTHREAD_CREATE_JOINABLE,
292 PTHREAD_CREATE_DETACHED
293};
294enum
295{
296 PTHREAD_MUTEX_TIMED_NP,
297 PTHREAD_MUTEX_RECURSIVE_NP,
298 PTHREAD_MUTEX_ERRORCHECK_NP,
299 PTHREAD_MUTEX_ADAPTIVE_NP
300 ,
301 PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
302 PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
303 PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
304 PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
305};
306enum
307{
308 PTHREAD_MUTEX_STALLED,
309 PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,
310 PTHREAD_MUTEX_ROBUST,
311 PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST
312};
313enum
314{
315 PTHREAD_RWLOCK_PREFER_READER_NP,
316 PTHREAD_RWLOCK_PREFER_WRITER_NP,
317 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
318 PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP
319};
320enum
321{
322 PTHREAD_INHERIT_SCHED,
323 PTHREAD_EXPLICIT_SCHED
324};
325enum
326{
327 PTHREAD_SCOPE_SYSTEM,
328 PTHREAD_SCOPE_PROCESS
329};
330enum
331{
332 PTHREAD_PROCESS_PRIVATE,
333 PTHREAD_PROCESS_SHARED
334};
335struct _pthread_cleanup_buffer
336{
337 void (*__routine) (void *);
338 void *__arg;
339 int __canceltype;
340 struct _pthread_cleanup_buffer *__prev;
341};
342enum
343{
344 PTHREAD_CANCEL_ENABLE,
345 PTHREAD_CANCEL_DISABLE
346};
347enum
348{
349 PTHREAD_CANCEL_DEFERRED,
350 PTHREAD_CANCEL_ASYNCHRONOUS
351};
352
353extern int pthread_create (pthread_t *__restrict __newthread,
354 __const pthread_attr_t *__restrict __attr,
355 void *(*__start_routine) (void *),
356 void *__restrict __arg) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 3)));
357extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__));
358extern int pthread_join (pthread_t __th, void **__thread_return);
359extern int pthread_detach (pthread_t __th) __attribute__ ((__nothrow__ , __leaf__));
360extern pthread_t pthread_self (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
361extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) __attribute__ ((__nothrow__ , __leaf__));
362extern int pthread_attr_init (pthread_attr_t *__attr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
363extern int pthread_attr_destroy (pthread_attr_t *__attr)
364 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
365extern int pthread_attr_getdetachstate (__const pthread_attr_t *__attr,
366 int *__detachstate)
367 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
368extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
369 int __detachstate)
370 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
371extern int pthread_attr_getguardsize (__const pthread_attr_t *__attr,
372 size_t *__guardsize)
373 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
374extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
375 size_t __guardsize)
376 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
377extern int pthread_attr_getschedparam (__const pthread_attr_t *__restrict
378 __attr,
379 struct sched_param *__restrict __param)
380 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
381extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
382 __const struct sched_param *__restrict
383 __param) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
384extern int pthread_attr_getschedpolicy (__const pthread_attr_t *__restrict
385 __attr, int *__restrict __policy)
386 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
387extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
388 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
389extern int pthread_attr_getinheritsched (__const pthread_attr_t *__restrict
390 __attr, int *__restrict __inherit)
391 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
392extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
393 int __inherit)
394 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
395extern int pthread_attr_getscope (__const pthread_attr_t *__restrict __attr,
396 int *__restrict __scope)
397 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
398extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
399 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
400extern int pthread_attr_getstackaddr (__const pthread_attr_t *__restrict
401 __attr, void **__restrict __stackaddr)
402 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))) __attribute__ ((__deprecated__));
403extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
404 void *__stackaddr)
405 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__deprecated__));
406extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict
407 __attr, size_t *__restrict __stacksize)
408 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
409extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
410 size_t __stacksize)
411 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
412extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
413 void **__restrict __stackaddr,
414 size_t *__restrict __stacksize)
415 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2, 3)));
416extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
417 size_t __stacksize) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
418extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
419 __const struct sched_param *__param)
420 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3)));
421extern int pthread_getschedparam (pthread_t __target_thread,
422 int *__restrict __policy,
423 struct sched_param *__restrict __param)
424 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
425extern int pthread_setschedprio (pthread_t __target_thread, int __prio)
426 __attribute__ ((__nothrow__ , __leaf__));
427extern int pthread_once (pthread_once_t *__once_control,
428 void (*__init_routine) (void)) __attribute__ ((__nonnull__ (1, 2)));
429extern int pthread_setcancelstate (int __state, int *__oldstate);
430extern int pthread_setcanceltype (int __type, int *__oldtype);
431extern int pthread_cancel (pthread_t __th);
432extern void pthread_testcancel (void);
433typedef struct
434{
435 struct
436 {
437 __jmp_buf __cancel_jmp_buf;
438 int __mask_was_saved;
439 } __cancel_jmp_buf[1];
440 void *__pad[4];
441} __pthread_unwind_buf_t __attribute__ ((__aligned__));
442struct __pthread_cleanup_frame
443{
444 void (*__cancel_routine) (void *);
445 void *__cancel_arg;
446 int __do_it;
447 int __cancel_type;
448};
449extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
450 ;
451extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
452 ;
453extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
454 __attribute__ ((__noreturn__))
455 __attribute__ ((__weak__))
456 ;
457struct __jmp_buf_tag;
458extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __attribute__ ((__nothrow__ , __leaf__));
459extern int pthread_mutex_init (pthread_mutex_t *__mutex,
460 __const pthread_mutexattr_t *__mutexattr)
461 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
462extern int pthread_mutex_destroy (pthread_mutex_t *__mutex)
463 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
464extern int pthread_mutex_trylock (pthread_mutex_t *__mutex)
465 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
466extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
467 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
468extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
469 __const struct timespec *__restrict
470 __abstime) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
471extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
472 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
473extern int pthread_mutex_getprioceiling (__const pthread_mutex_t *
474 __restrict __mutex,
475 int *__restrict __prioceiling)
476 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
477extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
478 int __prioceiling,
479 int *__restrict __old_ceiling)
480 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 3)));
481extern int pthread_mutex_consistent (pthread_mutex_t *__mutex)
482 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
483extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr)
484 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
485extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr)
486 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
487extern int pthread_mutexattr_getpshared (__const pthread_mutexattr_t *
488 __restrict __attr,
489 int *__restrict __pshared)
490 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
491extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
492 int __pshared)
493 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
494extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
495 __attr, int *__restrict __kind)
496 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
497extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
498 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
499extern int pthread_mutexattr_getprotocol (__const pthread_mutexattr_t *
500 __restrict __attr,
501 int *__restrict __protocol)
502 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
503extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr,
504 int __protocol)
505 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
506extern int pthread_mutexattr_getprioceiling (__const pthread_mutexattr_t *
507 __restrict __attr,
508 int *__restrict __prioceiling)
509 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
510extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr,
511 int __prioceiling)
512 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
513extern int pthread_mutexattr_getrobust (__const pthread_mutexattr_t *__attr,
514 int *__robustness)
515 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
516extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
517 int __robustness)
518 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
519extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
520 __const pthread_rwlockattr_t *__restrict
521 __attr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
522extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
523 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
524extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
525 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
526extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
527 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
528extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
529 __const struct timespec *__restrict
530 __abstime) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
531extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
532 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
533extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
534 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
535extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
536 __const struct timespec *__restrict
537 __abstime) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));
538extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
539 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
540extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr)
541 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
542extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr)
543 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
544extern int pthread_rwlockattr_getpshared (__const pthread_rwlockattr_t *
545 __restrict __attr,
546 int *__restrict __pshared)
547 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
548extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
549 int __pshared)
550 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
551extern int pthread_rwlockattr_getkind_np (__const pthread_rwlockattr_t *
552 __restrict __attr,
553 int *__restrict __pref)
554 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
555extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
556 int __pref) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
557extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
558 __const pthread_condattr_t *__restrict
559 __cond_attr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
560extern int pthread_cond_destroy (pthread_cond_t *__cond)
561 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
562extern int pthread_cond_signal (pthread_cond_t *__cond)
563 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
564extern int pthread_cond_broadcast (pthread_cond_t *__cond)
565 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
566extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
567 pthread_mutex_t *__restrict __mutex)
568 __attribute__ ((__nonnull__ (1, 2)));
569extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
570 pthread_mutex_t *__restrict __mutex,
571 __const struct timespec *__restrict
572 __abstime) __attribute__ ((__nonnull__ (1, 2, 3)));
573extern int pthread_condattr_init (pthread_condattr_t *__attr)
574 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
575extern int pthread_condattr_destroy (pthread_condattr_t *__attr)
576 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
577extern int pthread_condattr_getpshared (__const pthread_condattr_t *
578 __restrict __attr,
579 int *__restrict __pshared)
580 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
581extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
582 int __pshared) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
583extern int pthread_condattr_getclock (__const pthread_condattr_t *
584 __restrict __attr,
585 __clockid_t *__restrict __clock_id)
586 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
587extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
588 __clockid_t __clock_id)
589 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
590extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
591 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
592extern int pthread_spin_destroy (pthread_spinlock_t *__lock)
593 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
594extern int pthread_spin_lock (pthread_spinlock_t *__lock)
595 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
596extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
597 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
598extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
599 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
600extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
601 __const pthread_barrierattr_t *__restrict
602 __attr, unsigned int __count)
603 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
604extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
605 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
606extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
607 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1)));
608extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr)
609 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
610extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr)
611 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
612extern int pthread_barrierattr_getpshared (__const pthread_barrierattr_t *
613 __restrict __attr,
614 int *__restrict __pshared)
615 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
616extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
617 int __pshared)
618 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
619extern int pthread_key_create (pthread_key_t *__key,
620 void (*__destr_function) (void *))
621 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
622extern int pthread_key_delete (pthread_key_t __key) __attribute__ ((__nothrow__ , __leaf__));
623extern void *pthread_getspecific (pthread_key_t __key) __attribute__ ((__nothrow__ , __leaf__));
624extern int pthread_setspecific (pthread_key_t __key,
625 __const void *__pointer) __attribute__ ((__nothrow__ , __leaf__)) ;
626extern int pthread_getcpuclockid (pthread_t __thread_id,
627 __clockid_t *__clock_id)
628 __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
629extern int pthread_atfork (void (*__prepare) (void),
630 void (*__parent) (void),
631 void (*__child) (void)) __attribute__ ((__nothrow__ , __leaf__));
632
633int idx=0;
634int ctr1=1, ctr2=0;
635int readerprogress1=0, readerprogress2=0;
636pthread_mutex_t mutex;
637void __VERIFIER_atomic_use1(int myidx) {
638 __VERIFIER_assume(myidx <= 0 && ctr1>0);
639 ctr1++;
640}
641void __VERIFIER_atomic_use2(int myidx) {
642 __VERIFIER_assume(myidx >= 1 && ctr2>0);
643 ctr2++;
644}
645void __VERIFIER_atomic_use_done(int myidx) {
646 if (myidx <= 0) { ctr1--; }
647 else { ctr2--; }
648}
649void __VERIFIER_atomic_take_snapshot(int readerstart1, int readerstart2) {
650 readerstart1 = readerprogress1;
651 readerstart2 = readerprogress2;
652}
653void __VERIFIER_atomic_check_progress1(int readerstart1) {
654 if (__VERIFIER_nondet_int()) {
655 __VERIFIER_assume(readerstart1 == 1 && readerprogress1 == 1);
656 if (!(0)) ERROR: goto ERROR;;
657 }
658 return;
659}
660void __VERIFIER_atomic_check_progress2(int readerstart2) {
661 if (__VERIFIER_nondet_int()) {
662 __VERIFIER_assume(readerstart2 == 1 && readerprogress2 == 1);
663 if (!(0)) ERROR: goto ERROR;;
664 }
665 return;
666}
667void *qrcu_reader1() {
668 int myidx;
669 while (1) {
670 myidx = idx;
671 if (__VERIFIER_nondet_int()) {
672 __VERIFIER_atomic_use1(myidx);
673 break;
674 } else {
675 if (__VERIFIER_nondet_int()) {
676 __VERIFIER_atomic_use2(myidx);
677 break;
678 } else {}
679 }
680 }
681 readerprogress1 = 1;
682 readerprogress1 = 2;
683 __VERIFIER_atomic_use_done(myidx);
684 return 0;
685}
686void *qrcu_reader2() {
687 int myidx;
688 while (1) {
689 myidx = idx;
690 if (__VERIFIER_nondet_int()) {
691 __VERIFIER_atomic_use1(myidx);
692 break;
693 } else {
694 if (__VERIFIER_nondet_int()) {
695 __VERIFIER_atomic_use2(myidx);
696 break;
697 } else {}
698 }
699 }
700 readerprogress2 = 1;
701 readerprogress2 = 2;
702 __VERIFIER_atomic_use_done(myidx);
703 return 0;
704}
705void* qrcu_updater() {
706 int i;
707 int readerstart1, readerstart2;
708 int sum;
709 __VERIFIER_atomic_take_snapshot(readerstart1, readerstart2);
710 if (__VERIFIER_nondet_int()) { sum = ctr1; sum = sum + ctr2; } else { sum = ctr2; sum = sum + ctr1; };
711 if (sum <= 1) { if (__VERIFIER_nondet_int()) { sum = ctr1; sum = sum + ctr2; } else { sum = ctr2; sum = sum + ctr1; }; }
712 else {}
713 if (sum > 1) {
714 pthread_mutex_lock(&mutex);
715 if (idx <= 0) { ctr2++; idx = 1; ctr1--; }
716 else { ctr1++; idx = 0; ctr2--; }
717 if (idx <= 0) { while (ctr1 > 0); }
718 else { while (ctr2 > 0); }
719 pthread_mutex_unlock(&mutex);
720 } else {}
721 __VERIFIER_atomic_check_progress1(readerstart1);
722 __VERIFIER_atomic_check_progress2(readerstart2);
723 return 0;
724}
725int main() {
726 pthread_t t1, t2, t3;
727 pthread_mutex_init(&mutex, 0);
728 pthread_create(&t1, 0, qrcu_reader1, 0);
729 pthread_create(&t2, 0, qrcu_reader2, 0);
730 pthread_create(&t3, 0, qrcu_updater, 0);
731 pthread_join(t1, 0);
732 pthread_join(t2, 0);
733 pthread_join(t3, 0);
734 pthread_mutex_destroy(&mutex);
735 return 0;
736}