1  /* { dg-additional-options "-O3" } */
       2  
       3  #include "analyzer-decls.h"
       4  
       5  typedef __SIZE_TYPE__ size_t;
       6  typedef unsigned char Byte;
       7  typedef unsigned int uInt;
       8  typedef unsigned long uLong;
       9  
      10  extern size_t strlen(const char *__s) __attribute__((__nothrow__, __leaf__))
      11      __attribute__((__pure__)) __attribute__((__nonnull__(1)));
      12  extern void exit(int __status) __attribute__((__nothrow__, __leaf__))
      13      __attribute__((__noreturn__));
      14  extern char *strcpy(char *__restrict __dest, const char *__restrict __src)
      15      __attribute__((__nothrow__, __leaf__)) __attribute__((__nonnull__(1, 2)));
      16  extern void *calloc(size_t __nmemb, size_t __size)
      17      __attribute__((__nothrow__, __leaf__)) __attribute__((__malloc__));
      18  
      19  extern int compress(Byte *dest, uLong *destLen, const Byte *source,
      20                      uLong sourceLen);
      21  
      22  const char hello[] = "hello, hello!";
      23  
      24  void test_compress(Byte *compr, uLong comprLen, Byte *uncompr,
      25                     uLong uncomprLen) {
      26    int err;
      27    uLong len = strlen(hello) + 1;
      28  
      29    err = compress(compr, &comprLen, (const Byte *)hello, len);
      30    if (err != 0)
      31      exit(1);
      32    strcpy((char *)uncompr, "garbage"); /* { dg-bogus "NULL" } */
      33  }
      34  
      35  int main(int argc, char *argv[]) {
      36    Byte *compr, *uncompr;
      37    uLong comprLen = 10000 * sizeof(int);
      38    uLong uncomprLen = comprLen;
      39  
      40    compr = (Byte *)calloc((uInt)comprLen, 1);
      41    uncompr = (Byte *)calloc((uInt)uncomprLen, 1);
      42    if (compr == 0 || uncompr == 0)
      43      exit(1);
      44  
      45    __analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */
      46  
      47    test_compress(compr, comprLen, uncompr, uncomprLen);
      48  
      49    exit(0);
      50    return 0;
      51  }