modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/20030222-1.c (about)

     1  /* Verify that we get the low part of the long long as an int.  We
     2     used to get it wrong on big-endian machines, if register allocation
     3     succeeded at all.  We use volatile to make sure the long long is
     4     actually truncated to int, in case a single register is wide enough
     5     for a long long.  */
     6  /* { dg-skip-if "asm would require extra shift-left-4-byte" { spu-*-* } } */
     7  /* { dg-skip-if "asm requires register allocation" { nvptx-*-* } } */
     8  #include <limits.h>
     9  
    10  void
    11  ll_to_int (long long x, volatile int *p)
    12  {
    13    int i;
    14    asm ("" : "=r" (i) : "0" (x));
    15    *p = i;
    16  }
    17  
    18  int val = INT_MIN + 1;
    19  
    20  int main() {
    21    volatile int i;
    22  
    23    ll_to_int ((long long)val, &i);
    24    if (i != val)
    25      abort ();
    26    
    27    exit (0);
    28  }