diff mbox

[RFA/RFC] Stack clash mitigation patch 04/08

Message ID 11b791e4-d254-c263-b582-117a8f76771f@redhat.com
State New
Headers show

Commit Message

Jeff Law July 11, 2017, 9:20 p.m. UTC
This patch introduces x86 target specific bits to mitigate stack clash
attacks.

The key differences relative to the -fstack-check=specific expander are
that it never allocates more than PROBE_INTERVAL bytes at a time, it
probes into each allocated hunk immediately after allocation, and it
exploits the fact that a call instruction generates an implicit probe at
*sp for the callee and uses that fact to avoid many explicit probes.


The highlights:

  1. If the size of the local frame is < PROBE_INTERVAL, then no
     probing is needed.

  2. For up to 4 * PROBE_INTERVAL sized frames the allocation and
     probe are emitted inline.

  3. Anything larger we implement as a allocate/probe loop where
     each iteration handles a region of PROBE_INTERVAL size.

  4. Residuals need not be probed.

  5. CFIs should be correct, even for the loop case.

  6. Introduces several new tests.  Many of which are used unmodified
     on ppc, aarch64 and s390 later.


This implementation should be very efficient for the most common cases.

Comments/Questions?  OK for the trunk?
* config/i386/i386.c (ix86_adjust_stack_and_probe_stack_clash): New.
	(ix86_expand_prologue): Dump stack clash info as needed.
	Call ix86_adjust_stack_and_probe_stack_clash as needed.

testsuite/

	* gcc.dg/stack-check-4.c: New test.
	* gcc.dg/stack-check-5.c: New test.
	* gcc.dg/stack-check-6.c: New test.
	* gcc.dg/stack-check-7.c: New test.
	* gcc.dg/stack-check-8.c: New test.
	* gcc.dg/stack-check-9.c: New test.
	* gcc.dg/stack-check-10.c: New test.
commit e8fae56a2362c2952f735ce515c84de970efc582
Author: Jeff Law <law@torsion.usersys.redhat.com>
Date:   Thu Jun 29 16:36:51 2017 -0400

    X86 bits
    and test for noreturn callee
    
    Add more logging to x86 code
    More tests
    use dg-requires
    do not optimizing sibling calls
    
    Florian's tests
    
    Add suitable regexps for targets that have implicit probes, but must allocate
    small amounts of stack in non-leaf functions.
    Add -Wno-psabi to stack-check-8
    Do not optimizing sibling calls
    use dg-requires
diff mbox

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 0947b3c..7098f74 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -13779,6 +13779,140 @@  release_scratch_register_on_entry (struct scratch_reg *sr)
 
 #define PROBE_INTERVAL (1 << STACK_CHECK_PROBE_INTERVAL_EXP)
 
+/* Emit code to adjust the stack pointer by SIZE bytes while probing it.
+
+   This differs from the next routine in that it tries hard to prevent
+   attacks that jump the stack guard.  Thus it is never allowed to allocate
+   more than PROBE_INTERVAL bytes of stack space without a suitable
+   probe.  */
+
+static void
+ix86_adjust_stack_and_probe_stack_clash (const HOST_WIDE_INT size)
+{
+  struct machine_function *m = cfun->machine;
+
+  /* If this function does not statically allocate stack space, then
+     no probes are needed.  */
+  if (!size)
+    {
+      dump_stack_clash_frame_info (NO_PROBE_NO_FRAME, false);
+      return;
+    }
+
+  /* If we are a noreturn function, then we have to consider the
+     possibility that we're called via a jump rather than a call.
+
+     Thus we don't have the implicit probe generated by saving the
+     return address into the stack at the call.  Thus, the stack
+     pointer could be anywhere in the guard page.  The safe thing
+     to do is emit a probe now.
+
+     ?!? This should be revamped to work like aarch64 and s390 where
+     we track the offset from the most recent probe.  Normally that
+     offset would be zero.  For a non-return function we would reset
+     it to PROBE_INTERVAL - (STACK_BOUNDARY / BITS_PER_UNIT).   Then
+     we just probe when we cross PROBE_INTERVAL.  */
+  if (TREE_THIS_VOLATILE (cfun->decl))
+    emit_stack_probe (plus_constant (Pmode, stack_pointer_rtx,
+				     -GET_MODE_SIZE (word_mode)));
+
+  /* If we allocate less than PROBE_INTERVAL bytes statically,
+     then no probing is necessary, but we do need to allocate
+     the stack.  */
+  if (size < PROBE_INTERVAL)
+    {
+      pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
+			         GEN_INT (-size), -1,
+			         m->fs.cfa_reg == stack_pointer_rtx);
+      dump_stack_clash_frame_info (NO_PROBE_SMALL_FRAME, true);
+      return;
+    }
+
+  /* We're allocating a large enough stack frame that we need to
+     emit probes.  Either emit them inline or in a loop depending
+     on the size.  */
+  if (size <= 4 * PROBE_INTERVAL)
+    {
+      HOST_WIDE_INT i;
+      for (i = PROBE_INTERVAL; i <= size; i += PROBE_INTERVAL)
+	{
+	  /* Allocate PROBE_INTERVAL bytes.  */
+	  pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
+				     GEN_INT (-PROBE_INTERVAL), -1,
+				     m->fs.cfa_reg == stack_pointer_rtx);
+
+	  /* And probe at *sp.  */
+	  emit_stack_probe (stack_pointer_rtx);
+	}
+
+      /* We need to allocate space for the residual, but we do not need
+	 to probe the residual.  */
+      HOST_WIDE_INT residual = (i - PROBE_INTERVAL - size);
+      if (residual)
+	pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
+				   GEN_INT (residual), -1,
+				   m->fs.cfa_reg == stack_pointer_rtx);
+      dump_stack_clash_frame_info (PROBE_INLINE, residual != 0);
+    }
+  else
+    {
+      struct scratch_reg sr;
+      get_scratch_register_on_entry (&sr);
+
+      /* Step 1: round SIZE down to a multiple of the interval.  */
+      HOST_WIDE_INT rounded_size = size & -PROBE_INTERVAL;
+
+      /* Step 2: compute final value of the loop counter.  Use lea if
+	 possible.  */
+      rtx addr = plus_constant (Pmode, stack_pointer_rtx, -rounded_size);
+      rtx insn;
+      if (address_no_seg_operand (addr, Pmode))
+	insn = emit_insn (gen_rtx_SET (sr.reg, addr));
+      else
+	{
+	  emit_move_insn (sr.reg, GEN_INT (-rounded_size));
+	  insn = emit_insn (gen_rtx_SET (sr.reg,
+					 gen_rtx_PLUS (Pmode, sr.reg,
+						       stack_pointer_rtx)));
+	}
+      if (m->fs.cfa_reg == stack_pointer_rtx)
+	{
+	  add_reg_note (insn, REG_CFA_DEF_CFA,
+			plus_constant (Pmode, sr.reg,
+				       m->fs.cfa_offset + rounded_size));
+	  RTX_FRAME_RELATED_P (insn) = 1;
+        }
+
+      /* Step 3: the loop.  */
+      rtx size_rtx = GEN_INT (rounded_size);
+      insn = emit_insn (ix86_gen_adjust_stack_and_probe (sr.reg, sr.reg,
+							 size_rtx));
+      if (m->fs.cfa_reg == stack_pointer_rtx)
+	{
+	  m->fs.cfa_offset += rounded_size;
+	  add_reg_note (insn, REG_CFA_DEF_CFA,
+			plus_constant (Pmode, stack_pointer_rtx,
+				       m->fs.cfa_offset));
+	  RTX_FRAME_RELATED_P (insn) = 1;
+        }
+      m->fs.sp_offset += rounded_size;
+
+      /* Step 4: adjust SP if we cannot assert at compile-time that SIZE
+	 is equal to ROUNDED_SIZE.  */
+
+      if (size != rounded_size)
+	pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
+				   GEN_INT (rounded_size - size), -1,
+				   m->fs.cfa_reg == stack_pointer_rtx);
+      dump_stack_clash_frame_info (PROBE_LOOP, size != rounded_size);
+
+      release_scratch_register_on_entry (&sr);
+    }
+
+  /* Make sure nothing is scheduled before we are done.  */
+  emit_insn (gen_blockage ());
+}
+
 /* Emit code to adjust the stack pointer by SIZE bytes while probing it.  */
 
 static void
@@ -14619,15 +14753,22 @@  ix86_expand_prologue (void)
 
   /* The stack has already been decremented by the instruction calling us
      so probe if the size is non-negative to preserve the protection area.  */
-  if (allocate >= 0 && flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
+  if (allocate >= 0
+      && (flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+	  || flag_stack_check == STACK_CLASH_BUILTIN_STACK_CHECK))
     {
       /* We expect the registers to be saved when probes are used.  */
       gcc_assert (int_registers_saved);
 
       if (STACK_CHECK_MOVING_SP)
 	{
-	  if (!(crtl->is_leaf && !cfun->calls_alloca
-		&& allocate <= PROBE_INTERVAL))
+	  if (flag_stack_check == STACK_CLASH_BUILTIN_STACK_CHECK)
+	    {
+	      ix86_adjust_stack_and_probe_stack_clash (allocate);
+	      allocate = 0;
+	    }
+	  else if (!(crtl->is_leaf && !cfun->calls_alloca
+		     && allocate <= PROBE_INTERVAL))
 	    {
 	      ix86_adjust_stack_and_probe (allocate);
 	      allocate = 0;
diff --git a/gcc/testsuite/gcc.dg/stack-check-10.c b/gcc/testsuite/gcc.dg/stack-check-10.c
new file mode 100644
index 0000000..2d3b7b7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/stack-check-10.c
@@ -0,0 +1,41 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fstack-check=clash -fdump-rtl-pro_and_epilogue -fno-optimize-sibling-calls" } */
+/* { dg-require-effective-target stack_clash_protected } */
+
+int f (int *);
+
+int
+g (int a)
+{
+  return f (&a);
+}
+
+int f1 (void);
+int f2 (int);
+
+int
+f3 (void)
+{
+  return f2 (f1 ());
+}
+
+
+/* If we have caller implicit probes, then we should not need probes in either callee.
+   Else callees may need probes, particularly if non-leaf functions require a
+   frame/frame pointer.  */
+/* { dg-final { scan-rtl-dump-times "Stack clash no probe" 2 "pro_and_epilogue" { target caller_implicit_probes } } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash inline probe" 1 "pro_and_epilogue" { target { ! caller_implicit_probes } } } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash no probe" 1 "pro_and_epilogue" { target { ! caller_implicit_probes } } } } */
+
+/* Neither of these functions are a nonreturn function.  */
+/* { dg-final { scan-rtl-dump-times "Stack clash not noreturn" 2 "pro_and_epilogue" } } */
+
+/* If the callee realigns the stack or has a mandatory frame, then both functions
+   have a residual allocation.  Else just g() has a residual allocation.  */
+/* { dg-final { scan-rtl-dump-times "Stack clash residual allocation in prologue" 2 "pro_and_epilogue" } } */
+
+
+/* If the target has frame pointers for non-leafs, then both functions will
+   need a frame pointer.  Otherwise neither should.  */
+/* { dg-final { scan-rtl-dump-times "Stack clash no frame pointer needed" 2 "pro_and_epilogue" { target { ! frame_pointer_for_non_leaf } } } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash frame pointer needed" 2 "pro_and_epilogue" { target { frame_pointer_for_non_leaf } } } } */
diff --git a/gcc/testsuite/gcc.dg/stack-check-4.c b/gcc/testsuite/gcc.dg/stack-check-4.c
new file mode 100644
index 0000000..90eb000
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/stack-check-4.c
@@ -0,0 +1,42 @@ 
+/* On targets where the call instruction is an implicit probe of *sp, we
+   elide stack probes as long as the size of the local stack is less than
+   PROBE_INTERVAL.
+
+   But if the caller were to transform a tail call into a direct jump
+   we do not have that implicit probe.  This normally isn't a problem as
+   the caller must not have a local frame for that optimization to apply.
+
+   However, a sufficiently smart compiler could realize that the caller's
+   local stack need not be torn down and thus could transform a call into
+   a jump if the target is a noreturn function, even if the caller has
+   a local frame.
+
+   To guard against that, targets must emit a probe if the target function
+   is a noreturn function, even if they just allocate a small amount of
+   stack space.
+
+   Rather than try to parse RTL or assembly code, we instead require the
+   prologue code to emit information into the dump file that we can
+   scan for.   We scan for both the positive and negative cases.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -fstack-check=clash -fdump-rtl-pro_and_epilogue -fno-optimize-sibling-calls" } */
+/* { dg-require-effective-target stack_clash_protected } */
+
+extern void arf (char *);
+
+__attribute__ ((noreturn)) void foo1 ()
+{
+  char x[10];
+  while (1)
+    arf (x);
+}
+
+void foo2 ()
+{
+  char x[10];
+  arf (x);
+}
+/* { dg-final { scan-rtl-dump-times "Stack clash noreturn" 1 "pro_and_epilogue" } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash not noreturn" 1 "pro_and_epilogue" } } */
+
diff --git a/gcc/testsuite/gcc.dg/stack-check-5.c b/gcc/testsuite/gcc.dg/stack-check-5.c
new file mode 100644
index 0000000..66da339
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/stack-check-5.c
@@ -0,0 +1,73 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fstack-check=clash -fdump-rtl-pro_and_epilogue -fno-optimize-sibling-calls" } */
+/* { dg-require-effective-target stack_clash_protected } */
+
+extern void foo (char *);
+extern void bar (void);
+
+/* This function allocates no local stack and is a leaf.  It should have no
+   probes on any target and should not require a frame pointer.  */
+int
+f0 (int x, int y)
+{
+  asm volatile ("" : : : "memory");  
+  return x + y;
+}
+
+/* This function allocates no local stack, but is not a leaf.  Ideally it
+   should not need probing and no frame pointer.  */
+int
+f1 (int x, int y)
+{
+  asm volatile ("" : : : "memory");  
+  bar ();
+}
+
+/* This is a leaf with a small frame.  On targets with implicit probes in
+   the caller, this should not need probing.  On targets with no implicit
+   probes in the caller, it may require probes.  Ideally it should need no
+   frame pointer.  */
+void
+f2 (void)
+{
+  char buf[512];
+  asm volatile ("" : : "g" (&buf) : "memory");
+}
+
+/* This is a non-leaf with a small frame.  On targets with implicit probes in
+   the caller, this should not need probing.  On targets with no implicit
+   probes in the caller, it may require probes.  It should need no frame
+   pointer.  */
+void
+f3 (void)
+{
+  char buf[512];
+  foo (buf);
+}
+
+/* If we have caller implicit probes, then we should not need probes.
+   Else callees may need probes, particularly if non-leaf functions require a
+   frame/frame pointer.  */
+/* { dg-final { scan-rtl-dump-times "Stack clash no probe" 4 "pro_and_epilogue" { target caller_implicit_probes } } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash no probe" 2 "pro_and_epilogue" { target { ! caller_implicit_probes } } } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash inline probes " 2 "pro_and_epilogue" { target { ! caller_implicit_probes } } } } */
+
+/* None of these functions are marked with the noreturn attribute.  */
+/* { dg-final { scan-rtl-dump-times "Stack clash not noreturn" 4 "pro_and_epilogue" } } */
+
+/* Two functions are leafs, two are not.  Verify the target identified them
+   appropriately.  */
+/* { dg-final { scan-rtl-dump-times "Stack clash no frame pointer needed" 4 "pro_and_epilogue" { target { ! frame_pointer_for_non_leaf } } } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash no frame pointer needed" 2 "pro_and_epilogue" { target { frame_pointer_for_non_leaf } } } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash frame pointer needed" 2 "pro_and_epilogue" { target { frame_pointer_for_non_leaf } } } } */
+
+
+/* We have selected the size of the array in f2/f3 to be large enough
+   to not live in the red zone on targets that support it.
+
+   That allows simplification of this test considerably.
+   f1() should not require any allocations, thus no residuals.
+   All the rest of the functions require some kind of allocation,
+   either for the saved fp/rp or the array.  */
+/* { dg-final { scan-rtl-dump-times "Stack clash no residual allocation in prologue" 1 "pro_and_epilogue" } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash residual allocation in prologue" 3 "pro_and_epilogue" } } */
diff --git a/gcc/testsuite/gcc.dg/stack-check-6.c b/gcc/testsuite/gcc.dg/stack-check-6.c
new file mode 100644
index 0000000..9422e71
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/stack-check-6.c
@@ -0,0 +1,54 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fstack-check=clash -fdump-rtl-pro_and_epilogue -fno-optimize-sibling-calls" } */
+/* { dg-require-effective-target stack_clash_protected } */
+
+extern void foo (char *);
+extern void bar (void);
+
+
+/* This is a leaf with a frame that is large enough to require probing with
+   a residual allocation, but small enough to probe inline.  */
+void
+f4 (void)
+{
+  char buf[4096 + 512];
+  asm volatile ("" : : "g" (&buf) : "memory");
+}
+
+
+/* This is a non-leaf with a frame large enough to require probing and
+   a residual allocation, but small enough to probe inline.  */
+void
+f5 (void)
+{
+  char buf[4096 + 512];
+  foo (buf);
+}
+
+/* This is a leaf with a frame that is large enough to require probing with
+   a loop plus a residual allocation.  */
+void
+f6 (void)
+{
+  char buf[4096 * 10 + 512];
+  asm volatile ("" : : "g" (&buf) : "memory");
+}
+
+
+/* This is a non-leaf with a frame large enough to require probing with
+   a loop plus a residual allocation.  */
+void
+f7 (void)
+{
+  char buf[4096 * 10 + 512];
+  foo (buf);
+}
+
+/* { dg-final { scan-rtl-dump-times "Stack clash inline probes" 2 "pro_and_epilogue" } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash probe loop" 2 "pro_and_epilogue" } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash residual allocation in prologue" 4 "pro_and_epilogue" } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash not noreturn" 4 "pro_and_epilogue" } } */
+
+/* { dg-final { scan-rtl-dump-times "Stack clash no frame pointer needed" 4 "pro_and_epilogue" { target { ! frame_pointer_for_non_leaf } } } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash no frame pointer needed" 2 "pro_and_epilogue" { target { frame_pointer_for_non_leaf } } } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash frame pointer needed" 2 "pro_and_epilogue" { target { frame_pointer_for_non_leaf } } } } */
diff --git a/gcc/testsuite/gcc.dg/stack-check-7.c b/gcc/testsuite/gcc.dg/stack-check-7.c
new file mode 100644
index 0000000..d84eb24
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/stack-check-7.c
@@ -0,0 +1,36 @@ 
+/* { dg-do run } */
+/* { dg-options "-O2 -fstack-check=clash -fno-optimize-sibling-calls" } */
+/* { dg-require-effective-target stack_clash_protected } */
+
+/* For further testing, this can be run under valgrind where it's crashed
+   on aarch64 and ppc64le with -fstack-check=specific.  */
+
+
+__attribute__((noinline, noclone)) void
+foo (char *p)
+{
+  asm volatile ("" : : "r" (p) : "memory");
+}
+
+__attribute__((noinline, noclone)) void
+bar (void)
+{
+  char buf[131072];
+  foo (buf);
+}
+
+__attribute__((noinline, noclone)) void
+baz (void)
+{
+  char buf[12000];
+  foo (buf);
+}
+
+int
+main ()
+{
+  bar ();
+  baz ();
+  return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/stack-check-8.c b/gcc/testsuite/gcc.dg/stack-check-8.c
new file mode 100644
index 0000000..454a3dd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/stack-check-8.c
@@ -0,0 +1,139 @@ 
+/* { dg-do run } */
+/* { dg-options "-O2 -fstack-check=clash -Wno-psabi -fno-optimize-sibling-calls" } */
+/* { dg-additional-options "-mavx512f" { target i?86-*-* x86_64-*-* } } */
+/* { dg-require-effective-target stack_clash_protected } */
+
+typedef float V __attribute__((vector_size (32)));
+
+__attribute__((noinline, noclone)) void
+foo (char *p)
+{
+  asm volatile ("" : : "r" (p) : "memory");
+}
+
+__attribute__((noinline, noclone)) int
+f0 (int x, int y)
+{
+  asm volatile ("" : : : "memory");  
+  return x + y;
+}
+
+__attribute__((noinline, noclone)) void
+f1 (void)
+{
+  char buf[64];
+  foo (buf);
+}
+
+__attribute__((noinline, noclone)) void
+f2 (void)
+{
+  char buf[12000];
+  foo (buf);
+}
+
+__attribute__((noinline, noclone)) void
+f3 (void)
+{
+  char buf[131072];
+  foo (buf);
+}
+
+__attribute__((noinline, noclone)) void
+f4 (int x)
+{
+  char vla[x];
+  foo (vla);
+}
+
+__attribute__((noinline, noclone)) void
+f5 (int x)
+{
+  char buf[12000];
+  foo (buf);
+  {
+    char vla[x];
+    foo (vla);
+  }
+  {
+    char vla[x];
+    foo (vla);
+  }
+}
+
+V v;
+
+__attribute__((noinline, noclone)) int
+f6 (int x, int y, V a, V b, V c)
+{
+  asm volatile ("" : : : "memory");  
+  v = a + b + c;
+  return x + y;
+}
+
+__attribute__((noinline, noclone)) void
+f7 (V a, V b, V c)
+{
+  char buf[64];
+  foo (buf);
+  v = a + b + c;
+}
+
+__attribute__((noinline, noclone)) void
+f8 (V a, V b, V c)
+{
+  char buf[12000];
+  foo (buf);
+  v = a + b + c;
+}
+
+__attribute__((noinline, noclone)) void
+f9 (V a, V b, V c)
+{
+  char buf[131072];
+  foo (buf);
+  v = a + b + c;
+}
+
+__attribute__((noinline, noclone)) void
+f10 (int x, V a, V b, V c)
+{
+  char vla[x];
+  foo (vla);
+  v = a + b + c;
+}
+
+__attribute__((noinline, noclone)) void
+f11 (int x, V a, V b, V c)
+{
+  char buf[12000];
+  foo (buf);
+  v = a + b + c;
+  {
+    char vla[x];
+    foo (vla);
+  }
+  {
+    char vla[x];
+    foo (vla);
+  }
+}
+
+int
+main ()
+{
+  f0 (2, 3);
+  f1 ();
+  f2 ();
+  f3 ();
+  f4 (12000);
+  f5 (12000);
+  f6 (2, 3, v, v, v);
+  f7 (v, v, v);
+  f8 (v, v, v);
+  f9 (v, v, v);
+  f10 (12000, v, v, v);
+  f11 (12000, v, v, v);
+  return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/stack-check-9.c b/gcc/testsuite/gcc.dg/stack-check-9.c
new file mode 100644
index 0000000..5631ef1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/stack-check-9.c
@@ -0,0 +1,2022 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fstack-check=clash -fdump-rtl-pro_and_epilogue -fno-optimize-sibling-calls" } */
+/* { dg-require-effective-target stack_clash_protected } */
+
+double f1 (void);
+double f2 (double, double);
+
+double
+f3 (void)
+{
+  double d000 = f1 ();
+  double d001 = f1 ();
+  double d002 = f1 ();
+  double d003 = f1 ();
+  double d004 = f1 ();
+  double d005 = f1 ();
+  double d006 = f1 ();
+  double d007 = f1 ();
+  double d008 = f1 ();
+  double d009 = f1 ();
+  double d010 = f1 ();
+  double d011 = f1 ();
+  double d012 = f1 ();
+  double d013 = f1 ();
+  double d014 = f1 ();
+  double d015 = f1 ();
+  double d016 = f1 ();
+  double d017 = f1 ();
+  double d018 = f1 ();
+  double d019 = f1 ();
+  double d020 = f1 ();
+  double d021 = f1 ();
+  double d022 = f1 ();
+  double d023 = f1 ();
+  double d024 = f1 ();
+  double d025 = f1 ();
+  double d026 = f1 ();
+  double d027 = f1 ();
+  double d028 = f1 ();
+  double d029 = f1 ();
+  double d030 = f1 ();
+  double d031 = f1 ();
+  double d032 = f1 ();
+  double d033 = f1 ();
+  double d034 = f1 ();
+  double d035 = f1 ();
+  double d036 = f1 ();
+  double d037 = f1 ();
+  double d038 = f1 ();
+  double d039 = f1 ();
+  double d040 = f1 ();
+  double d041 = f1 ();
+  double d042 = f1 ();
+  double d043 = f1 ();
+  double d044 = f1 ();
+  double d045 = f1 ();
+  double d046 = f1 ();
+  double d047 = f1 ();
+  double d048 = f1 ();
+  double d049 = f1 ();
+  double d050 = f1 ();
+  double d051 = f1 ();
+  double d052 = f1 ();
+  double d053 = f1 ();
+  double d054 = f1 ();
+  double d055 = f1 ();
+  double d056 = f1 ();
+  double d057 = f1 ();
+  double d058 = f1 ();
+  double d059 = f1 ();
+  double d060 = f1 ();
+  double d061 = f1 ();
+  double d062 = f1 ();
+  double d063 = f1 ();
+  double d064 = f1 ();
+  double d065 = f1 ();
+  double d066 = f1 ();
+  double d067 = f1 ();
+  double d068 = f1 ();
+  double d069 = f1 ();
+  double d070 = f1 ();
+  double d071 = f1 ();
+  double d072 = f1 ();
+  double d073 = f1 ();
+  double d074 = f1 ();
+  double d075 = f1 ();
+  double d076 = f1 ();
+  double d077 = f1 ();
+  double d078 = f1 ();
+  double d079 = f1 ();
+  double d080 = f1 ();
+  double d081 = f1 ();
+  double d082 = f1 ();
+  double d083 = f1 ();
+  double d084 = f1 ();
+  double d085 = f1 ();
+  double d086 = f1 ();
+  double d087 = f1 ();
+  double d088 = f1 ();
+  double d089 = f1 ();
+  double d090 = f1 ();
+  double d091 = f1 ();
+  double d092 = f1 ();
+  double d093 = f1 ();
+  double d094 = f1 ();
+  double d095 = f1 ();
+  double d096 = f1 ();
+  double d097 = f1 ();
+  double d098 = f1 ();
+  double d099 = f1 ();
+  double d100 = f1 ();
+  double d101 = f1 ();
+  double d102 = f1 ();
+  double d103 = f1 ();
+  double d104 = f1 ();
+  double d105 = f1 ();
+  double d106 = f1 ();
+  double d107 = f1 ();
+  double d108 = f1 ();
+  double d109 = f1 ();
+  double d110 = f1 ();
+  double d111 = f1 ();
+  double d112 = f1 ();
+  double d113 = f1 ();
+  double d114 = f1 ();
+  double d115 = f1 ();
+  double d116 = f1 ();
+  double d117 = f1 ();
+  double d118 = f1 ();
+  double d119 = f1 ();
+  double d120 = f1 ();
+  double d121 = f1 ();
+  double d122 = f1 ();
+  double d123 = f1 ();
+  double d124 = f1 ();
+  double d125 = f1 ();
+  double d126 = f1 ();
+  double d127 = f1 ();
+  double d128 = f1 ();
+  double d129 = f1 ();
+  double d130 = f1 ();
+  double d131 = f1 ();
+  double d132 = f1 ();
+  double d133 = f1 ();
+  double d134 = f1 ();
+  double d135 = f1 ();
+  double d136 = f1 ();
+  double d137 = f1 ();
+  double d138 = f1 ();
+  double d139 = f1 ();
+  double d140 = f1 ();
+  double d141 = f1 ();
+  double d142 = f1 ();
+  double d143 = f1 ();
+  double d144 = f1 ();
+  double d145 = f1 ();
+  double d146 = f1 ();
+  double d147 = f1 ();
+  double d148 = f1 ();
+  double d149 = f1 ();
+  double d150 = f1 ();
+  double d151 = f1 ();
+  double d152 = f1 ();
+  double d153 = f1 ();
+  double d154 = f1 ();
+  double d155 = f1 ();
+  double d156 = f1 ();
+  double d157 = f1 ();
+  double d158 = f1 ();
+  double d159 = f1 ();
+  double d160 = f1 ();
+  double d161 = f1 ();
+  double d162 = f1 ();
+  double d163 = f1 ();
+  double d164 = f1 ();
+  double d165 = f1 ();
+  double d166 = f1 ();
+  double d167 = f1 ();
+  double d168 = f1 ();
+  double d169 = f1 ();
+  double d170 = f1 ();
+  double d171 = f1 ();
+  double d172 = f1 ();
+  double d173 = f1 ();
+  double d174 = f1 ();
+  double d175 = f1 ();
+  double d176 = f1 ();
+  double d177 = f1 ();
+  double d178 = f1 ();
+  double d179 = f1 ();
+  double d180 = f1 ();
+  double d181 = f1 ();
+  double d182 = f1 ();
+  double d183 = f1 ();
+  double d184 = f1 ();
+  double d185 = f1 ();
+  double d186 = f1 ();
+  double d187 = f1 ();
+  double d188 = f1 ();
+  double d189 = f1 ();
+  double d190 = f1 ();
+  double d191 = f1 ();
+  double d192 = f1 ();
+  double d193 = f1 ();
+  double d194 = f1 ();
+  double d195 = f1 ();
+  double d196 = f1 ();
+  double d197 = f1 ();
+  double d198 = f1 ();
+  double d199 = f1 ();
+  double d200 = f1 ();
+  double d201 = f1 ();
+  double d202 = f1 ();
+  double d203 = f1 ();
+  double d204 = f1 ();
+  double d205 = f1 ();
+  double d206 = f1 ();
+  double d207 = f1 ();
+  double d208 = f1 ();
+  double d209 = f1 ();
+  double d210 = f1 ();
+  double d211 = f1 ();
+  double d212 = f1 ();
+  double d213 = f1 ();
+  double d214 = f1 ();
+  double d215 = f1 ();
+  double d216 = f1 ();
+  double d217 = f1 ();
+  double d218 = f1 ();
+  double d219 = f1 ();
+  double d220 = f1 ();
+  double d221 = f1 ();
+  double d222 = f1 ();
+  double d223 = f1 ();
+  double d224 = f1 ();
+  double d225 = f1 ();
+  double d226 = f1 ();
+  double d227 = f1 ();
+  double d228 = f1 ();
+  double d229 = f1 ();
+  double d230 = f1 ();
+  double d231 = f1 ();
+  double d232 = f1 ();
+  double d233 = f1 ();
+  double d234 = f1 ();
+  double d235 = f1 ();
+  double d236 = f1 ();
+  double d237 = f1 ();
+  double d238 = f1 ();
+  double d239 = f1 ();
+  double d240 = f1 ();
+  double d241 = f1 ();
+  double d242 = f1 ();
+  double d243 = f1 ();
+  double d244 = f1 ();
+  double d245 = f1 ();
+  double d246 = f1 ();
+  double d247 = f1 ();
+  double d248 = f1 ();
+  double d249 = f1 ();
+  double d250 = f1 ();
+  double d251 = f1 ();
+  double d252 = f1 ();
+  double d253 = f1 ();
+  double d254 = f1 ();
+  double d255 = f1 ();
+  double d256 = f1 ();
+  double d257 = f1 ();
+  double d258 = f1 ();
+  double d259 = f1 ();
+  double d260 = f1 ();
+  double d261 = f1 ();
+  double d262 = f1 ();
+  double d263 = f1 ();
+  double d264 = f1 ();
+  double d265 = f1 ();
+  double d266 = f1 ();
+  double d267 = f1 ();
+  double d268 = f1 ();
+  double d269 = f1 ();
+  double d270 = f1 ();
+  double d271 = f1 ();
+  double d272 = f1 ();
+  double d273 = f1 ();
+  double d274 = f1 ();
+  double d275 = f1 ();
+  double d276 = f1 ();
+  double d277 = f1 ();
+  double d278 = f1 ();
+  double d279 = f1 ();
+  double d280 = f1 ();
+  double d281 = f1 ();
+  double d282 = f1 ();
+  double d283 = f1 ();
+  double d284 = f1 ();
+  double d285 = f1 ();
+  double d286 = f1 ();
+  double d287 = f1 ();
+  double d288 = f1 ();
+  double d289 = f1 ();
+  double d290 = f1 ();
+  double d291 = f1 ();
+  double d292 = f1 ();
+  double d293 = f1 ();
+  double d294 = f1 ();
+  double d295 = f1 ();
+  double d296 = f1 ();
+  double d297 = f1 ();
+  double d298 = f1 ();
+  double d299 = f1 ();
+  double d300 = f1 ();
+  double d301 = f1 ();
+  double d302 = f1 ();
+  double d303 = f1 ();
+  double d304 = f1 ();
+  double d305 = f1 ();
+  double d306 = f1 ();
+  double d307 = f1 ();
+  double d308 = f1 ();
+  double d309 = f1 ();
+  double d310 = f1 ();
+  double d311 = f1 ();
+  double d312 = f1 ();
+  double d313 = f1 ();
+  double d314 = f1 ();
+  double d315 = f1 ();
+  double d316 = f1 ();
+  double d317 = f1 ();
+  double d318 = f1 ();
+  double d319 = f1 ();
+  double d320 = f1 ();
+  double d321 = f1 ();
+  double d322 = f1 ();
+  double d323 = f1 ();
+  double d324 = f1 ();
+  double d325 = f1 ();
+  double d326 = f1 ();
+  double d327 = f1 ();
+  double d328 = f1 ();
+  double d329 = f1 ();
+  double d330 = f1 ();
+  double d331 = f1 ();
+  double d332 = f1 ();
+  double d333 = f1 ();
+  double d334 = f1 ();
+  double d335 = f1 ();
+  double d336 = f1 ();
+  double d337 = f1 ();
+  double d338 = f1 ();
+  double d339 = f1 ();
+  double d340 = f1 ();
+  double d341 = f1 ();
+  double d342 = f1 ();
+  double d343 = f1 ();
+  double d344 = f1 ();
+  double d345 = f1 ();
+  double d346 = f1 ();
+  double d347 = f1 ();
+  double d348 = f1 ();
+  double d349 = f1 ();
+  double d350 = f1 ();
+  double d351 = f1 ();
+  double d352 = f1 ();
+  double d353 = f1 ();
+  double d354 = f1 ();
+  double d355 = f1 ();
+  double d356 = f1 ();
+  double d357 = f1 ();
+  double d358 = f1 ();
+  double d359 = f1 ();
+  double d360 = f1 ();
+  double d361 = f1 ();
+  double d362 = f1 ();
+  double d363 = f1 ();
+  double d364 = f1 ();
+  double d365 = f1 ();
+  double d366 = f1 ();
+  double d367 = f1 ();
+  double d368 = f1 ();
+  double d369 = f1 ();
+  double d370 = f1 ();
+  double d371 = f1 ();
+  double d372 = f1 ();
+  double d373 = f1 ();
+  double d374 = f1 ();
+  double d375 = f1 ();
+  double d376 = f1 ();
+  double d377 = f1 ();
+  double d378 = f1 ();
+  double d379 = f1 ();
+  double d380 = f1 ();
+  double d381 = f1 ();
+  double d382 = f1 ();
+  double d383 = f1 ();
+  double d384 = f1 ();
+  double d385 = f1 ();
+  double d386 = f1 ();
+  double d387 = f1 ();
+  double d388 = f1 ();
+  double d389 = f1 ();
+  double d390 = f1 ();
+  double d391 = f1 ();
+  double d392 = f1 ();
+  double d393 = f1 ();
+  double d394 = f1 ();
+  double d395 = f1 ();
+  double d396 = f1 ();
+  double d397 = f1 ();
+  double d398 = f1 ();
+  double d399 = f1 ();
+  double d400 = f1 ();
+  double d401 = f1 ();
+  double d402 = f1 ();
+  double d403 = f1 ();
+  double d404 = f1 ();
+  double d405 = f1 ();
+  double d406 = f1 ();
+  double d407 = f1 ();
+  double d408 = f1 ();
+  double d409 = f1 ();
+  double d410 = f1 ();
+  double d411 = f1 ();
+  double d412 = f1 ();
+  double d413 = f1 ();
+  double d414 = f1 ();
+  double d415 = f1 ();
+  double d416 = f1 ();
+  double d417 = f1 ();
+  double d418 = f1 ();
+  double d419 = f1 ();
+  double d420 = f1 ();
+  double d421 = f1 ();
+  double d422 = f1 ();
+  double d423 = f1 ();
+  double d424 = f1 ();
+  double d425 = f1 ();
+  double d426 = f1 ();
+  double d427 = f1 ();
+  double d428 = f1 ();
+  double d429 = f1 ();
+  double d430 = f1 ();
+  double d431 = f1 ();
+  double d432 = f1 ();
+  double d433 = f1 ();
+  double d434 = f1 ();
+  double d435 = f1 ();
+  double d436 = f1 ();
+  double d437 = f1 ();
+  double d438 = f1 ();
+  double d439 = f1 ();
+  double d440 = f1 ();
+  double d441 = f1 ();
+  double d442 = f1 ();
+  double d443 = f1 ();
+  double d444 = f1 ();
+  double d445 = f1 ();
+  double d446 = f1 ();
+  double d447 = f1 ();
+  double d448 = f1 ();
+  double d449 = f1 ();
+  double d450 = f1 ();
+  double d451 = f1 ();
+  double d452 = f1 ();
+  double d453 = f1 ();
+  double d454 = f1 ();
+  double d455 = f1 ();
+  double d456 = f1 ();
+  double d457 = f1 ();
+  double d458 = f1 ();
+  double d459 = f1 ();
+  double d460 = f1 ();
+  double d461 = f1 ();
+  double d462 = f1 ();
+  double d463 = f1 ();
+  double d464 = f1 ();
+  double d465 = f1 ();
+  double d466 = f1 ();
+  double d467 = f1 ();
+  double d468 = f1 ();
+  double d469 = f1 ();
+  double d470 = f1 ();
+  double d471 = f1 ();
+  double d472 = f1 ();
+  double d473 = f1 ();
+  double d474 = f1 ();
+  double d475 = f1 ();
+  double d476 = f1 ();
+  double d477 = f1 ();
+  double d478 = f1 ();
+  double d479 = f1 ();
+  double d480 = f1 ();
+  double d481 = f1 ();
+  double d482 = f1 ();
+  double d483 = f1 ();
+  double d484 = f1 ();
+  double d485 = f1 ();
+  double d486 = f1 ();
+  double d487 = f1 ();
+  double d488 = f1 ();
+  double d489 = f1 ();
+  double d490 = f1 ();
+  double d491 = f1 ();
+  double d492 = f1 ();
+  double d493 = f1 ();
+  double d494 = f1 ();
+  double d495 = f1 ();
+  double d496 = f1 ();
+  double d497 = f1 ();
+  double d498 = f1 ();
+  double d499 = f1 ();
+  double d500 = f1 ();
+  double d501 = f1 ();
+  double d502 = f1 ();
+  double d503 = f1 ();
+  double d504 = f1 ();
+  double d505 = f1 ();
+  double d506 = f1 ();
+  double d507 = f1 ();
+  double d508 = f1 ();
+  double d509 = f1 ();
+  double d510 = f1 ();
+  double d511 = f1 ();
+  double d512 = f1 ();
+  double d513 = f1 ();
+  double d514 = f1 ();
+  double d515 = f1 ();
+  double d516 = f1 ();
+  double d517 = f1 ();
+  double d518 = f1 ();
+  double d519 = f1 ();
+  double d520 = f1 ();
+  double d521 = f1 ();
+  double d522 = f1 ();
+  double d523 = f1 ();
+  double d524 = f1 ();
+  double d525 = f1 ();
+  double d526 = f1 ();
+  double d527 = f1 ();
+  double d528 = f1 ();
+  double d529 = f1 ();
+  double d530 = f1 ();
+  double d531 = f1 ();
+  double d532 = f1 ();
+  double d533 = f1 ();
+  double d534 = f1 ();
+  double d535 = f1 ();
+  double d536 = f1 ();
+  double d537 = f1 ();
+  double d538 = f1 ();
+  double d539 = f1 ();
+  double d540 = f1 ();
+  double d541 = f1 ();
+  double d542 = f1 ();
+  double d543 = f1 ();
+  double d544 = f1 ();
+  double d545 = f1 ();
+  double d546 = f1 ();
+  double d547 = f1 ();
+  double d548 = f1 ();
+  double d549 = f1 ();
+  double d550 = f1 ();
+  double d551 = f1 ();
+  double d552 = f1 ();
+  double d553 = f1 ();
+  double d554 = f1 ();
+  double d555 = f1 ();
+  double d556 = f1 ();
+  double d557 = f1 ();
+  double d558 = f1 ();
+  double d559 = f1 ();
+  double d560 = f1 ();
+  double d561 = f1 ();
+  double d562 = f1 ();
+  double d563 = f1 ();
+  double d564 = f1 ();
+  double d565 = f1 ();
+  double d566 = f1 ();
+  double d567 = f1 ();
+  double d568 = f1 ();
+  double d569 = f1 ();
+  double d570 = f1 ();
+  double d571 = f1 ();
+  double d572 = f1 ();
+  double d573 = f1 ();
+  double d574 = f1 ();
+  double d575 = f1 ();
+  double d576 = f1 ();
+  double d577 = f1 ();
+  double d578 = f1 ();
+  double d579 = f1 ();
+  double d580 = f1 ();
+  double d581 = f1 ();
+  double d582 = f1 ();
+  double d583 = f1 ();
+  double d584 = f1 ();
+  double d585 = f1 ();
+  double d586 = f1 ();
+  double d587 = f1 ();
+  double d588 = f1 ();
+  double d589 = f1 ();
+  double d590 = f1 ();
+  double d591 = f1 ();
+  double d592 = f1 ();
+  double d593 = f1 ();
+  double d594 = f1 ();
+  double d595 = f1 ();
+  double d596 = f1 ();
+  double d597 = f1 ();
+  double d598 = f1 ();
+  double d599 = f1 ();
+  double d600 = f1 ();
+  double d601 = f1 ();
+  double d602 = f1 ();
+  double d603 = f1 ();
+  double d604 = f1 ();
+  double d605 = f1 ();
+  double d606 = f1 ();
+  double d607 = f1 ();
+  double d608 = f1 ();
+  double d609 = f1 ();
+  double d610 = f1 ();
+  double d611 = f1 ();
+  double d612 = f1 ();
+  double d613 = f1 ();
+  double d614 = f1 ();
+  double d615 = f1 ();
+  double d616 = f1 ();
+  double d617 = f1 ();
+  double d618 = f1 ();
+  double d619 = f1 ();
+  double d620 = f1 ();
+  double d621 = f1 ();
+  double d622 = f1 ();
+  double d623 = f1 ();
+  double d624 = f1 ();
+  double d625 = f1 ();
+  double d626 = f1 ();
+  double d627 = f1 ();
+  double d628 = f1 ();
+  double d629 = f1 ();
+  double d630 = f1 ();
+  double d631 = f1 ();
+  double d632 = f1 ();
+  double d633 = f1 ();
+  double d634 = f1 ();
+  double d635 = f1 ();
+  double d636 = f1 ();
+  double d637 = f1 ();
+  double d638 = f1 ();
+  double d639 = f1 ();
+  double d640 = f1 ();
+  double d641 = f1 ();
+  double d642 = f1 ();
+  double d643 = f1 ();
+  double d644 = f1 ();
+  double d645 = f1 ();
+  double d646 = f1 ();
+  double d647 = f1 ();
+  double d648 = f1 ();
+  double d649 = f1 ();
+  double d650 = f1 ();
+  double d651 = f1 ();
+  double d652 = f1 ();
+  double d653 = f1 ();
+  double d654 = f1 ();
+  double d655 = f1 ();
+  double d656 = f1 ();
+  double d657 = f1 ();
+  double d658 = f1 ();
+  double d659 = f1 ();
+  double d660 = f1 ();
+  double d661 = f1 ();
+  double d662 = f1 ();
+  double d663 = f1 ();
+  double d664 = f1 ();
+  double d665 = f1 ();
+  double d666 = f1 ();
+  double d667 = f1 ();
+  double d668 = f1 ();
+  double d669 = f1 ();
+  double d670 = f1 ();
+  double d671 = f1 ();
+  double d672 = f1 ();
+  double d673 = f1 ();
+  double d674 = f1 ();
+  double d675 = f1 ();
+  double d676 = f1 ();
+  double d677 = f1 ();
+  double d678 = f1 ();
+  double d679 = f1 ();
+  double d680 = f1 ();
+  double d681 = f1 ();
+  double d682 = f1 ();
+  double d683 = f1 ();
+  double d684 = f1 ();
+  double d685 = f1 ();
+  double d686 = f1 ();
+  double d687 = f1 ();
+  double d688 = f1 ();
+  double d689 = f1 ();
+  double d690 = f1 ();
+  double d691 = f1 ();
+  double d692 = f1 ();
+  double d693 = f1 ();
+  double d694 = f1 ();
+  double d695 = f1 ();
+  double d696 = f1 ();
+  double d697 = f1 ();
+  double d698 = f1 ();
+  double d699 = f1 ();
+  double d700 = f1 ();
+  double d701 = f1 ();
+  double d702 = f1 ();
+  double d703 = f1 ();
+  double d704 = f1 ();
+  double d705 = f1 ();
+  double d706 = f1 ();
+  double d707 = f1 ();
+  double d708 = f1 ();
+  double d709 = f1 ();
+  double d710 = f1 ();
+  double d711 = f1 ();
+  double d712 = f1 ();
+  double d713 = f1 ();
+  double d714 = f1 ();
+  double d715 = f1 ();
+  double d716 = f1 ();
+  double d717 = f1 ();
+  double d718 = f1 ();
+  double d719 = f1 ();
+  double d720 = f1 ();
+  double d721 = f1 ();
+  double d722 = f1 ();
+  double d723 = f1 ();
+  double d724 = f1 ();
+  double d725 = f1 ();
+  double d726 = f1 ();
+  double d727 = f1 ();
+  double d728 = f1 ();
+  double d729 = f1 ();
+  double d730 = f1 ();
+  double d731 = f1 ();
+  double d732 = f1 ();
+  double d733 = f1 ();
+  double d734 = f1 ();
+  double d735 = f1 ();
+  double d736 = f1 ();
+  double d737 = f1 ();
+  double d738 = f1 ();
+  double d739 = f1 ();
+  double d740 = f1 ();
+  double d741 = f1 ();
+  double d742 = f1 ();
+  double d743 = f1 ();
+  double d744 = f1 ();
+  double d745 = f1 ();
+  double d746 = f1 ();
+  double d747 = f1 ();
+  double d748 = f1 ();
+  double d749 = f1 ();
+  double d750 = f1 ();
+  double d751 = f1 ();
+  double d752 = f1 ();
+  double d753 = f1 ();
+  double d754 = f1 ();
+  double d755 = f1 ();
+  double d756 = f1 ();
+  double d757 = f1 ();
+  double d758 = f1 ();
+  double d759 = f1 ();
+  double d760 = f1 ();
+  double d761 = f1 ();
+  double d762 = f1 ();
+  double d763 = f1 ();
+  double d764 = f1 ();
+  double d765 = f1 ();
+  double d766 = f1 ();
+  double d767 = f1 ();
+  double d768 = f1 ();
+  double d769 = f1 ();
+  double d770 = f1 ();
+  double d771 = f1 ();
+  double d772 = f1 ();
+  double d773 = f1 ();
+  double d774 = f1 ();
+  double d775 = f1 ();
+  double d776 = f1 ();
+  double d777 = f1 ();
+  double d778 = f1 ();
+  double d779 = f1 ();
+  double d780 = f1 ();
+  double d781 = f1 ();
+  double d782 = f1 ();
+  double d783 = f1 ();
+  double d784 = f1 ();
+  double d785 = f1 ();
+  double d786 = f1 ();
+  double d787 = f1 ();
+  double d788 = f1 ();
+  double d789 = f1 ();
+  double d790 = f1 ();
+  double d791 = f1 ();
+  double d792 = f1 ();
+  double d793 = f1 ();
+  double d794 = f1 ();
+  double d795 = f1 ();
+  double d796 = f1 ();
+  double d797 = f1 ();
+  double d798 = f1 ();
+  double d799 = f1 ();
+  double d800 = f1 ();
+  double d801 = f1 ();
+  double d802 = f1 ();
+  double d803 = f1 ();
+  double d804 = f1 ();
+  double d805 = f1 ();
+  double d806 = f1 ();
+  double d807 = f1 ();
+  double d808 = f1 ();
+  double d809 = f1 ();
+  double d810 = f1 ();
+  double d811 = f1 ();
+  double d812 = f1 ();
+  double d813 = f1 ();
+  double d814 = f1 ();
+  double d815 = f1 ();
+  double d816 = f1 ();
+  double d817 = f1 ();
+  double d818 = f1 ();
+  double d819 = f1 ();
+  double d820 = f1 ();
+  double d821 = f1 ();
+  double d822 = f1 ();
+  double d823 = f1 ();
+  double d824 = f1 ();
+  double d825 = f1 ();
+  double d826 = f1 ();
+  double d827 = f1 ();
+  double d828 = f1 ();
+  double d829 = f1 ();
+  double d830 = f1 ();
+  double d831 = f1 ();
+  double d832 = f1 ();
+  double d833 = f1 ();
+  double d834 = f1 ();
+  double d835 = f1 ();
+  double d836 = f1 ();
+  double d837 = f1 ();
+  double d838 = f1 ();
+  double d839 = f1 ();
+  double d840 = f1 ();
+  double d841 = f1 ();
+  double d842 = f1 ();
+  double d843 = f1 ();
+  double d844 = f1 ();
+  double d845 = f1 ();
+  double d846 = f1 ();
+  double d847 = f1 ();
+  double d848 = f1 ();
+  double d849 = f1 ();
+  double d850 = f1 ();
+  double d851 = f1 ();
+  double d852 = f1 ();
+  double d853 = f1 ();
+  double d854 = f1 ();
+  double d855 = f1 ();
+  double d856 = f1 ();
+  double d857 = f1 ();
+  double d858 = f1 ();
+  double d859 = f1 ();
+  double d860 = f1 ();
+  double d861 = f1 ();
+  double d862 = f1 ();
+  double d863 = f1 ();
+  double d864 = f1 ();
+  double d865 = f1 ();
+  double d866 = f1 ();
+  double d867 = f1 ();
+  double d868 = f1 ();
+  double d869 = f1 ();
+  double d870 = f1 ();
+  double d871 = f1 ();
+  double d872 = f1 ();
+  double d873 = f1 ();
+  double d874 = f1 ();
+  double d875 = f1 ();
+  double d876 = f1 ();
+  double d877 = f1 ();
+  double d878 = f1 ();
+  double d879 = f1 ();
+  double d880 = f1 ();
+  double d881 = f1 ();
+  double d882 = f1 ();
+  double d883 = f1 ();
+  double d884 = f1 ();
+  double d885 = f1 ();
+  double d886 = f1 ();
+  double d887 = f1 ();
+  double d888 = f1 ();
+  double d889 = f1 ();
+  double d890 = f1 ();
+  double d891 = f1 ();
+  double d892 = f1 ();
+  double d893 = f1 ();
+  double d894 = f1 ();
+  double d895 = f1 ();
+  double d896 = f1 ();
+  double d897 = f1 ();
+  double d898 = f1 ();
+  double d899 = f1 ();
+  double d900 = f1 ();
+  double d901 = f1 ();
+  double d902 = f1 ();
+  double d903 = f1 ();
+  double d904 = f1 ();
+  double d905 = f1 ();
+  double d906 = f1 ();
+  double d907 = f1 ();
+  double d908 = f1 ();
+  double d909 = f1 ();
+  double d910 = f1 ();
+  double d911 = f1 ();
+  double d912 = f1 ();
+  double d913 = f1 ();
+  double d914 = f1 ();
+  double d915 = f1 ();
+  double d916 = f1 ();
+  double d917 = f1 ();
+  double d918 = f1 ();
+  double d919 = f1 ();
+  double d920 = f1 ();
+  double d921 = f1 ();
+  double d922 = f1 ();
+  double d923 = f1 ();
+  double d924 = f1 ();
+  double d925 = f1 ();
+  double d926 = f1 ();
+  double d927 = f1 ();
+  double d928 = f1 ();
+  double d929 = f1 ();
+  double d930 = f1 ();
+  double d931 = f1 ();
+  double d932 = f1 ();
+  double d933 = f1 ();
+  double d934 = f1 ();
+  double d935 = f1 ();
+  double d936 = f1 ();
+  double d937 = f1 ();
+  double d938 = f1 ();
+  double d939 = f1 ();
+  double d940 = f1 ();
+  double d941 = f1 ();
+  double d942 = f1 ();
+  double d943 = f1 ();
+  double d944 = f1 ();
+  double d945 = f1 ();
+  double d946 = f1 ();
+  double d947 = f1 ();
+  double d948 = f1 ();
+  double d949 = f1 ();
+  double d950 = f1 ();
+  double d951 = f1 ();
+  double d952 = f1 ();
+  double d953 = f1 ();
+  double d954 = f1 ();
+  double d955 = f1 ();
+  double d956 = f1 ();
+  double d957 = f1 ();
+  double d958 = f1 ();
+  double d959 = f1 ();
+  double d960 = f1 ();
+  double d961 = f1 ();
+  double d962 = f1 ();
+  double d963 = f1 ();
+  double d964 = f1 ();
+  double d965 = f1 ();
+  double d966 = f1 ();
+  double d967 = f1 ();
+  double d968 = f1 ();
+  double d969 = f1 ();
+  double d970 = f1 ();
+  double d971 = f1 ();
+  double d972 = f1 ();
+  double d973 = f1 ();
+  double d974 = f1 ();
+  double d975 = f1 ();
+  double d976 = f1 ();
+  double d977 = f1 ();
+  double d978 = f1 ();
+  double d979 = f1 ();
+  double d980 = f1 ();
+  double d981 = f1 ();
+  double d982 = f1 ();
+  double d983 = f1 ();
+  double d984 = f1 ();
+  double d985 = f1 ();
+  double d986 = f1 ();
+  double d987 = f1 ();
+  double d988 = f1 ();
+  double d989 = f1 ();
+  double d990 = f1 ();
+  double d991 = f1 ();
+  double d992 = f1 ();
+  double d993 = f1 ();
+  double d994 = f1 ();
+  double d995 = f1 ();
+  double d996 = f1 ();
+  double d997 = f1 ();
+  double d998 = f1 ();
+  double d999 = f1 ();
+
+  double x = 0;
+  x = f2 (x, d000);
+  x = f2 (x, d001);
+  x = f2 (x, d002);
+  x = f2 (x, d003);
+  x = f2 (x, d004);
+  x = f2 (x, d005);
+  x = f2 (x, d006);
+  x = f2 (x, d007);
+  x = f2 (x, d008);
+  x = f2 (x, d009);
+  x = f2 (x, d010);
+  x = f2 (x, d011);
+  x = f2 (x, d012);
+  x = f2 (x, d013);
+  x = f2 (x, d014);
+  x = f2 (x, d015);
+  x = f2 (x, d016);
+  x = f2 (x, d017);
+  x = f2 (x, d018);
+  x = f2 (x, d019);
+  x = f2 (x, d020);
+  x = f2 (x, d021);
+  x = f2 (x, d022);
+  x = f2 (x, d023);
+  x = f2 (x, d024);
+  x = f2 (x, d025);
+  x = f2 (x, d026);
+  x = f2 (x, d027);
+  x = f2 (x, d028);
+  x = f2 (x, d029);
+  x = f2 (x, d030);
+  x = f2 (x, d031);
+  x = f2 (x, d032);
+  x = f2 (x, d033);
+  x = f2 (x, d034);
+  x = f2 (x, d035);
+  x = f2 (x, d036);
+  x = f2 (x, d037);
+  x = f2 (x, d038);
+  x = f2 (x, d039);
+  x = f2 (x, d040);
+  x = f2 (x, d041);
+  x = f2 (x, d042);
+  x = f2 (x, d043);
+  x = f2 (x, d044);
+  x = f2 (x, d045);
+  x = f2 (x, d046);
+  x = f2 (x, d047);
+  x = f2 (x, d048);
+  x = f2 (x, d049);
+  x = f2 (x, d050);
+  x = f2 (x, d051);
+  x = f2 (x, d052);
+  x = f2 (x, d053);
+  x = f2 (x, d054);
+  x = f2 (x, d055);
+  x = f2 (x, d056);
+  x = f2 (x, d057);
+  x = f2 (x, d058);
+  x = f2 (x, d059);
+  x = f2 (x, d060);
+  x = f2 (x, d061);
+  x = f2 (x, d062);
+  x = f2 (x, d063);
+  x = f2 (x, d064);
+  x = f2 (x, d065);
+  x = f2 (x, d066);
+  x = f2 (x, d067);
+  x = f2 (x, d068);
+  x = f2 (x, d069);
+  x = f2 (x, d070);
+  x = f2 (x, d071);
+  x = f2 (x, d072);
+  x = f2 (x, d073);
+  x = f2 (x, d074);
+  x = f2 (x, d075);
+  x = f2 (x, d076);
+  x = f2 (x, d077);
+  x = f2 (x, d078);
+  x = f2 (x, d079);
+  x = f2 (x, d080);
+  x = f2 (x, d081);
+  x = f2 (x, d082);
+  x = f2 (x, d083);
+  x = f2 (x, d084);
+  x = f2 (x, d085);
+  x = f2 (x, d086);
+  x = f2 (x, d087);
+  x = f2 (x, d088);
+  x = f2 (x, d089);
+  x = f2 (x, d090);
+  x = f2 (x, d091);
+  x = f2 (x, d092);
+  x = f2 (x, d093);
+  x = f2 (x, d094);
+  x = f2 (x, d095);
+  x = f2 (x, d096);
+  x = f2 (x, d097);
+  x = f2 (x, d098);
+  x = f2 (x, d099);
+  x = f2 (x, d100);
+  x = f2 (x, d101);
+  x = f2 (x, d102);
+  x = f2 (x, d103);
+  x = f2 (x, d104);
+  x = f2 (x, d105);
+  x = f2 (x, d106);
+  x = f2 (x, d107);
+  x = f2 (x, d108);
+  x = f2 (x, d109);
+  x = f2 (x, d110);
+  x = f2 (x, d111);
+  x = f2 (x, d112);
+  x = f2 (x, d113);
+  x = f2 (x, d114);
+  x = f2 (x, d115);
+  x = f2 (x, d116);
+  x = f2 (x, d117);
+  x = f2 (x, d118);
+  x = f2 (x, d119);
+  x = f2 (x, d120);
+  x = f2 (x, d121);
+  x = f2 (x, d122);
+  x = f2 (x, d123);
+  x = f2 (x, d124);
+  x = f2 (x, d125);
+  x = f2 (x, d126);
+  x = f2 (x, d127);
+  x = f2 (x, d128);
+  x = f2 (x, d129);
+  x = f2 (x, d130);
+  x = f2 (x, d131);
+  x = f2 (x, d132);
+  x = f2 (x, d133);
+  x = f2 (x, d134);
+  x = f2 (x, d135);
+  x = f2 (x, d136);
+  x = f2 (x, d137);
+  x = f2 (x, d138);
+  x = f2 (x, d139);
+  x = f2 (x, d140);
+  x = f2 (x, d141);
+  x = f2 (x, d142);
+  x = f2 (x, d143);
+  x = f2 (x, d144);
+  x = f2 (x, d145);
+  x = f2 (x, d146);
+  x = f2 (x, d147);
+  x = f2 (x, d148);
+  x = f2 (x, d149);
+  x = f2 (x, d150);
+  x = f2 (x, d151);
+  x = f2 (x, d152);
+  x = f2 (x, d153);
+  x = f2 (x, d154);
+  x = f2 (x, d155);
+  x = f2 (x, d156);
+  x = f2 (x, d157);
+  x = f2 (x, d158);
+  x = f2 (x, d159);
+  x = f2 (x, d160);
+  x = f2 (x, d161);
+  x = f2 (x, d162);
+  x = f2 (x, d163);
+  x = f2 (x, d164);
+  x = f2 (x, d165);
+  x = f2 (x, d166);
+  x = f2 (x, d167);
+  x = f2 (x, d168);
+  x = f2 (x, d169);
+  x = f2 (x, d170);
+  x = f2 (x, d171);
+  x = f2 (x, d172);
+  x = f2 (x, d173);
+  x = f2 (x, d174);
+  x = f2 (x, d175);
+  x = f2 (x, d176);
+  x = f2 (x, d177);
+  x = f2 (x, d178);
+  x = f2 (x, d179);
+  x = f2 (x, d180);
+  x = f2 (x, d181);
+  x = f2 (x, d182);
+  x = f2 (x, d183);
+  x = f2 (x, d184);
+  x = f2 (x, d185);
+  x = f2 (x, d186);
+  x = f2 (x, d187);
+  x = f2 (x, d188);
+  x = f2 (x, d189);
+  x = f2 (x, d190);
+  x = f2 (x, d191);
+  x = f2 (x, d192);
+  x = f2 (x, d193);
+  x = f2 (x, d194);
+  x = f2 (x, d195);
+  x = f2 (x, d196);
+  x = f2 (x, d197);
+  x = f2 (x, d198);
+  x = f2 (x, d199);
+  x = f2 (x, d200);
+  x = f2 (x, d201);
+  x = f2 (x, d202);
+  x = f2 (x, d203);
+  x = f2 (x, d204);
+  x = f2 (x, d205);
+  x = f2 (x, d206);
+  x = f2 (x, d207);
+  x = f2 (x, d208);
+  x = f2 (x, d209);
+  x = f2 (x, d210);
+  x = f2 (x, d211);
+  x = f2 (x, d212);
+  x = f2 (x, d213);
+  x = f2 (x, d214);
+  x = f2 (x, d215);
+  x = f2 (x, d216);
+  x = f2 (x, d217);
+  x = f2 (x, d218);
+  x = f2 (x, d219);
+  x = f2 (x, d220);
+  x = f2 (x, d221);
+  x = f2 (x, d222);
+  x = f2 (x, d223);
+  x = f2 (x, d224);
+  x = f2 (x, d225);
+  x = f2 (x, d226);
+  x = f2 (x, d227);
+  x = f2 (x, d228);
+  x = f2 (x, d229);
+  x = f2 (x, d230);
+  x = f2 (x, d231);
+  x = f2 (x, d232);
+  x = f2 (x, d233);
+  x = f2 (x, d234);
+  x = f2 (x, d235);
+  x = f2 (x, d236);
+  x = f2 (x, d237);
+  x = f2 (x, d238);
+  x = f2 (x, d239);
+  x = f2 (x, d240);
+  x = f2 (x, d241);
+  x = f2 (x, d242);
+  x = f2 (x, d243);
+  x = f2 (x, d244);
+  x = f2 (x, d245);
+  x = f2 (x, d246);
+  x = f2 (x, d247);
+  x = f2 (x, d248);
+  x = f2 (x, d249);
+  x = f2 (x, d250);
+  x = f2 (x, d251);
+  x = f2 (x, d252);
+  x = f2 (x, d253);
+  x = f2 (x, d254);
+  x = f2 (x, d255);
+  x = f2 (x, d256);
+  x = f2 (x, d257);
+  x = f2 (x, d258);
+  x = f2 (x, d259);
+  x = f2 (x, d260);
+  x = f2 (x, d261);
+  x = f2 (x, d262);
+  x = f2 (x, d263);
+  x = f2 (x, d264);
+  x = f2 (x, d265);
+  x = f2 (x, d266);
+  x = f2 (x, d267);
+  x = f2 (x, d268);
+  x = f2 (x, d269);
+  x = f2 (x, d270);
+  x = f2 (x, d271);
+  x = f2 (x, d272);
+  x = f2 (x, d273);
+  x = f2 (x, d274);
+  x = f2 (x, d275);
+  x = f2 (x, d276);
+  x = f2 (x, d277);
+  x = f2 (x, d278);
+  x = f2 (x, d279);
+  x = f2 (x, d280);
+  x = f2 (x, d281);
+  x = f2 (x, d282);
+  x = f2 (x, d283);
+  x = f2 (x, d284);
+  x = f2 (x, d285);
+  x = f2 (x, d286);
+  x = f2 (x, d287);
+  x = f2 (x, d288);
+  x = f2 (x, d289);
+  x = f2 (x, d290);
+  x = f2 (x, d291);
+  x = f2 (x, d292);
+  x = f2 (x, d293);
+  x = f2 (x, d294);
+  x = f2 (x, d295);
+  x = f2 (x, d296);
+  x = f2 (x, d297);
+  x = f2 (x, d298);
+  x = f2 (x, d299);
+  x = f2 (x, d300);
+  x = f2 (x, d301);
+  x = f2 (x, d302);
+  x = f2 (x, d303);
+  x = f2 (x, d304);
+  x = f2 (x, d305);
+  x = f2 (x, d306);
+  x = f2 (x, d307);
+  x = f2 (x, d308);
+  x = f2 (x, d309);
+  x = f2 (x, d310);
+  x = f2 (x, d311);
+  x = f2 (x, d312);
+  x = f2 (x, d313);
+  x = f2 (x, d314);
+  x = f2 (x, d315);
+  x = f2 (x, d316);
+  x = f2 (x, d317);
+  x = f2 (x, d318);
+  x = f2 (x, d319);
+  x = f2 (x, d320);
+  x = f2 (x, d321);
+  x = f2 (x, d322);
+  x = f2 (x, d323);
+  x = f2 (x, d324);
+  x = f2 (x, d325);
+  x = f2 (x, d326);
+  x = f2 (x, d327);
+  x = f2 (x, d328);
+  x = f2 (x, d329);
+  x = f2 (x, d330);
+  x = f2 (x, d331);
+  x = f2 (x, d332);
+  x = f2 (x, d333);
+  x = f2 (x, d334);
+  x = f2 (x, d335);
+  x = f2 (x, d336);
+  x = f2 (x, d337);
+  x = f2 (x, d338);
+  x = f2 (x, d339);
+  x = f2 (x, d340);
+  x = f2 (x, d341);
+  x = f2 (x, d342);
+  x = f2 (x, d343);
+  x = f2 (x, d344);
+  x = f2 (x, d345);
+  x = f2 (x, d346);
+  x = f2 (x, d347);
+  x = f2 (x, d348);
+  x = f2 (x, d349);
+  x = f2 (x, d350);
+  x = f2 (x, d351);
+  x = f2 (x, d352);
+  x = f2 (x, d353);
+  x = f2 (x, d354);
+  x = f2 (x, d355);
+  x = f2 (x, d356);
+  x = f2 (x, d357);
+  x = f2 (x, d358);
+  x = f2 (x, d359);
+  x = f2 (x, d360);
+  x = f2 (x, d361);
+  x = f2 (x, d362);
+  x = f2 (x, d363);
+  x = f2 (x, d364);
+  x = f2 (x, d365);
+  x = f2 (x, d366);
+  x = f2 (x, d367);
+  x = f2 (x, d368);
+  x = f2 (x, d369);
+  x = f2 (x, d370);
+  x = f2 (x, d371);
+  x = f2 (x, d372);
+  x = f2 (x, d373);
+  x = f2 (x, d374);
+  x = f2 (x, d375);
+  x = f2 (x, d376);
+  x = f2 (x, d377);
+  x = f2 (x, d378);
+  x = f2 (x, d379);
+  x = f2 (x, d380);
+  x = f2 (x, d381);
+  x = f2 (x, d382);
+  x = f2 (x, d383);
+  x = f2 (x, d384);
+  x = f2 (x, d385);
+  x = f2 (x, d386);
+  x = f2 (x, d387);
+  x = f2 (x, d388);
+  x = f2 (x, d389);
+  x = f2 (x, d390);
+  x = f2 (x, d391);
+  x = f2 (x, d392);
+  x = f2 (x, d393);
+  x = f2 (x, d394);
+  x = f2 (x, d395);
+  x = f2 (x, d396);
+  x = f2 (x, d397);
+  x = f2 (x, d398);
+  x = f2 (x, d399);
+  x = f2 (x, d400);
+  x = f2 (x, d401);
+  x = f2 (x, d402);
+  x = f2 (x, d403);
+  x = f2 (x, d404);
+  x = f2 (x, d405);
+  x = f2 (x, d406);
+  x = f2 (x, d407);
+  x = f2 (x, d408);
+  x = f2 (x, d409);
+  x = f2 (x, d410);
+  x = f2 (x, d411);
+  x = f2 (x, d412);
+  x = f2 (x, d413);
+  x = f2 (x, d414);
+  x = f2 (x, d415);
+  x = f2 (x, d416);
+  x = f2 (x, d417);
+  x = f2 (x, d418);
+  x = f2 (x, d419);
+  x = f2 (x, d420);
+  x = f2 (x, d421);
+  x = f2 (x, d422);
+  x = f2 (x, d423);
+  x = f2 (x, d424);
+  x = f2 (x, d425);
+  x = f2 (x, d426);
+  x = f2 (x, d427);
+  x = f2 (x, d428);
+  x = f2 (x, d429);
+  x = f2 (x, d430);
+  x = f2 (x, d431);
+  x = f2 (x, d432);
+  x = f2 (x, d433);
+  x = f2 (x, d434);
+  x = f2 (x, d435);
+  x = f2 (x, d436);
+  x = f2 (x, d437);
+  x = f2 (x, d438);
+  x = f2 (x, d439);
+  x = f2 (x, d440);
+  x = f2 (x, d441);
+  x = f2 (x, d442);
+  x = f2 (x, d443);
+  x = f2 (x, d444);
+  x = f2 (x, d445);
+  x = f2 (x, d446);
+  x = f2 (x, d447);
+  x = f2 (x, d448);
+  x = f2 (x, d449);
+  x = f2 (x, d450);
+  x = f2 (x, d451);
+  x = f2 (x, d452);
+  x = f2 (x, d453);
+  x = f2 (x, d454);
+  x = f2 (x, d455);
+  x = f2 (x, d456);
+  x = f2 (x, d457);
+  x = f2 (x, d458);
+  x = f2 (x, d459);
+  x = f2 (x, d460);
+  x = f2 (x, d461);
+  x = f2 (x, d462);
+  x = f2 (x, d463);
+  x = f2 (x, d464);
+  x = f2 (x, d465);
+  x = f2 (x, d466);
+  x = f2 (x, d467);
+  x = f2 (x, d468);
+  x = f2 (x, d469);
+  x = f2 (x, d470);
+  x = f2 (x, d471);
+  x = f2 (x, d472);
+  x = f2 (x, d473);
+  x = f2 (x, d474);
+  x = f2 (x, d475);
+  x = f2 (x, d476);
+  x = f2 (x, d477);
+  x = f2 (x, d478);
+  x = f2 (x, d479);
+  x = f2 (x, d480);
+  x = f2 (x, d481);
+  x = f2 (x, d482);
+  x = f2 (x, d483);
+  x = f2 (x, d484);
+  x = f2 (x, d485);
+  x = f2 (x, d486);
+  x = f2 (x, d487);
+  x = f2 (x, d488);
+  x = f2 (x, d489);
+  x = f2 (x, d490);
+  x = f2 (x, d491);
+  x = f2 (x, d492);
+  x = f2 (x, d493);
+  x = f2 (x, d494);
+  x = f2 (x, d495);
+  x = f2 (x, d496);
+  x = f2 (x, d497);
+  x = f2 (x, d498);
+  x = f2 (x, d499);
+  x = f2 (x, d500);
+  x = f2 (x, d501);
+  x = f2 (x, d502);
+  x = f2 (x, d503);
+  x = f2 (x, d504);
+  x = f2 (x, d505);
+  x = f2 (x, d506);
+  x = f2 (x, d507);
+  x = f2 (x, d508);
+  x = f2 (x, d509);
+  x = f2 (x, d510);
+  x = f2 (x, d511);
+  x = f2 (x, d512);
+  x = f2 (x, d513);
+  x = f2 (x, d514);
+  x = f2 (x, d515);
+  x = f2 (x, d516);
+  x = f2 (x, d517);
+  x = f2 (x, d518);
+  x = f2 (x, d519);
+  x = f2 (x, d520);
+  x = f2 (x, d521);
+  x = f2 (x, d522);
+  x = f2 (x, d523);
+  x = f2 (x, d524);
+  x = f2 (x, d525);
+  x = f2 (x, d526);
+  x = f2 (x, d527);
+  x = f2 (x, d528);
+  x = f2 (x, d529);
+  x = f2 (x, d530);
+  x = f2 (x, d531);
+  x = f2 (x, d532);
+  x = f2 (x, d533);
+  x = f2 (x, d534);
+  x = f2 (x, d535);
+  x = f2 (x, d536);
+  x = f2 (x, d537);
+  x = f2 (x, d538);
+  x = f2 (x, d539);
+  x = f2 (x, d540);
+  x = f2 (x, d541);
+  x = f2 (x, d542);
+  x = f2 (x, d543);
+  x = f2 (x, d544);
+  x = f2 (x, d545);
+  x = f2 (x, d546);
+  x = f2 (x, d547);
+  x = f2 (x, d548);
+  x = f2 (x, d549);
+  x = f2 (x, d550);
+  x = f2 (x, d551);
+  x = f2 (x, d552);
+  x = f2 (x, d553);
+  x = f2 (x, d554);
+  x = f2 (x, d555);
+  x = f2 (x, d556);
+  x = f2 (x, d557);
+  x = f2 (x, d558);
+  x = f2 (x, d559);
+  x = f2 (x, d560);
+  x = f2 (x, d561);
+  x = f2 (x, d562);
+  x = f2 (x, d563);
+  x = f2 (x, d564);
+  x = f2 (x, d565);
+  x = f2 (x, d566);
+  x = f2 (x, d567);
+  x = f2 (x, d568);
+  x = f2 (x, d569);
+  x = f2 (x, d570);
+  x = f2 (x, d571);
+  x = f2 (x, d572);
+  x = f2 (x, d573);
+  x = f2 (x, d574);
+  x = f2 (x, d575);
+  x = f2 (x, d576);
+  x = f2 (x, d577);
+  x = f2 (x, d578);
+  x = f2 (x, d579);
+  x = f2 (x, d580);
+  x = f2 (x, d581);
+  x = f2 (x, d582);
+  x = f2 (x, d583);
+  x = f2 (x, d584);
+  x = f2 (x, d585);
+  x = f2 (x, d586);
+  x = f2 (x, d587);
+  x = f2 (x, d588);
+  x = f2 (x, d589);
+  x = f2 (x, d590);
+  x = f2 (x, d591);
+  x = f2 (x, d592);
+  x = f2 (x, d593);
+  x = f2 (x, d594);
+  x = f2 (x, d595);
+  x = f2 (x, d596);
+  x = f2 (x, d597);
+  x = f2 (x, d598);
+  x = f2 (x, d599);
+  x = f2 (x, d600);
+  x = f2 (x, d601);
+  x = f2 (x, d602);
+  x = f2 (x, d603);
+  x = f2 (x, d604);
+  x = f2 (x, d605);
+  x = f2 (x, d606);
+  x = f2 (x, d607);
+  x = f2 (x, d608);
+  x = f2 (x, d609);
+  x = f2 (x, d610);
+  x = f2 (x, d611);
+  x = f2 (x, d612);
+  x = f2 (x, d613);
+  x = f2 (x, d614);
+  x = f2 (x, d615);
+  x = f2 (x, d616);
+  x = f2 (x, d617);
+  x = f2 (x, d618);
+  x = f2 (x, d619);
+  x = f2 (x, d620);
+  x = f2 (x, d621);
+  x = f2 (x, d622);
+  x = f2 (x, d623);
+  x = f2 (x, d624);
+  x = f2 (x, d625);
+  x = f2 (x, d626);
+  x = f2 (x, d627);
+  x = f2 (x, d628);
+  x = f2 (x, d629);
+  x = f2 (x, d630);
+  x = f2 (x, d631);
+  x = f2 (x, d632);
+  x = f2 (x, d633);
+  x = f2 (x, d634);
+  x = f2 (x, d635);
+  x = f2 (x, d636);
+  x = f2 (x, d637);
+  x = f2 (x, d638);
+  x = f2 (x, d639);
+  x = f2 (x, d640);
+  x = f2 (x, d641);
+  x = f2 (x, d642);
+  x = f2 (x, d643);
+  x = f2 (x, d644);
+  x = f2 (x, d645);
+  x = f2 (x, d646);
+  x = f2 (x, d647);
+  x = f2 (x, d648);
+  x = f2 (x, d649);
+  x = f2 (x, d650);
+  x = f2 (x, d651);
+  x = f2 (x, d652);
+  x = f2 (x, d653);
+  x = f2 (x, d654);
+  x = f2 (x, d655);
+  x = f2 (x, d656);
+  x = f2 (x, d657);
+  x = f2 (x, d658);
+  x = f2 (x, d659);
+  x = f2 (x, d660);
+  x = f2 (x, d661);
+  x = f2 (x, d662);
+  x = f2 (x, d663);
+  x = f2 (x, d664);
+  x = f2 (x, d665);
+  x = f2 (x, d666);
+  x = f2 (x, d667);
+  x = f2 (x, d668);
+  x = f2 (x, d669);
+  x = f2 (x, d670);
+  x = f2 (x, d671);
+  x = f2 (x, d672);
+  x = f2 (x, d673);
+  x = f2 (x, d674);
+  x = f2 (x, d675);
+  x = f2 (x, d676);
+  x = f2 (x, d677);
+  x = f2 (x, d678);
+  x = f2 (x, d679);
+  x = f2 (x, d680);
+  x = f2 (x, d681);
+  x = f2 (x, d682);
+  x = f2 (x, d683);
+  x = f2 (x, d684);
+  x = f2 (x, d685);
+  x = f2 (x, d686);
+  x = f2 (x, d687);
+  x = f2 (x, d688);
+  x = f2 (x, d689);
+  x = f2 (x, d690);
+  x = f2 (x, d691);
+  x = f2 (x, d692);
+  x = f2 (x, d693);
+  x = f2 (x, d694);
+  x = f2 (x, d695);
+  x = f2 (x, d696);
+  x = f2 (x, d697);
+  x = f2 (x, d698);
+  x = f2 (x, d699);
+  x = f2 (x, d700);
+  x = f2 (x, d701);
+  x = f2 (x, d702);
+  x = f2 (x, d703);
+  x = f2 (x, d704);
+  x = f2 (x, d705);
+  x = f2 (x, d706);
+  x = f2 (x, d707);
+  x = f2 (x, d708);
+  x = f2 (x, d709);
+  x = f2 (x, d710);
+  x = f2 (x, d711);
+  x = f2 (x, d712);
+  x = f2 (x, d713);
+  x = f2 (x, d714);
+  x = f2 (x, d715);
+  x = f2 (x, d716);
+  x = f2 (x, d717);
+  x = f2 (x, d718);
+  x = f2 (x, d719);
+  x = f2 (x, d720);
+  x = f2 (x, d721);
+  x = f2 (x, d722);
+  x = f2 (x, d723);
+  x = f2 (x, d724);
+  x = f2 (x, d725);
+  x = f2 (x, d726);
+  x = f2 (x, d727);
+  x = f2 (x, d728);
+  x = f2 (x, d729);
+  x = f2 (x, d730);
+  x = f2 (x, d731);
+  x = f2 (x, d732);
+  x = f2 (x, d733);
+  x = f2 (x, d734);
+  x = f2 (x, d735);
+  x = f2 (x, d736);
+  x = f2 (x, d737);
+  x = f2 (x, d738);
+  x = f2 (x, d739);
+  x = f2 (x, d740);
+  x = f2 (x, d741);
+  x = f2 (x, d742);
+  x = f2 (x, d743);
+  x = f2 (x, d744);
+  x = f2 (x, d745);
+  x = f2 (x, d746);
+  x = f2 (x, d747);
+  x = f2 (x, d748);
+  x = f2 (x, d749);
+  x = f2 (x, d750);
+  x = f2 (x, d751);
+  x = f2 (x, d752);
+  x = f2 (x, d753);
+  x = f2 (x, d754);
+  x = f2 (x, d755);
+  x = f2 (x, d756);
+  x = f2 (x, d757);
+  x = f2 (x, d758);
+  x = f2 (x, d759);
+  x = f2 (x, d760);
+  x = f2 (x, d761);
+  x = f2 (x, d762);
+  x = f2 (x, d763);
+  x = f2 (x, d764);
+  x = f2 (x, d765);
+  x = f2 (x, d766);
+  x = f2 (x, d767);
+  x = f2 (x, d768);
+  x = f2 (x, d769);
+  x = f2 (x, d770);
+  x = f2 (x, d771);
+  x = f2 (x, d772);
+  x = f2 (x, d773);
+  x = f2 (x, d774);
+  x = f2 (x, d775);
+  x = f2 (x, d776);
+  x = f2 (x, d777);
+  x = f2 (x, d778);
+  x = f2 (x, d779);
+  x = f2 (x, d780);
+  x = f2 (x, d781);
+  x = f2 (x, d782);
+  x = f2 (x, d783);
+  x = f2 (x, d784);
+  x = f2 (x, d785);
+  x = f2 (x, d786);
+  x = f2 (x, d787);
+  x = f2 (x, d788);
+  x = f2 (x, d789);
+  x = f2 (x, d790);
+  x = f2 (x, d791);
+  x = f2 (x, d792);
+  x = f2 (x, d793);
+  x = f2 (x, d794);
+  x = f2 (x, d795);
+  x = f2 (x, d796);
+  x = f2 (x, d797);
+  x = f2 (x, d798);
+  x = f2 (x, d799);
+  x = f2 (x, d800);
+  x = f2 (x, d801);
+  x = f2 (x, d802);
+  x = f2 (x, d803);
+  x = f2 (x, d804);
+  x = f2 (x, d805);
+  x = f2 (x, d806);
+  x = f2 (x, d807);
+  x = f2 (x, d808);
+  x = f2 (x, d809);
+  x = f2 (x, d810);
+  x = f2 (x, d811);
+  x = f2 (x, d812);
+  x = f2 (x, d813);
+  x = f2 (x, d814);
+  x = f2 (x, d815);
+  x = f2 (x, d816);
+  x = f2 (x, d817);
+  x = f2 (x, d818);
+  x = f2 (x, d819);
+  x = f2 (x, d820);
+  x = f2 (x, d821);
+  x = f2 (x, d822);
+  x = f2 (x, d823);
+  x = f2 (x, d824);
+  x = f2 (x, d825);
+  x = f2 (x, d826);
+  x = f2 (x, d827);
+  x = f2 (x, d828);
+  x = f2 (x, d829);
+  x = f2 (x, d830);
+  x = f2 (x, d831);
+  x = f2 (x, d832);
+  x = f2 (x, d833);
+  x = f2 (x, d834);
+  x = f2 (x, d835);
+  x = f2 (x, d836);
+  x = f2 (x, d837);
+  x = f2 (x, d838);
+  x = f2 (x, d839);
+  x = f2 (x, d840);
+  x = f2 (x, d841);
+  x = f2 (x, d842);
+  x = f2 (x, d843);
+  x = f2 (x, d844);
+  x = f2 (x, d845);
+  x = f2 (x, d846);
+  x = f2 (x, d847);
+  x = f2 (x, d848);
+  x = f2 (x, d849);
+  x = f2 (x, d850);
+  x = f2 (x, d851);
+  x = f2 (x, d852);
+  x = f2 (x, d853);
+  x = f2 (x, d854);
+  x = f2 (x, d855);
+  x = f2 (x, d856);
+  x = f2 (x, d857);
+  x = f2 (x, d858);
+  x = f2 (x, d859);
+  x = f2 (x, d860);
+  x = f2 (x, d861);
+  x = f2 (x, d862);
+  x = f2 (x, d863);
+  x = f2 (x, d864);
+  x = f2 (x, d865);
+  x = f2 (x, d866);
+  x = f2 (x, d867);
+  x = f2 (x, d868);
+  x = f2 (x, d869);
+  x = f2 (x, d870);
+  x = f2 (x, d871);
+  x = f2 (x, d872);
+  x = f2 (x, d873);
+  x = f2 (x, d874);
+  x = f2 (x, d875);
+  x = f2 (x, d876);
+  x = f2 (x, d877);
+  x = f2 (x, d878);
+  x = f2 (x, d879);
+  x = f2 (x, d880);
+  x = f2 (x, d881);
+  x = f2 (x, d882);
+  x = f2 (x, d883);
+  x = f2 (x, d884);
+  x = f2 (x, d885);
+  x = f2 (x, d886);
+  x = f2 (x, d887);
+  x = f2 (x, d888);
+  x = f2 (x, d889);
+  x = f2 (x, d890);
+  x = f2 (x, d891);
+  x = f2 (x, d892);
+  x = f2 (x, d893);
+  x = f2 (x, d894);
+  x = f2 (x, d895);
+  x = f2 (x, d896);
+  x = f2 (x, d897);
+  x = f2 (x, d898);
+  x = f2 (x, d899);
+  x = f2 (x, d900);
+  x = f2 (x, d901);
+  x = f2 (x, d902);
+  x = f2 (x, d903);
+  x = f2 (x, d904);
+  x = f2 (x, d905);
+  x = f2 (x, d906);
+  x = f2 (x, d907);
+  x = f2 (x, d908);
+  x = f2 (x, d909);
+  x = f2 (x, d910);
+  x = f2 (x, d911);
+  x = f2 (x, d912);
+  x = f2 (x, d913);
+  x = f2 (x, d914);
+  x = f2 (x, d915);
+  x = f2 (x, d916);
+  x = f2 (x, d917);
+  x = f2 (x, d918);
+  x = f2 (x, d919);
+  x = f2 (x, d920);
+  x = f2 (x, d921);
+  x = f2 (x, d922);
+  x = f2 (x, d923);
+  x = f2 (x, d924);
+  x = f2 (x, d925);
+  x = f2 (x, d926);
+  x = f2 (x, d927);
+  x = f2 (x, d928);
+  x = f2 (x, d929);
+  x = f2 (x, d930);
+  x = f2 (x, d931);
+  x = f2 (x, d932);
+  x = f2 (x, d933);
+  x = f2 (x, d934);
+  x = f2 (x, d935);
+  x = f2 (x, d936);
+  x = f2 (x, d937);
+  x = f2 (x, d938);
+  x = f2 (x, d939);
+  x = f2 (x, d940);
+  x = f2 (x, d941);
+  x = f2 (x, d942);
+  x = f2 (x, d943);
+  x = f2 (x, d944);
+  x = f2 (x, d945);
+  x = f2 (x, d946);
+  x = f2 (x, d947);
+  x = f2 (x, d948);
+  x = f2 (x, d949);
+  x = f2 (x, d950);
+  x = f2 (x, d951);
+  x = f2 (x, d952);
+  x = f2 (x, d953);
+  x = f2 (x, d954);
+  x = f2 (x, d955);
+  x = f2 (x, d956);
+  x = f2 (x, d957);
+  x = f2 (x, d958);
+  x = f2 (x, d959);
+  x = f2 (x, d960);
+  x = f2 (x, d961);
+  x = f2 (x, d962);
+  x = f2 (x, d963);
+  x = f2 (x, d964);
+  x = f2 (x, d965);
+  x = f2 (x, d966);
+  x = f2 (x, d967);
+  x = f2 (x, d968);
+  x = f2 (x, d969);
+  x = f2 (x, d970);
+  x = f2 (x, d971);
+  x = f2 (x, d972);
+  x = f2 (x, d973);
+  x = f2 (x, d974);
+  x = f2 (x, d975);
+  x = f2 (x, d976);
+  x = f2 (x, d977);
+  x = f2 (x, d978);
+  x = f2 (x, d979);
+  x = f2 (x, d980);
+  x = f2 (x, d981);
+  x = f2 (x, d982);
+  x = f2 (x, d983);
+  x = f2 (x, d984);
+  x = f2 (x, d985);
+  x = f2 (x, d986);
+  x = f2 (x, d987);
+  x = f2 (x, d988);
+  x = f2 (x, d989);
+  x = f2 (x, d990);
+  x = f2 (x, d991);
+  x = f2 (x, d992);
+  x = f2 (x, d993);
+  x = f2 (x, d994);
+  x = f2 (x, d995);
+  x = f2 (x, d996);
+  x = f2 (x, d997);
+  x = f2 (x, d998);
+  x = f2 (x, d999);
+  return x;
+}
+
+/* { dg-final { scan-rtl-dump-times "Stack clash inline probes" 1 "pro_and_epilogue" } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash residual allocation in prologue" 1 "pro_and_epilogue" } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash not noreturn" 1 "pro_and_epilogue" } } */
+
+/* f3 is not a leaf
+/* { dg-final { scan-rtl-dump-times "Stack clash no frame pointer needed" 1 "pro_and_epilogue" { target { ! frame_pointer_for_non_leaf } } } } */
+/* { dg-final { scan-rtl-dump-times "Stack clash frame pointer needed" 1 "pro_and_epilogue" { target { frame_pointer_for_non_leaf } } } } */