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

    <tr>
        <th>Summary</th>
        <td>
            Debug information for loop control variable initialization is incorrect in binary compiled with "-O0"
        </td>
    </tr>

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

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

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

<pre>
    The variable `i_1` at line 8 is incorrectly initialized to `23` instead of `0`. This issue can be reproduced using LLVM versions 18.1.8, 17.0.6, and 16.0.3. Godbolt link is [here](https://godbolt.org/z/rETvsb9cT)


```
clang -g -O0 func.c driver.c -o test_O0.out
lldb test_O0.out

(lldb) b func.c:8
(lldb) r
[...]
* thread #1, name = 'test_O0.out', stop reason = breakpoint 1.1
    frame #0: 0x0000555555555156 test_O0.out`test at func.c:8:32
   5    void test() {
   6        if (var_5){
   7            for (unsigned int i_0 = 0; i_0 < 23; i_0 += 3) 
-> 8          for (long long int i_1 = 0; i_1 < 23; i_1 += 4) 
   9     arr_7 [i_0] [i_1] =  var_0 && arr_1 [5U];
   10       }
   11   }
(lldb) p i_1
(long long) 23

```

GDB also exhibits this behavior.
```
$gdb test_O0.out
GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
[...]
(gdb) b func.c:8
(gdb) r
[...]
Breakpoint 1, test () at func.c:8
8        for (long long int i_1 = 0; i_1 < 23; i_1 += 4) 
(gdb) p i_1
$1 = 23

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU-T26gT_TT40mUKGv096GDHcS75_XKZ2asLSVhiI4MLkJPJp98Ca2zPTjKnnZrCovv1o7t5gPReD0aphuRbku9Wcg6jdY3q55O1YdXa_qV5GhVcpNOynRSQgukDJwUDGWDSRkEF2oM2nXVOdWF6AW100HLSv1QPwcYIFDFAGx-U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