#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*/ assert(int);
void example6(void) {
  int a[42];
  int i = 0;
  int top;
  while (i < 30) {
    a[i] = 0;
    i++;
    assert(a[top] == 0);
    int j = 0;
    while (j < i) {
      assert(a[j] == 0);
      j++;
    }
  }
}


x86 assembly (clang, -O0):
<example6>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0xb4(%rbp)
cmpl   $0x1e,-0xb4(%rbp)
jge    11c0 <example6+0xb0>
movslq -0xb4(%rbp),%rax
movl   $0x0,-0xb0(%rbp,%rax,4)
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
movslq -0xb8(%rbp),%rax
cmpl   $0x0,-0xb0(%rbp,%rax,4)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x0,-0xbc(%rbp)
mov    -0xbc(%rbp),%eax
cmp    -0xb4(%rbp),%eax
jge    11bb <example6+0xab>
movslq -0xbc(%rbp),%rax
cmpl   $0x0,-0xb0(%rbp,%rax,4)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
jmp    1179 <example6+0x69>
jmp    1125 <example6+0x15>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<example6>:
push   %rbp
push   %r14
push   %rbx
sub    $0xb0,%rsp
mov    $0x1,%r14d
xor    %ebx,%ebx
jmp    113e <example6+0x2e>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
add    $0x1,%r14
cmp    $0x1e,%rbx
je     118b <example6+0x7b>
movl   $0x0,(%rsp,%rbx,4)
xor    %ebp,%ebp
cmpl   $0x0,(%rsp)
sete   %bpl
mov    %ebp,%edi
call   1030 <assert@plt>
mov    %ebp,%edi
call   1030 <assert@plt>
cmp    $0x1,%r14
je     1130 <example6+0x20>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edi,%edi
cmpl   $0x0,0x4(%rsp,%rbp,4)
sete   %dil
call   1030 <assert@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1170 <example6+0x60>
jmp    1130 <example6+0x20>
add    $0xb0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @example6() {
%1 = alloca [42 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %2
br label %5
5: ; preds = %35, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 30
br i1 %7, label %8, label %36
8: ; preds = %5
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [42 x i32], [42 x i32]* %1, i64 0, i64 %10
store i32 0, i32* %11
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
store i32 %13, i32* %2
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [42 x i32], [42 x i32]* %1, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
store i32 0, i32* %4
br label %21
21: ; preds = %25, %8
%22 = load i32, i32* %4
%23 = load i32, i32* %2
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %35
25: ; preds = %21
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [42 x i32], [42 x i32]* %1, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = icmp eq i32 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %21
35: ; preds = %21
br label %5
36: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @example6() {
%1 = alloca [42 x i32]
%2 = bitcast [42 x i32]* %1 to i8*
%3 = getelementptr inbounds [42 x i32], [42 x i32]* %1, i64 0, i64 0
br label %8
4: ; preds = %20, %8
%5 = add nuw nsw i64 %9, 1
%6 = add nuw nsw i64 %10, 1
%7 = icmp eq i64 %5, 30
br i1 %7, label %29, label %8
8: ; preds = %0, %4
%9 = phi i64 [ 0, %0 ], [ %5, %4 ]
%10 = phi i64 [ 1, %0 ], [ %6, %4 ]
%11 = getelementptr inbounds [42 x i32], [42 x i32]* %1, i64 0, i64 %9
store i32 0, i32* %11
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = icmp eq i32 %12, 0
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
%19 = icmp eq i64 %10, 1
br i1 %19, label %4, label %20
20: ; preds = %8, %20
%21 = phi i64 [ %27, %20 ], [ 1, %8 ]
%22 = getelementptr inbounds [42 x i32], [42 x i32]* %1, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
%27 = add nuw nsw i64 %21, 1
%28 = icmp eq i64 %27, %10
br i1 %28, label %4, label %20
29: ; preds = %4
ret void
}