(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
torture/
pr109564-1.c
       1  /* { dg-do run } */
       2  
       3  struct libkeccak_spec {
       4      long int bitrate;
       5  };
       6  
       7  struct libkeccak_generalised_spec {
       8      long int bitrate;
       9      long int state_size;
      10      long int word_size;
      11  };
      12  
      13  int __attribute__((noipa))
      14  libkeccak_degeneralise_spec(struct libkeccak_generalised_spec *restrict spec,
      15  			    struct libkeccak_spec *restrict output_spec)
      16  {
      17    long int state_size, word_size, bitrate, output;
      18    const int have_state_size = spec->state_size != (-65536L);
      19    const int have_word_size = spec->word_size != (-65536L);
      20    const int have_bitrate = spec->bitrate != (-65536L);
      21  
      22    if (have_state_size)
      23      {
      24        state_size = spec->state_size;
      25        if (state_size <= 0)
      26  	return 1;
      27        if (state_size > 1600)
      28  	return 2;
      29      }
      30  
      31    if (have_word_size)
      32      {
      33        word_size = spec->word_size;
      34        if (word_size <= 0)
      35  	return 4;
      36        if (word_size > 64)
      37  	return 5;
      38        if (have_state_size && state_size != word_size * 25)
      39  	return 6;
      40        else if (!have_state_size) {
      41  	  spec->state_size = 1;
      42  	  state_size = word_size * 25;
      43        }
      44      }
      45  
      46    if (have_bitrate)
      47      bitrate = spec->bitrate;
      48  
      49    if (!have_bitrate)
      50      {
      51        state_size = (have_state_size ? state_size : (1600L));
      52        output = ((state_size << 5) / 100L + 7L) & ~0x07L;
      53        bitrate = output << 1;
      54      }
      55  
      56    output_spec->bitrate = bitrate;
      57  
      58    return 0;
      59  }
      60  
      61  int main ()
      62  {
      63    struct libkeccak_generalised_spec gspec;
      64    struct libkeccak_spec spec;
      65    spec.bitrate = -1;
      66    gspec.bitrate = -65536;
      67    gspec.state_size = -65536;
      68    gspec.word_size = -65536;
      69    if (libkeccak_degeneralise_spec(&gspec, &spec))
      70      __builtin_abort ();
      71    if (spec.bitrate != 1024)
      72      __builtin_abort ();
      73    return 0;
      74  }