| 1 |
/* { dg-require-effective-target alarm } */ |
| 2 |
/* { dg-require-effective-target signal } */ |
| 3 |
/* { dg-options "-O2" } */ |
| 4 |
|
| 5 |
#include <stdint.h> |
| 6 |
#include <unistd.h> |
| 7 |
#include <signal.h> |
| 8 |
#include <stdlib.h> |
| 9 |
|
| 10 |
int a = 1, b = 0; |
| 11 |
|
| 12 |
uint64_t safe_mod(uint64_t a, uint64_t b) |
| 13 |
{ |
| 14 |
if (b == 0) return a; |
| 15 |
else return a % b; |
| 16 |
} |
| 17 |
|
| 18 |
int __attribute__((noipa)) |
| 19 |
f(uint64_t p) |
| 20 |
{ |
| 21 |
int c = 0; |
| 22 |
j: |
| 23 |
b = safe_mod( |
| 24 |
(c = ((a &= (0 < p)) && 1), 1), p); |
| 25 |
if (!c) |
| 26 |
goto j; |
| 27 |
return 0; |
| 28 |
} |
| 29 |
|
| 30 |
void do_exit (int i) |
| 31 |
{ |
| 32 |
exit (0); |
| 33 |
} |
| 34 |
|
| 35 |
int main() |
| 36 |
{ |
| 37 |
struct sigaction s; |
| 38 |
sigemptyset (&s.sa_mask); |
| 39 |
s.sa_handler = do_exit; |
| 40 |
s.sa_flags = 0; |
| 41 |
sigaction (SIGALRM, &s, NULL); |
| 42 |
alarm (1); |
| 43 |
f(b); |
| 44 |
} |