#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;
  int x;
  while (i < 42) {
    a[i] = 0;
    int v = i;
    x = a[v];
    assert(x == 0);
    i++;
  }
}


x86 assembly (clang, -O0):
<example3>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0xb4(%rbp)
cmpl   $0x2a,-0xb4(%rbp)
jge    118c <example3+0x7c>
movslq -0xb4(%rbp),%rax
movl   $0x0,-0xb0(%rbp,%rax,4)
mov    -0xb4(%rbp),%eax
mov    %eax,-0xbc(%rbp)
movslq -0xbc(%rbp),%rax
mov    -0xb0(%rbp,%rax,4),%eax
mov    %eax,-0xb8(%rbp)
cmpl   $0x0,-0xb8(%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 <example3+0x15>
add    $0xc0,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @example3() {
%1 = alloca [42 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %2
br label %5
5: ; preds = %8, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 42
br i1 %7, label %8, label %23
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
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [42 x i32], [42 x i32]* %1, i64 0, i64 %14
%16 = load i32, i32* %15
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %5
23: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @example3() {
%1 = tail call i32 @assert(i32 1)
%2 = tail call i32 @assert(i32 1)
%3 = tail call i32 @assert(i32 1)
%4 = tail call i32 @assert(i32 1)
%5 = tail call i32 @assert(i32 1)
%6 = tail call i32 @assert(i32 1)
%7 = tail call i32 @assert(i32 1)
%8 = tail call i32 @assert(i32 1)
%9 = tail call i32 @assert(i32 1)
%10 = tail call i32 @assert(i32 1)
%11 = tail call i32 @assert(i32 1)
%12 = tail call i32 @assert(i32 1)
%13 = tail call i32 @assert(i32 1)
%14 = tail call i32 @assert(i32 1)
%15 = tail call i32 @assert(i32 1)
%16 = tail call i32 @assert(i32 1)
%17 = tail call i32 @assert(i32 1)
%18 = tail call i32 @assert(i32 1)
%19 = tail call i32 @assert(i32 1)
%20 = tail call i32 @assert(i32 1)
%21 = tail call i32 @assert(i32 1)
%22 = tail call i32 @assert(i32 1)
%23 = tail call i32 @assert(i32 1)
%24 = tail call i32 @assert(i32 1)
%25 = tail call i32 @assert(i32 1)
%26 = tail call i32 @assert(i32 1)
%27 = tail call i32 @assert(i32 1)
%28 = tail call i32 @assert(i32 1)
%29 = tail call i32 @assert(i32 1)
%30 = tail call i32 @assert(i32 1)
%31 = tail call i32 @assert(i32 1)
%32 = tail call i32 @assert(i32 1)
%33 = tail call i32 @assert(i32 1)
%34 = tail call i32 @assert(i32 1)
%35 = tail call i32 @assert(i32 1)
%36 = tail call i32 @assert(i32 1)
%37 = tail call i32 @assert(i32 1)
%38 = tail call i32 @assert(i32 1)
%39 = tail call i32 @assert(i32 1)
%40 = tail call i32 @assert(i32 1)
%41 = tail call i32 @assert(i32 1)
%42 = tail call i32 @assert(i32 1)
ret void
}