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


x86 assembly (clang, -O0):
<example2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x1,-0xb4(%rbp)
cmpl   $0x2b,-0xb4(%rbp)
jge    118d <example2+0x7d>
mov    -0xb4(%rbp),%eax
sub    $0x1,%eax
cltq
movl   $0x0,-0xb0(%rbp,%rax,4)
mov    -0xb4(%rbp),%eax
sub    $0x1,%eax
cltq
cmpl   $0x0,-0xb0(%rbp,%rax,4)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1125 <example2+0x15>
cmpl   $0x0,-0xb0(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x94(%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>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<example2>:
push   %rbx
sub    $0xb0,%rsp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movl   $0x0,(%rsp,%rbx,4)
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,0x98(%rsp)
sete   %dil
call   1030 <assert@plt>
add    $0x1,%rbx
cmp    $0x2a,%rbx
jne    1120 <example2+0x10>
xor    %edi,%edi
cmpl   $0x0,(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,0x1c(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,0xa4(%rsp)
sete   %dil
add    $0xb0,%rsp
pop    %rbx
jmp    1030 <assert@plt>

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

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