1  /* { dg-do compile } */
       2  /* { dg-options "-O -fcf-protection" } */
       3  /* { dg-final { scan-assembler-times "endbr32" 2 { target ia32 } } } */
       4  /* { dg-final { scan-assembler-times "endbr64" 2 { target { ! ia32 } } } } */
       5  /* { dg-final { scan-assembler-times "call	_?setjmp" 1 } } */
       6  /* { dg-final { scan-assembler-times "call	_?longjmp" 1 } } */
       7  
       8  #include <stdio.h>
       9  #include <setjmp.h>
      10  
      11  jmp_buf buf;
      12  static int bar (int);
      13  
      14  __attribute__ ((noinline, noclone))
      15  static int
      16  foo (int i)
      17  {
      18    int j = i * 11;
      19  
      20    if (!setjmp (buf))
      21      {
      22        j += 33;
      23        printf ("After setjmp: j = %d\n", j);
      24        bar (j);
      25      }
      26  
      27    return j + i;
      28  }
      29  
      30  __attribute__ ((noinline, noclone))
      31  static int
      32  bar (int i)
      33  {
      34   int j = i;
      35  
      36    j -= 111;
      37    printf ("In longjmp: j = %d\n", j);
      38    longjmp (buf, 1);
      39  
      40    return j;
      41  }
      42  
      43  int
      44  main ()
      45  {
      46    foo (10);
      47    return 0;
      48  }