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


x86 assembly (clang, -O0):
<example3>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0xb4(%rbp)
cmpl   $0x2a,-0xb4(%rbp)
jge    1179 <example3+0x69>
movslq -0xb4(%rbp),%rax
movl   $0x0,-0xb0(%rbp,%rax,4)
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
movslq -0xb4(%rbp),%rax
movl   $0x1,-0xb0(%rbp,%rax,4)
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1125 <example3+0x15>
cmpl   $0x2,-0xb0(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x1,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0xffffffff,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<example3>:
push   %rax
xor    %edi,%edi
call   1030 <assert@plt>
xor    %edi,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %edi,%edi
pop    %rax
jmp    1030 <assert@plt>

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

LLVM IR (-O2):
define void @example3() {
%1 = tail call i32 @assert(i32 0)
%2 = tail call i32 @assert(i32 0)
%3 = tail call i32 @assert(i32 1)
%4 = tail call i32 @assert(i32 0)
ret void
}