#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 example5(void) {
  int a[40];
  int i = 0;
  a[i] = 0;
  while (i < 42) {
    int j = i;
    a[j] = 0;
    i++;
    assert(a[i] == 0);
    assert(a[i - 1] == 0);
    assert(a[j] == 0);
    if (i > 1) {
      assert(a[i - 2] == 0);
      assert(a[j - 1] == 0);
    }
  }
}


x86 assembly (clang, -O0):
<example5>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0xa4(%rbp)
movslq -0xa4(%rbp),%rax
movl   $0x0,-0xa0(%rbp,%rax,4)
cmpl   $0x2a,-0xa4(%rbp)
jge    121b <example5+0x10b>
mov    -0xa4(%rbp),%eax
mov    %eax,-0xa8(%rbp)
movslq -0xa8(%rbp),%rax
movl   $0x0,-0xa0(%rbp,%rax,4)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
movslq -0xa4(%rbp),%rax
cmpl   $0x0,-0xa0(%rbp,%rax,4)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0xa4(%rbp),%eax
sub    $0x1,%eax
cltq
cmpl   $0x0,-0xa0(%rbp,%rax,4)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movslq -0xa8(%rbp),%rax
cmpl   $0x0,-0xa0(%rbp,%rax,4)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x1,-0xa4(%rbp)
jle    1216 <example5+0x106>
mov    -0xa4(%rbp),%eax
sub    $0x2,%eax
cltq
cmpl   $0x0,-0xa0(%rbp,%rax,4)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0xa8(%rbp),%eax
sub    $0x1,%eax
cltq
cmpl   $0x0,-0xa0(%rbp,%rax,4)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
jmp    1137 <example5+0x27>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<example5>:
push   %rbp
push   %rbx
sub    $0xa8,%rsp
movl   $0x0,(%rsp)
xor    %edi,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x2,%ebx
movl   $0x0,-0x4(%rsp,%rbx,4)
xor    %edi,%edi
cmpl   $0x0,(%rsp,%rbx,4)
sete   %dil
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %ebp,%ebp
cmpl   $0x0,-0x8(%rsp,%rbx,4)
sete   %bpl
mov    %ebp,%edi
call   1030 <assert@plt>
mov    %ebp,%edi
call   1030 <assert@plt>
add    $0x1,%rbx
cmp    $0x2b,%rbx
jne    1140 <example5+0x30>
add    $0xa8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @example5() {
%1 = alloca [40 x i32]
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
%4 = load i32, i32* %2
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %5
store i32 0, i32* %6
br label %7
7: ; preds = %58, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 42
br i1 %9, label %10, label %59
10: ; preds = %7
%11 = load i32, i32* %2
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %13
store i32 0, i32* %14
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i32, i32* %2
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = icmp eq i32 %35, 0
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i32, i32* %2
%40 = icmp sgt i32 %39, 1
br i1 %40, label %41, label %58
41: ; preds = %10
%42 = load i32, i32* %2
%43 = sub nsw i32 %42, 2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = icmp eq i32 %46, 0
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = load i32, i32* %3
%51 = sub nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = icmp eq i32 %54, 0
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
br label %58
58: ; preds = %41, %10
br label %7
59: ; preds = %7
ret void
}

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