<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/70566>70566</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            wrong code at -O{s,2,3} on x86_64-linux-gnu
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          zhendongsu
      </td>
    </tr>
</table>

<pre>
    It appears to be a regression from 14.\*, and affects 15.\* and later.

Compiler Explorer: https://godbolt.org/z/GoxPhxxzT

```
[560] % clangtk -v
clang version 18.0.0 (https://github.com/llvm/llvm-project.git a8e0acf660639078a7e5341dd6ec82326d3b796b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/opfuzz/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
[561] % 
[561] % clangtk -O1 small.c; ./a.out
[562] % 
[562] % clangtk -O3 small.c
[563] % ./a.out
Segmentation fault
[564] % 
[564] % cat small.c
long a[] = {4073709551615, 9, 3, 9, 4073709551615, 3};
int b, c, e = 12;
volatile char d;
long f;
int main() {
  int *g = &c, h = 0;
  for (; h < 6; h++) {
 f = 6;
    for (; f >= 0; f--)
      ;
  }
  b = 5;
  for (; b >= 0; b--) {
    ~f &&d;
    int i = d, j = ~e;
    char k = (f && d) + b;
    i = b;
    b = ~(b & ~(~f | j) & ~(c || d));
    c = j && (~(k & f) & i || ~(e && d));
    d = ~(((~f ^ i) | 7) & (e ^ (d | 4)));
    if (e < k && i > f)
      break;
    b = i;
    *g = a[i];
  }
  return 0;
}
```
</pre>
<img width="1px" height="1px" al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