#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ foo();
void test_collapse() {
  int i;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse()
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(,
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(, )
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse 4)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(4
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(4,
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(4, )
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(4)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(4 4)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(4, , 4)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(4)
  for (int i1 = 0; i1 < 16; ++i1)
    for (int i2 = 0; i2 < 16; ++i2)
      for (int i3 = 0; i3 < 16; ++i3)
        for (int i4 = 0; i4 < 16; ++i4)
          foo();
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(4, 8)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(2.5)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(foo())
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(-5)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(0)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(5 - 5)
  for (i = 0; i < 16; ++i)
    ;
#pragma omp target
#pragma omp teams
#pragma omp distribute simd collapse(2) reduction(+ : i)
  for (i = 0; i < 16; ++i)
    for (int j = 0; j < 16; ++j)
#pragma omp for reduction(+ : i, j)
      for (int k = 0; k < 16; ++k)
        i += j;
#pragma omp target
#pragma omp teams
  for (i = 0; i < 16; ++i)
    for (int j = 0; j < 16; ++j)
#pragma omp distribute simd reduction(+ : i, j)
      for (int k = 0; k < 16; ++k)
        i += j;
}


x86 assembly (clang, -O0):
<test_collapse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    113c <test_collapse+0x2c>
jmp    112e <test_collapse+0x1e>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    111f <test_collapse+0xf>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    1160 <test_collapse+0x50>
jmp    1152 <test_collapse+0x42>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1143 <test_collapse+0x33>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    1184 <test_collapse+0x74>
jmp    1176 <test_collapse+0x66>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1167 <test_collapse+0x57>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    11a8 <test_collapse+0x98>
jmp    119a <test_collapse+0x8a>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    118b <test_collapse+0x7b>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    11cc <test_collapse+0xbc>
jmp    11be <test_collapse+0xae>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11af <test_collapse+0x9f>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    11f0 <test_collapse+0xe0>
jmp    11e2 <test_collapse+0xd2>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11d3 <test_collapse+0xc3>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    1214 <test_collapse+0x104>
jmp    1206 <test_collapse+0xf6>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11f7 <test_collapse+0xe7>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    1238 <test_collapse+0x128>
jmp    122a <test_collapse+0x11a>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    121b <test_collapse+0x10b>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    125c <test_collapse+0x14c>
jmp    124e <test_collapse+0x13e>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    123f <test_collapse+0x12f>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    1280 <test_collapse+0x170>
jmp    1272 <test_collapse+0x162>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1263 <test_collapse+0x153>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    12a4 <test_collapse+0x194>
jmp    1296 <test_collapse+0x186>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1287 <test_collapse+0x177>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    12c8 <test_collapse+0x1b8>
jmp    12ba <test_collapse+0x1aa>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    12ab <test_collapse+0x19b>
movl   $0x0,-0x8(%rbp)
cmpl   $0x10,-0x8(%rbp)
jge    135a <test_collapse+0x24a>
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    1347 <test_collapse+0x237>
movl   $0x0,-0x10(%rbp)
cmpl   $0x10,-0x10(%rbp)
jge    1334 <test_collapse+0x224>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jge    1321 <test_collapse+0x211>
mov    $0x0,%al
call   1030 <foo@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1302 <test_collapse+0x1f2>
jmp    1326 <test_collapse+0x216>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12f1 <test_collapse+0x1e1>
jmp    1339 <test_collapse+0x229>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12e0 <test_collapse+0x1d0>
jmp    134c <test_collapse+0x23c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12cf <test_collapse+0x1bf>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    137e <test_collapse+0x26e>
jmp    1370 <test_collapse+0x260>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1361 <test_collapse+0x251>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    13a2 <test_collapse+0x292>
jmp    1394 <test_collapse+0x284>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1385 <test_collapse+0x275>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    13c6 <test_collapse+0x2b6>
jmp    13b8 <test_collapse+0x2a8>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    13a9 <test_collapse+0x299>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    13ea <test_collapse+0x2da>
jmp    13dc <test_collapse+0x2cc>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    13cd <test_collapse+0x2bd>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    140e <test_collapse+0x2fe>
jmp    1400 <test_collapse+0x2f0>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    13f1 <test_collapse+0x2e1>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    1432 <test_collapse+0x322>
jmp    1424 <test_collapse+0x314>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1415 <test_collapse+0x305>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    14a2 <test_collapse+0x392>
movl   $0x0,-0x18(%rbp)
cmpl   $0x10,-0x18(%rbp)
jge    148f <test_collapse+0x37f>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    147c <test_collapse+0x36c>
mov    -0x18(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    145b <test_collapse+0x34b>
jmp    1481 <test_collapse+0x371>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    144a <test_collapse+0x33a>
jmp    1494 <test_collapse+0x384>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1439 <test_collapse+0x329>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    1512 <test_collapse+0x402>
movl   $0x0,-0x20(%rbp)
cmpl   $0x10,-0x20(%rbp)
jge    14ff <test_collapse+0x3ef>
movl   $0x0,-0x24(%rbp)
cmpl   $0x10,-0x24(%rbp)
jge    14ec <test_collapse+0x3dc>
mov    -0x20(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    14cb <test_collapse+0x3bb>
jmp    14f1 <test_collapse+0x3e1>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    14ba <test_collapse+0x3aa>
jmp    1504 <test_collapse+0x3f4>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    14a9 <test_collapse+0x399>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_collapse>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x10,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
xor    %eax,%eax
call   1030 <foo@plt>
add    $0xffffffff,%ebx
jne    1140 <test_collapse+0x30>
add    $0x1,%ebp
cmp    $0x10,%ebp
jne    1130 <test_collapse+0x20>
add    $0x1,%r14d
cmp    $0x10,%r14d
jne    1120 <test_collapse+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @test_collapse() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
br label %10
10: ; preds = %14, %0
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 16
br i1 %12, label %13, label %17
13: ; preds = %10
br label %14
14: ; preds = %13
%15 = load i32, i32* %1
%16 = add nsw i32 %15, 1
store i32 %16, i32* %1
br label %10
17: ; preds = %10
store i32 0, i32* %1
br label %18
18: ; preds = %22, %17
%19 = load i32, i32* %1
%20 = icmp slt i32 %19, 16
br i1 %20, label %21, label %25
21: ; preds = %18
br label %22
22: ; preds = %21
%23 = load i32, i32* %1
%24 = add nsw i32 %23, 1
store i32 %24, i32* %1
br label %18
25: ; preds = %18
store i32 0, i32* %1
br label %26
26: ; preds = %30, %25
%27 = load i32, i32* %1
%28 = icmp slt i32 %27, 16
br i1 %28, label %29, label %33
29: ; preds = %26
br label %30
30: ; preds = %29
%31 = load i32, i32* %1
%32 = add nsw i32 %31, 1
store i32 %32, i32* %1
br label %26
33: ; preds = %26
store i32 0, i32* %1
br label %34
34: ; preds = %38, %33
%35 = load i32, i32* %1
%36 = icmp slt i32 %35, 16
br i1 %36, label %37, label %41
37: ; preds = %34
br label %38
38: ; preds = %37
%39 = load i32, i32* %1
%40 = add nsw i32 %39, 1
store i32 %40, i32* %1
br label %34
41: ; preds = %34
store i32 0, i32* %1
br label %42
42: ; preds = %46, %41
%43 = load i32, i32* %1
%44 = icmp slt i32 %43, 16
br i1 %44, label %45, label %49
45: ; preds = %42
br label %46
46: ; preds = %45
%47 = load i32, i32* %1
%48 = add nsw i32 %47, 1
store i32 %48, i32* %1
br label %42
49: ; preds = %42
store i32 0, i32* %1
br label %50
50: ; preds = %54, %49
%51 = load i32, i32* %1
%52 = icmp slt i32 %51, 16
br i1 %52, label %53, label %57
53: ; preds = %50
br label %54
54: ; preds = %53
%55 = load i32, i32* %1
%56 = add nsw i32 %55, 1
store i32 %56, i32* %1
br label %50
57: ; preds = %50
store i32 0, i32* %1
br label %58
58: ; preds = %62, %57
%59 = load i32, i32* %1
%60 = icmp slt i32 %59, 16
br i1 %60, label %61, label %65
61: ; preds = %58
br label %62
62: ; preds = %61
%63 = load i32, i32* %1
%64 = add nsw i32 %63, 1
store i32 %64, i32* %1
br label %58
65: ; preds = %58
store i32 0, i32* %1
br label %66
66: ; preds = %70, %65
%67 = load i32, i32* %1
%68 = icmp slt i32 %67, 16
br i1 %68, label %69, label %73
69: ; preds = %66
br label %70
70: ; preds = %69
%71 = load i32, i32* %1
%72 = add nsw i32 %71, 1
store i32 %72, i32* %1
br label %66
73: ; preds = %66
store i32 0, i32* %1
br label %74
74: ; preds = %78, %73
%75 = load i32, i32* %1
%76 = icmp slt i32 %75, 16
br i1 %76, label %77, label %81
77: ; preds = %74
br label %78
78: ; preds = %77
%79 = load i32, i32* %1
%80 = add nsw i32 %79, 1
store i32 %80, i32* %1
br label %74
81: ; preds = %74
store i32 0, i32* %1
br label %82
82: ; preds = %86, %81
%83 = load i32, i32* %1
%84 = icmp slt i32 %83, 16
br i1 %84, label %85, label %89
85: ; preds = %82
br label %86
86: ; preds = %85
%87 = load i32, i32* %1
%88 = add nsw i32 %87, 1
store i32 %88, i32* %1
br label %82
89: ; preds = %82
store i32 0, i32* %1
br label %90
90: ; preds = %94, %89
%91 = load i32, i32* %1
%92 = icmp slt i32 %91, 16
br i1 %92, label %93, label %97
93: ; preds = %90
br label %94
94: ; preds = %93
%95 = load i32, i32* %1
%96 = add nsw i32 %95, 1
store i32 %96, i32* %1
br label %90
97: ; preds = %90
store i32 0, i32* %1
br label %98
98: ; preds = %102, %97
%99 = load i32, i32* %1
%100 = icmp slt i32 %99, 16
br i1 %100, label %101, label %105
101: ; preds = %98
br label %102
102: ; preds = %101
%103 = load i32, i32* %1
%104 = add nsw i32 %103, 1
store i32 %104, i32* %1
br label %98
105: ; preds = %98
store i32 0, i32* %2
br label %106
106: ; preds = %135, %105
%107 = load i32, i32* %2
%108 = icmp slt i32 %107, 16
br i1 %108, label %109, label %138
109: ; preds = %106
store i32 0, i32* %3
br label %110
110: ; preds = %131, %109
%111 = load i32, i32* %3
%112 = icmp slt i32 %111, 16
br i1 %112, label %113, label %134
113: ; preds = %110
store i32 0, i32* %4
br label %114
114: ; preds = %127, %113
%115 = load i32, i32* %4
%116 = icmp slt i32 %115, 16
br i1 %116, label %117, label %130
117: ; preds = %114
store i32 0, i32* %5
br label %118
118: ; preds = %123, %117
%119 = load i32, i32* %5
%120 = icmp slt i32 %119, 16
br i1 %120, label %121, label %126
121: ; preds = %118
%122 = call i32 (...) @foo()
br label %123
123: ; preds = %121
%124 = load i32, i32* %5
%125 = add nsw i32 %124, 1
store i32 %125, i32* %5
br label %118
126: ; preds = %118
br label %127
127: ; preds = %126
%128 = load i32, i32* %4
%129 = add nsw i32 %128, 1
store i32 %129, i32* %4
br label %114
130: ; preds = %114
br label %131
131: ; preds = %130
%132 = load i32, i32* %3
%133 = add nsw i32 %132, 1
store i32 %133, i32* %3
br label %110
134: ; preds = %110
br label %135
135: ; preds = %134
%136 = load i32, i32* %2
%137 = add nsw i32 %136, 1
store i32 %137, i32* %2
br label %106
138: ; preds = %106
store i32 0, i32* %1
br label %139
139: ; preds = %143, %138
%140 = load i32, i32* %1
%141 = icmp slt i32 %140, 16
br i1 %141, label %142, label %146
142: ; preds = %139
br label %143
143: ; preds = %142
%144 = load i32, i32* %1
%145 = add nsw i32 %144, 1
store i32 %145, i32* %1
br label %139
146: ; preds = %139
store i32 0, i32* %1
br label %147
147: ; preds = %151, %146
%148 = load i32, i32* %1
%149 = icmp slt i32 %148, 16
br i1 %149, label %150, label %154
150: ; preds = %147
br label %151
151: ; preds = %150
%152 = load i32, i32* %1
%153 = add nsw i32 %152, 1
store i32 %153, i32* %1
br label %147
154: ; preds = %147
store i32 0, i32* %1
br label %155
155: ; preds = %159, %154
%156 = load i32, i32* %1
%157 = icmp slt i32 %156, 16
br i1 %157, label %158, label %162
158: ; preds = %155
br label %159
159: ; preds = %158
%160 = load i32, i32* %1
%161 = add nsw i32 %160, 1
store i32 %161, i32* %1
br label %155
162: ; preds = %155
store i32 0, i32* %1
br label %163
163: ; preds = %167, %162
%164 = load i32, i32* %1
%165 = icmp slt i32 %164, 16
br i1 %165, label %166, label %170
166: ; preds = %163
br label %167
167: ; preds = %166
%168 = load i32, i32* %1
%169 = add nsw i32 %168, 1
store i32 %169, i32* %1
br label %163
170: ; preds = %163
store i32 0, i32* %1
br label %171
171: ; preds = %175, %170
%172 = load i32, i32* %1
%173 = icmp slt i32 %172, 16
br i1 %173, label %174, label %178
174: ; preds = %171
br label %175
175: ; preds = %174
%176 = load i32, i32* %1
%177 = add nsw i32 %176, 1
store i32 %177, i32* %1
br label %171
178: ; preds = %171
store i32 0, i32* %1
br label %179
179: ; preds = %183, %178
%180 = load i32, i32* %1
%181 = icmp slt i32 %180, 16
br i1 %181, label %182, label %186
182: ; preds = %179
br label %183
183: ; preds = %182
%184 = load i32, i32* %1
%185 = add nsw i32 %184, 1
store i32 %185, i32* %1
br label %179
186: ; preds = %179
store i32 0, i32* %1
br label %187
187: ; preds = %210, %186
%188 = load i32, i32* %1
%189 = icmp slt i32 %188, 16
br i1 %189, label %190, label %213
190: ; preds = %187
store i32 0, i32* %6
br label %191
191: ; preds = %206, %190
%192 = load i32, i32* %6
%193 = icmp slt i32 %192, 16
br i1 %193, label %194, label %209
194: ; preds = %191
store i32 0, i32* %7
br label %195
195: ; preds = %202, %194
%196 = load i32, i32* %7
%197 = icmp slt i32 %196, 16
br i1 %197, label %198, label %205
198: ; preds = %195
%199 = load i32, i32* %6
%200 = load i32, i32* %1
%201 = add nsw i32 %200, %199
store i32 %201, i32* %1
br label %202
202: ; preds = %198
%203 = load i32, i32* %7
%204 = add nsw i32 %203, 1
store i32 %204, i32* %7
br label %195
205: ; preds = %195
br label %206
206: ; preds = %205
%207 = load i32, i32* %6
%208 = add nsw i32 %207, 1
store i32 %208, i32* %6
br label %191
209: ; preds = %191
br label %210
210: ; preds = %209
%211 = load i32, i32* %1
%212 = add nsw i32 %211, 1
store i32 %212, i32* %1
br label %187
213: ; preds = %187
store i32 0, i32* %1
br label %214
214: ; preds = %237, %213
%215 = load i32, i32* %1
%216 = icmp slt i32 %215, 16
br i1 %216, label %217, label %240
217: ; preds = %214
store i32 0, i32* %8
br label %218
218: ; preds = %233, %217
%219 = load i32, i32* %8
%220 = icmp slt i32 %219, 16
br i1 %220, label %221, label %236
221: ; preds = %218
store i32 0, i32* %9
br label %222
222: ; preds = %229, %221
%223 = load i32, i32* %9
%224 = icmp slt i32 %223, 16
br i1 %224, label %225, label %232
225: ; preds = %222
%226 = load i32, i32* %8
%227 = load i32, i32* %1
%228 = add nsw i32 %227, %226
store i32 %228, i32* %1
br label %229
229: ; preds = %225
%230 = load i32, i32* %9
%231 = add nsw i32 %230, 1
store i32 %231, i32* %9
br label %222
232: ; preds = %222
br label %233
233: ; preds = %232
%234 = load i32, i32* %8
%235 = add nsw i32 %234, 1
store i32 %235, i32* %8
br label %218
236: ; preds = %218
br label %237
237: ; preds = %236
%238 = load i32, i32* %1
%239 = add nsw i32 %238, 1
store i32 %239, i32* %1
br label %214
240: ; preds = %214
ret void
}

LLVM IR (-O2):
define void @test_collapse() {
br label %1
1: ; preds = %0, %5
%2 = phi i32 [ %6, %5 ], [ 0, %0 ]
br label %3
3: ; preds = %1, %29
%4 = phi i32 [ 0, %1 ], [ %30, %29 ]
br label %9
5: ; preds = %29
%6 = add nuw nsw i32 %2, 1
%7 = icmp eq i32 %6, 16
br i1 %7, label %8, label %1
8: ; preds = %5
ret void
9: ; preds = %3, %9
%10 = phi i32 [ 0, %3 ], [ %27, %9 ]
%11 = tail call i32 (...) @foo()
%12 = tail call i32 (...) @foo()
%13 = tail call i32 (...) @foo()
%14 = tail call i32 (...) @foo()
%15 = tail call i32 (...) @foo()
%16 = tail call i32 (...) @foo()
%17 = tail call i32 (...) @foo()
%18 = tail call i32 (...) @foo()
%19 = tail call i32 (...) @foo()
%20 = tail call i32 (...) @foo()
%21 = tail call i32 (...) @foo()
%22 = tail call i32 (...) @foo()
%23 = tail call i32 (...) @foo()
%24 = tail call i32 (...) @foo()
%25 = tail call i32 (...) @foo()
%26 = tail call i32 (...) @foo()
%27 = add nuw nsw i32 %10, 1
%28 = icmp eq i32 %27, 16
br i1 %28, label %29, label %9
29: ; preds = %9
%30 = add nuw nsw i32 %4, 1
%31 = icmp eq i32 %30, 16
br i1 %31, label %5, label %3
}